MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / isSymmetric

Method isSymmetric

JSAT/src/jsat/linear/Matrix.java:1069–1078  ·  view source on GitHub ↗

Checks to see if the given input is approximately symmetric. Rounding errors may cause the computation of a matrix to come out non symmetric, where |a[i,h] - a[j, i]| < eps. Despite these errors, it may be preferred to treat the matrix as perfectly symmetric regardless. @param A the input matrix

(Matrix A, double eps)

Source from the content-addressed store, hash-verified

1067 * @return {@code true} if the matrix is approximately symmetric
1068 */
1069 public static boolean isSymmetric(Matrix A, double eps)
1070 {
1071 if(!A.isSquare())
1072 return false;
1073 for(int i = 0; i < A.rows(); i++)
1074 for(int j = i+1; j < A.cols(); j++)
1075 if( Math.abs(A.get(i, j)-A.get(j, i)) > eps)
1076 return false;
1077 return true;
1078 }
1079
1080 /**
1081 * Checks to see if the given input is a perfectly symmetric matrix

Callers 3

Calls 4

isSquareMethod · 0.45
rowsMethod · 0.45
colsMethod · 0.45
getMethod · 0.45

Tested by 2