org.apache.commons.math3.linear
Class UnmodifiableRealVectorAbstractTest

java.lang.Object
  extended by org.apache.commons.math3.linear.UnmodifiableRealVectorAbstractTest
Direct Known Subclasses:
UnmodifiableArrayRealVectorTest, UnmodifiableOpenMapRealVectorTest

public abstract class UnmodifiableRealVectorAbstractTest
extends Object

This is an abstract test of the unmodifiable vector implementation. These unmodifiable vectors decorate a (modifiable) RealVector; therefore, a new implementation of this abstract test should be considered for each implementation of RealVector.

Version:
$Id$

Field Summary
protected static int DIM
          The dimension of the randomly generated vectors.
protected static double EPS
          Absolute tolerance.
protected static Set<String> EXCLUDE
          The list of methods which are excluded from the general test testAllButExcluded().
protected static Random RANDOM
          The random number generator (always initialized with the same seed.
 
Constructor Summary
UnmodifiableRealVectorAbstractTest()
           
 
Method Summary
 Object createParameter(Class<?> c)
          Creates a new random object of the specified type.
abstract  RealVector createVector()
          Creates a new random vector of a specified type.
static boolean equals(double[] x, double[] y)
          Returns true if the specified double arrays are equal (within a given tolerance).
static boolean equals(double x, double y)
          Returns true if the specified double are equal (within a given tolerance).
static boolean equals(Object x, Object y)
          Returns true if the specified Object are equal.
static boolean equals(RealMatrix x, RealMatrix y)
          Returns true if the specified RealMatrix are equal (within a given tolerance).
static boolean equals(RealVector x, double[] y)
          Returns true if the specified RealVector is equal to the specified double array (within a given tolerance).
static boolean equals(RealVector x, RealVector y)
          Returns true if the specified RealVector are equal (within a given tolerance).
 void testAddToEntry()
           
 void testAllButExcluded()
          This test calls callMethod(Method, RealVector, Object...) on every method defined in interface RealVector.
 void testGetEntry()
           
 void testGetSubVector()
           
 void testIterator()
           
 void testSetEntry()
           
 void testSetSubVector()
           
 void testSparseIterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIM

protected static final int DIM
The dimension of the randomly generated vectors.

See Also:
Constant Field Values

EPS

protected static final double EPS
Absolute tolerance.


EXCLUDE

protected static final Set<String> EXCLUDE
The list of methods which are excluded from the general test testAllButExcluded().


RANDOM

protected static final Random RANDOM
The random number generator (always initialized with the same seed.

Constructor Detail

UnmodifiableRealVectorAbstractTest

public UnmodifiableRealVectorAbstractTest()
Method Detail

equals

public static boolean equals(double x,
                             double y)
Returns true if the specified double are equal (within a given tolerance).

Parameters:
x - First double.
y - Second double.
Returns:
true if x and y are equal.

equals

public static boolean equals(double[] x,
                             double[] y)
Returns true if the specified double arrays are equal (within a given tolerance).

Parameters:
x - First array.
y - Second array.
Returns:
true if x and y are equal.

equals

public static boolean equals(RealVector x,
                             RealVector y)
Returns true if the specified RealVector are equal (within a given tolerance).

Parameters:
x - First vector.
y - Second vector.
Returns:
true if x and y are equal.

equals

public static boolean equals(RealVector x,
                             double[] y)
Returns true if the specified RealVector is equal to the specified double array (within a given tolerance).

Parameters:
x - Vector.
y - Array.
Returns:
true if x and y are equal.

equals

public static boolean equals(RealMatrix x,
                             RealMatrix y)
Returns true if the specified RealMatrix are equal (within a given tolerance).

Parameters:
x - First matrix.
y - Second matrix.
Returns:
true if x and y are equal.

equals

public static boolean equals(Object x,
                             Object y)
Returns true if the specified Object are equal.

Parameters:
x - First object.
y - Second object.
Returns:
true if x and y are equal.
Throws:
IllegalArgumentException - if x and y could not be compared.

createVector

public abstract RealVector createVector()
Creates a new random vector of a specified type. This vector is then to be wrapped in an unmodifiable vector.

Returns:
a new random vector.

createParameter

public Object createParameter(Class<?> c)
Creates a new random object of the specified type.

Parameters:
c - Class of the object to be created.
Returns:
a new random object.
Throws:
IllegalArgumentException - if the specified class is not recognized by this method.

testAllButExcluded

public void testAllButExcluded()
                        throws IllegalAccessException,
                               IllegalArgumentException,
                               InvocationTargetException
This test calls callMethod(Method, RealVector, Object...) on every method defined in interface RealVector. It generates the appropriate random arguments. Some methods are manually excluded (see EXCLUDE), they must be handled by separate tests.

Throws:
IllegalAccessException
IllegalArgumentException
InvocationTargetException

testGetEntry

public void testGetEntry()

testSetEntry

public void testSetEntry()

testAddToEntry

public void testAddToEntry()

testGetSubVector

public void testGetSubVector()

testSetSubVector

public void testSetSubVector()

testIterator

public void testIterator()

testSparseIterator

public void testSparseIterator()


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.