public static boolean isSymmetric ( DMatrixSparseCSC A , double tol ) { if ( A . numRows != A . numCols ) return false ; int N = A . numCols ; for ( int i = 0 ; i < N ; i ++ ) { int idx0 = A . col_idx [ i ] ; int idx1 = A . col_idx [ i + 1 ] ; for ( int index = idx0 ; index < idx1 ; index ++ ) { int j = A . nz_rows [ index ] ; double value_ji = A . nz_values [ index ] ; double value_ij = A . get ( i , j ) ; if ( Math . abs ( value_ij - value_ji ) > tol ) return false ; } } return true ; }
Checks to see if the matrix is symmetric to within tolerance .