I have a matrix program that so far takes an input file in and expresses the numbers in matrices. I also wrote a function to find its transpose but I can't figure out how to do the symmetrical.
I have to take only 3 input parameters (MainMatrix[max][max] MainTranspose[max][max] and the Size)
It should return -1 if it isn't symmetrical and 0 if it is.
My program shows everything right except for 1 that says it is not symmetrical when it SHOULD be.
I hope one of you guys can help me with this.
int Symmetry (int mainmatrix[max][max], int maintranspose[max][max], int size) {
double thesqrtSize = sqrt((double)Size);
double fract = thesqrtSize - floor(thesqrtSize);
if(fract > 0.0001)
return -1;
int isqrtSize = (int)thesqrtSize;
int i, j;
for(i=0;i<isqrtSize;i++){
for(j=0;j<isqrtSize;j++) {
if(mainmatrix[i][j]!=maintranspose[i][j]) {
return -1;
}
}
}
return 0;
}