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)
| 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 |