c1 c2 C3 C4 c1 c2 C3 C4
R1 1 0 0 0 R1 1+1 -1 0 0
R2 0 0 0 0 R2 -1 1 0 0
R3 0 0 0 0 R3 0 0 0 0
R4 0 0 0 0 R4 0 0 0 0
c1 c2 C3 C4 c1 c2 C3 C4
R1 2 -1 0 0 R1 2 -1 0 0
R2 -1 1+1 -1 0 R2 -1 2 -1 0
R3 0 -1 1 0 R3 0 -1 1+1 -1
R4 0 0 0 0 R4 0 0 -1 1
c1 c2 C3 C4
R1 2 -1 0 0
R2 -1 2 -1 0
R3 0 -1 2 -1
R4 0 0 -1 1
So, this is my problem.I have to generate this kind of matrix step by step. The steps are shown here. After searching on google I came to know that this kind of matrix is called symmetric matrix. The matrix and transpose of this matrix is same. I try to write down some code to implement this.
import Jama.Matrix;
public class mutest {
public static void main(String args[]){
Matrix omega=new Matrix(5,5);
Matrix omega1=new Matrix(5,5);
for(int i=0;i<=4;i++){
for(int j=0;j<4;j++) {
if (i == j) {
omega1.set(i, j, 1);//Here I set the value 1 if i=j
} else {
omega1.set(i, j, -1);//Here I set the value -1 if i not equal j
}
}
omega=omega.plus(omega1);
omega.print(9,6);
}
}
}
But I don't get the desire output: I got
5.000000 -5.000000 -5.000000 -5.000000 0.000000
-4.000000 4.000000 -4.000000 -4.000000 0.000000
-3.000000 -3.000000 3.000000 -3.000000 0.000000
-2.000000 -2.000000 -2.000000 2.000000 0.000000
-1.000000 -1.000000 -1.000000 -1.000000 0.000000
This one is not symmetric matrix. Can anyone tell me what should I change in my code block. I almost reach the goal.