SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.vector.doubles
Class IsVector

java.lang.Object
  extended by com.numericalmethod.suanshu.vector.doubles.IsVector

public class IsVector
extends java.lang.Object

These are the utility functions to validate input arguments for vector operations.


Nested Class Summary
static class IsVector.SizeMismatch
          This is the exception thrown when an operation is performed on two vectors with different sizes.
static class IsVector.VectorAccessException
          This is the exception thrown when any invalid access to a Vector instance is detected.
 
Method Summary
static boolean equal(Vector v1, Vector v2, double epsilon)
          Check the equality of two vectors up to a precision.
static void throwIfInvalidIndex(Vector v, int index)
          Check if an index is a valid index.
static void throwIfNotEqualSize(Vector v1, Vector v2)
          Check if the input vectors have the same size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

throwIfNotEqualSize

public static void throwIfNotEqualSize(Vector v1,
                                       Vector v2)
Check if the input vectors have the same size.

Parameters:
v1 - a vector
v2 - a vector
Throws:
IsVector.SizeMismatch - if sizes do not match

throwIfInvalidIndex

public static void throwIfInvalidIndex(Vector v,
                                       int index)
Check if an index is a valid index.

Parameters:
v - a vector
index - a vector index
Throws:
IsVector.VectorAccessException - if the index is invalid

equal

public static boolean equal(Vector v1,
                            Vector v2,
                            double epsilon)
Check the equality of two vectors up to a precision. Two vectors are equal if
  1. the dimensions are the same;
  2. all entries are equal

Parameters:
v1 - a vector
v2 - another vector
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
Returns:
true if all entries are equal, entry by entry

SuanShu, a Java numerical and statistical library

Copyright © 2012 Numerical Method Inc. Ltd. All Rights Reserved.