public static void assertSymmetric(IDoubleMatrix mat,double epsilon){
  assertSquare(mat);
  for (int i=0; i < mat.getRowNum(); ++i) {
    for (int j=i + 1; j < mat.getRowNum(); ++j) {
      final double v1=mat.get(i,j);
      final double v2=mat.get(j,i);
      if (Double.isNaN(v1) || Double.isNaN(v2)) {
        if (!Double.isNaN(v1) || !Double.isNaN(v2)) {
          final String msg=String.format("Matrix is not symmetric with respect to Nans: (%d,%d)=%f (%d,%d)=%f",i,j,v1,j,i,v2);
          throw new AdeCoreIllegalArgumentException(msg);
        }
      }
 else       if (Math.abs(v1 - v2) > epsilon) {
        final String errorMsg=String.format("Matrix not symmetric: (%d,%d)=%f (%d,%d)=%f  (epsilon=%g)",i,j,v1,j,i,v2,epsilon);
        throw new AdeCoreIllegalArgumentException(errorMsg);
      }
    }
  }
}

public static void assertSymmetric ( IDoubleMatrix mat , double epsilon ) { assertSquare ( mat ) ; for ( int i = 0 ; i < mat . getRowNum ( ) ; ++ i ) { for ( int j = i + 1 ; j < mat . getRowNum ( ) ; ++ j ) { final double v1 = mat . get ( i , j ) ; final double v2 = mat . get ( j , i ) ; if ( Double . isNaN ( v1 ) || Double . isNaN ( v2 ) ) { if ( ! Double . isNaN ( v1 ) || ! Double . isNaN ( v2 ) ) { final String msg = String . format ( "Matrix is not symmetric with respect to Nans: (%d,%d)=%f (%d,%d)=%f" , i , j , v1 , j , i , v2 ) ; throw new AdeCoreIllegalArgumentException ( msg ) ; } } else if ( Math . abs ( v1 - v2 ) > epsilon ) { final String errorMsg = String . format ( "Matrix not symmetric: (%d,%d)=%f (%d,%d)=%f  (epsilon=%g)" , i , j , v1 , j , i , v2 , epsilon ) ; throw new AdeCoreIllegalArgumentException ( errorMsg ) ; } } } }
throws an exception if matrix is not symmetric
