public static boolean isSymmetric(DMatrixRMaj m , double tol ) {
        if( m.numCols != m.numRows )
            return false;

        double max = CommonOps_DDRM.elementMaxAbs(m);

        for( int i = 0; i < m.numRows; i++ ) {
            for( int j = 0; j < i; j++ ) {
                double a = m.get(i,j)/max;
                double b = m.get(j,i)/max;

                double diff = Math.abs(a-b);

                if( !(diff <= tol) ) {
                    return false;
                }
            }
        }
        return true;
    }
public static boolean isSymmetric ( DMatrixRMaj m , double tol ) { if ( m . numCols != m . numRows ) return false ; double max = CommonOps_DDRM . elementMaxAbs ( m ) ; for ( int i = 0 ; i < m . numRows ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { double a = m . get ( i , j ) / max ; double b = m . get ( j , i ) / max ; double diff = Math . abs ( a - b ) ; if ( ! ( diff <= tol ) ) { return false ; } } } return true ; }
<p>
Returns true if the matrix is symmetric within the tolerance.  Only square matrices can be
symmetric.
</p>
<p>
A matrix is symmetric if:<br>
|a<sub>ij</sub> - a<sub>ji</sub>| &le; tol
</p>

@param m A matrix. Not modified.
@param tol Tolerance for how similar two elements need to be.
@return true if it is symmetric and false if it is not.