Below is my function to transpose a Matrix in Java which has the form double [][]:
public static double[][] transposeMatrix(double [][] m){
for (int i = 0; i < m.length; i++) {
for (int j = i+1; j < m[0].length; j++) {
double temp = m[i][j];
m[i][j] = m[j][i];
m[j][i] = temp;
}
}
return m;
}
But it’s not working properly. Can anyone tell me what I’m doing wrong here?