I am trying to convert Matlab code into c code, I verifying each step with Matlab result. everything matches except for subtraction the error scale is 1e-14 but due iterations it affects the whole answer.
Matlab:
s = c-A'*y;
c code:
for (i=0;i<A_cols;i++)
{
s[i][0] = c[i][0]-Temp_Mat_0[i][0];
}
I have done this (A'*y) aside and matched it to Matlab code
I entered the same values for both, but the are saved or displayed as follows: Values are:
A_example[16]= {8,1,1,2,-1,5,23,7,5,8,10,1,12,-1,5,23};
b_example[16]= {5.3326,12.8165,10.0277,19.4862};
c_example[16]= {13.3215,4.0611,24.2008,27.7622};
c code: saves as as
output for s:
Matlab Output is:
K>> full(A)
ans =
8 1 1 2
-1 5 23 7
5 8 10 1
12 -1 5 23
K>> full(b)
ans =
5.3326
12.8165
10.0277
19.4862
K>> full(c)
ans =
13.3215
4.0611
24.2008
27.7622
s =
1.0e-13 *
-0.0355
0.1599
-0.1421
0.0711
this error in addition to other errors based on subtraction makes my c code calculations drifting very far! is there any way to make both codes work with the same precision?