org.apache.commons.math
Class TestUtils

java.lang.Object
  extended by org.apache.commons.math.TestUtils

public class TestUtils
extends Object

Version:
$Revision: 776939 $ $Date: 2009-05-20 23:17:52 -0400 (Wed, 20 May 2009) $

Method Summary
static void assertContains(org.apache.commons.math.complex.Complex[] values, org.apache.commons.math.complex.Complex z, double epsilon)
          Fails iff values does not contain a number within epsilon of z.
static void assertContains(double[] values, double x, double epsilon)
          Fails iff values does not contain a number within epsilon of x.
static void assertContains(String msg, org.apache.commons.math.complex.Complex[] values, org.apache.commons.math.complex.Complex z, double epsilon)
          Fails iff values does not contain a number within epsilon of z.
static void assertContains(String msg, double[] values, double x, double epsilon)
          Fails iff values does not contain a number within epsilon of x.
static void assertEquals(org.apache.commons.math.complex.Complex expected, org.apache.commons.math.complex.Complex actual, double delta)
          Verifies that real and imaginary parts of the two complex arguments differ by at most delta.
static void assertEquals(double[] expected, double[] observed, double tolerance)
          Verifies that two double arrays have equal entries, up to tolerance
static void assertEquals(double expected, double actual, double delta)
          Verifies that expected and actual are within delta, or are both NaN or infinities of the same sign.
static void assertEquals(org.apache.commons.math.linear.FieldMatrix<? extends org.apache.commons.math.FieldElement<?>> expected, org.apache.commons.math.linear.FieldMatrix<? extends org.apache.commons.math.FieldElement<?>> observed)
          verifies that two matrices are equal
static void assertEquals(String msg, double[] expected, double[] observed, double tolerance)
          verifies that two arrays are close (sup norm)
static void assertEquals(String msg, double expected, double actual, double delta)
          Verifies that expected and actual are within delta, or are both NaN or infinities of the same sign.
static void assertEquals(String msg, org.apache.commons.math.linear.RealMatrix expected, org.apache.commons.math.linear.RealMatrix observed, double tolerance)
          verifies that two matrices are close (1-norm)
static
<T extends org.apache.commons.math.FieldElement<T>>
void
assertEquals(T[] m, T[] n)
          verifies that two arrays are equal
static void assertRelativelyEquals(double expected, double actual, double relativeError)
          Verifies that the relative error in actual vs.
static void assertRelativelyEquals(String msg, double expected, double actual, double relativeError)
          Verifies that the relative error in actual vs.
static void assertSame(org.apache.commons.math.complex.Complex expected, org.apache.commons.math.complex.Complex actual)
          Verifies that real and imaginary parts of the two complex arguments are exactly the same.
static void assertSame(double expected, double actual)
          Verifies that the two arguments are exactly the same, either both NaN or infinities of same sign, or identical floating point values.
static void checkSerializedEquality(Object object)
          Verifies that serialization preserves equals and hashCode.
static Object serializeAndRecover(Object o)
          Serializes an object to a bytes array and then recovers the object from the bytes array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

assertEquals

public static void assertEquals(double expected,
                                double actual,
                                double delta)
Verifies that expected and actual are within delta, or are both NaN or infinities of the same sign.


assertEquals

public static void assertEquals(String msg,
                                double expected,
                                double actual,
                                double delta)
Verifies that expected and actual are within delta, or are both NaN or infinities of the same sign.


assertSame

public static void assertSame(double expected,
                              double actual)
Verifies that the two arguments are exactly the same, either both NaN or infinities of same sign, or identical floating point values.


assertSame

public static void assertSame(org.apache.commons.math.complex.Complex expected,
                              org.apache.commons.math.complex.Complex actual)
Verifies that real and imaginary parts of the two complex arguments are exactly the same. Also ensures that NaN / infinite components match.


assertEquals

public static void assertEquals(org.apache.commons.math.complex.Complex expected,
                                org.apache.commons.math.complex.Complex actual,
                                double delta)
Verifies that real and imaginary parts of the two complex arguments differ by at most delta. Also ensures that NaN / infinite components match.


assertEquals

public static void assertEquals(double[] expected,
                                double[] observed,
                                double tolerance)
Verifies that two double arrays have equal entries, up to tolerance


serializeAndRecover

public static Object serializeAndRecover(Object o)
Serializes an object to a bytes array and then recovers the object from the bytes array. Returns the deserialized object.

Parameters:
o - object to serialize and recover
Returns:
the recovered, deserialized object

checkSerializedEquality

public static void checkSerializedEquality(Object object)
Verifies that serialization preserves equals and hashCode. Serializes the object, then recovers it and checks equals and hash code.

Parameters:
object - the object to serialize and recover

assertRelativelyEquals

public static void assertRelativelyEquals(double expected,
                                          double actual,
                                          double relativeError)
Verifies that the relative error in actual vs. expected is less than or equal to relativeError. If expected is infinite or NaN, actual must be the same (NaN or infinity of the same sign).

Parameters:
expected - expected value
actual - observed value
relativeError - maximum allowable relative error

assertRelativelyEquals

public static void assertRelativelyEquals(String msg,
                                          double expected,
                                          double actual,
                                          double relativeError)
Verifies that the relative error in actual vs. expected is less than or equal to relativeError. If expected is infinite or NaN, actual must be the same (NaN or infinity of the same sign).

Parameters:
msg - message to return with failure
expected - expected value
actual - observed value
relativeError - maximum allowable relative error

assertContains

public static void assertContains(String msg,
                                  org.apache.commons.math.complex.Complex[] values,
                                  org.apache.commons.math.complex.Complex z,
                                  double epsilon)
Fails iff values does not contain a number within epsilon of z.

Parameters:
msg - message to return with failure
values - complex array to search
z - value sought
epsilon - tolerance

assertContains

public static void assertContains(org.apache.commons.math.complex.Complex[] values,
                                  org.apache.commons.math.complex.Complex z,
                                  double epsilon)
Fails iff values does not contain a number within epsilon of z.

Parameters:
values - complex array to search
z - value sought
epsilon - tolerance

assertContains

public static void assertContains(String msg,
                                  double[] values,
                                  double x,
                                  double epsilon)
Fails iff values does not contain a number within epsilon of x.

Parameters:
msg - message to return with failure
values - double array to search
x - value sought
epsilon - tolerance

assertContains

public static void assertContains(double[] values,
                                  double x,
                                  double epsilon)
Fails iff values does not contain a number within epsilon of x.

Parameters:
values - double array to search
x - value sought
epsilon - tolerance

assertEquals

public static void assertEquals(String msg,
                                org.apache.commons.math.linear.RealMatrix expected,
                                org.apache.commons.math.linear.RealMatrix observed,
                                double tolerance)
verifies that two matrices are close (1-norm)


assertEquals

public static void assertEquals(org.apache.commons.math.linear.FieldMatrix<? extends org.apache.commons.math.FieldElement<?>> expected,
                                org.apache.commons.math.linear.FieldMatrix<? extends org.apache.commons.math.FieldElement<?>> observed)
verifies that two matrices are equal


assertEquals

public static void assertEquals(String msg,
                                double[] expected,
                                double[] observed,
                                double tolerance)
verifies that two arrays are close (sup norm)


assertEquals

public static <T extends org.apache.commons.math.FieldElement<T>> void assertEquals(T[] m,
                                                                                    T[] n)
verifies that two arrays are equal



Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.