this is not the entire code but i dnt know if i put a certain part in the correction location
its the red part
insert
Code:
smatrix(A,x,n);
n=4;
double A_t, A_s, y;
int i,j;
for (i=0; i<rowLength; i++)
for (j=0; j<colLength; j++)
A_t[j][i] = A[i][j];
A_t=(double **)calloc(4,sizeof(double *));
for(i=0;i<4;i++)
A_t[i]=(double *)calloc(4 ,sizeof(double));
printf("Matrix A_s is:\n\n ");
for(q=0;q<4;q++)
printf("%6.3f ",A_s[0][q]);
printf("\n");
for(q=0;q<4;q++)
printf("%6.3f ",A_s[1][q]);
printf("\n");
for(q=0;q<4;q++)
printf("%6.3f ",A_s[2][q]);
printf("\n");
for(q=0;q<4;q++)
printf("%6.3f ",A_s[3][q]);
printf("\n\n");
printf("Vector y is:");
printf("\n\n");
printf(" y[] = ");
for(q=0;q<4;q++)
printf("%6.3f ",b[j]);
printf("\n\n");
free(A);
free(A_s);
free(x);
free(y);
}
void smatrix(double **A, double *x, double x[], double y[], double A_s, double norm_x);
{
int i, j, k;
for(i=0; i<4; i++)
{
for(k=0; k<4; k++)
{
A_s[i][k] = (A[i][k]+A_t[i][k])/2;
}
}
double dotp (double A_s[], double x[], double n)
{
int output;
output = 0;
int i;
for (i=0; i<n; i++)
result += A_t[i]*x[i];
return output;
}
double norm_x, storage, add;
int k,
for(k=0;k<n;k++)
{
add = x[k] * x[k];
storage = storage + add;
}
norm_x=sqrt(sum);
return norm_x;
}