public static void assertEquals(String msg,double[] expected,double[] observed,double tolerance){
  StringBuilder out=new StringBuilder(msg);
  if (expected.length != observed.length) {
    out.append("\n Arrays not same length. \n");
    out.append("expected has length ");
    out.append(expected.length);
    out.append(" observed length = ");
    out.append(observed.length);
    Assert.fail(out.toString());
  }
  boolean failure=false;
  for (int i=0; i < expected.length; i++) {
    if (!Precision.equalsIncludingNaN(expected[i],observed[i],tolerance)) {
      failure=true;
      out.append("\n Elements at index ");
      out.append(i);
      out.append(" differ. ");
      out.append(" expected = ");
      out.append(expected[i]);
      out.append(" observed = ");
      out.append(observed[i]);
    }
  }
  if (failure) {
    Assert.fail(out.toString());
  }
}

public static void assertEquals ( String msg , double [ ] expected , double [ ] observed , double tolerance ) { StringBuilder out = new StringBuilder ( msg ) ; if ( expected . length != observed . length ) { out . append ( "\n Arrays not same length. \n" ) ; out . append ( "expected has length " ) ; out . append ( expected . length ) ; out . append ( " observed length = " ) ; out . append ( observed . length ) ; Assert . fail ( out . toString ( ) ) ; } boolean failure = false ; for ( int i = 0 ; i < expected . length ; i ++ ) { if ( ! Precision . equalsIncludingNaN ( expected [ i ] , observed [ i ] , tolerance ) ) { failure = true ; out . append ( "\n Elements at index " ) ; out . append ( i ) ; out . append ( " differ. " ) ; out . append ( " expected = " ) ; out . append ( expected [ i ] ) ; out . append ( " observed = " ) ; out . append ( observed [ i ] ) ; } } if ( failure ) { Assert . fail ( out . toString ( ) ) ; } }
verifies that two arrays are close ( sup norm )
