com.lgc.wsh.opt
Class VectUtil

java.lang.Object
  extended by com.lgc.wsh.opt.VectUtil

public class VectUtil
extends java.lang.Object

Implements convenience methods for Vect.


Field Summary
(package private) static Almost ALMOST_DOT
           
 
Constructor Summary
VectUtil()
           
 
Method Summary
static boolean areSame(VectConst v1, VectConst v2)
          See if two vectors are the same.
static Vect cloneZero(VectConst v)
          Clone a vector and initialized to zero, so that out.dot(out) == 0.
static void copy(Vect to, VectConst from)
          Copy the state of one vector onto another.
static int getTransposePrecision(VectConst data, VectConst model, LinearTransform transform)
          Return the number of significant digits in the dot product when calculated with and without the transpose.
static int getTransposePrecision(VectConst data, VectConst model, Transform transform)
          Return the number of significant digits in the dot product when calculated with and without the transpose.
static void scale(Vect v, double scalar)
          Scale a vector by a scalar constant.
static void test(VectConst vect)
          Exercise all methods of Vect.
static void zero(Vect v)
          Set the magnitude of this vector to zero, so that this.dot(this) == 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALMOST_DOT

static final Almost ALMOST_DOT
Constructor Detail

VectUtil

public VectUtil()
Method Detail

scale

public static void scale(Vect v,
                         double scalar)
Scale a vector by a scalar constant.

Parameters:
v - Vector to scale.
scalar - Factor to scale the vector.

zero

public static void zero(Vect v)
Set the magnitude of this vector to zero, so that this.dot(this) == 0.

Parameters:
v - Vector to zero

copy

public static void copy(Vect to,
                        VectConst from)
Copy the state of one vector onto another.

Parameters:
to - Vector whose state should be initialized with the state of from.
from - Vector whose state should be copied.

cloneZero

public static Vect cloneZero(VectConst v)
Clone a vector and initialized to zero, so that out.dot(out) == 0.

Parameters:
v - Vect to clone
Returns:
A cloned copy of the vector set to zero magnitude.

areSame

public static boolean areSame(VectConst v1,
                              VectConst v2)
See if two vectors are the same. Useful for test code.

Parameters:
v1 - First vector
v2 - Second vector
Returns:
true if vectors appear to be the same, within floating precision.

test

public static void test(VectConst vect)
Exercise all methods of Vect.

Parameters:
vect - An instance of a Vect to test. Should be initialized to random non-zero values. A vector of zero magnitude will fail.

getTransposePrecision

public static int getTransposePrecision(VectConst data,
                                        VectConst model,
                                        LinearTransform transform)
Return the number of significant digits in the dot product when calculated with and without the transpose.

Parameters:
data - Nonzero sample data
model - A nonzero sample model.
transform - The transform to test.
Returns:
number of digits in precision.

getTransposePrecision

public static int getTransposePrecision(VectConst data,
                                        VectConst model,
                                        Transform transform)
Return the number of significant digits in the dot product when calculated with and without the transpose.

Parameters:
data - Nonzero sample data
model - A nonzero sample model.
transform - The transform to test.
Returns:
number of digits in precision.