sbrt.kernel.math
Class VectorComparer

java.lang.Object
  extended by sbrt.kernel.math.VectorComparer

public class VectorComparer
extends java.lang.Object

This class is used to compare vectors of double precision numbers.

Author:
This class was written and documented by Jeremiah Wright while in the Wagner lab.

Nested Class Summary
static class VectorComparer.Diff<V>
          Instances of this class are used to hold a variable and a pair of corresponding numerical values.
 
Constructor Summary
VectorComparer()
           
 
Method Summary
 boolean areSame(java.util.Map<?,java.lang.Double> m1, java.util.Map<?,java.lang.Double> m2, double tolerance)
          Indicates if the provided numerical vectors are equivalent.
<V> java.util.Set<VectorComparer.Diff<V>>
getDiffs(java.util.Map<? extends V,java.lang.Double> m1, java.util.Map<? extends V,java.lang.Double> m2, double tolerance)
          Returns the set of differences between the provided numerical vectors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorComparer

public VectorComparer()
Method Detail

areSame

public boolean areSame(java.util.Map<?,java.lang.Double> m1,
                       java.util.Map<?,java.lang.Double> m2,
                       double tolerance)
Indicates if the provided numerical vectors are equivalent.

Parameters:
m1 - variables mapped to a numerical value.
m2 - variables mapped to a numerical value.
tolerance - the amount by which two numerical values can differ but still be considered equivalent.
Returns:
true if the provided vectors are equivalent; false otherwise.

getDiffs

public <V> java.util.Set<VectorComparer.Diff<V>> getDiffs(java.util.Map<? extends V,java.lang.Double> m1,
                                                          java.util.Map<? extends V,java.lang.Double> m2,
                                                          double tolerance)
Returns the set of differences between the provided numerical vectors. Values are compared for equivalence for each variable that occurs in both provided vectors.

Type Parameters:
V - the variable type.
Parameters:
m1 - variables mapped to numerical values.
m2 - variables mapped to numerical values.
tolerance - the amount by which a two numerical values can differ but still be considered equivalent.
Returns:
the set of differences between the provided vectors.
See Also:
DoubleEquiv.areEquiv(double, double)