gov.sns.tools.math
Class Vector

java.lang.Object
  |
  +--Jama.Matrix
        |
        +--gov.sns.tools.math.Vector
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Vector
extends Jama.Matrix
implements java.io.Serializable

Specializes the Jama.Matrix class to a vector.

See Also:
Serialized Form

Constructor Summary
Vector(double[] arrVals)
          Constructs a Vector specified by the double array
Vector(int nSize)
          Constructs a column vector of zeros
Vector(int nSize, double dblVal)
          Constructs a constant column vector
Vector(Jama.Matrix mat)
          Constructs a new Vector from a Matrix object.
Vector(Vector vecInit)
          Copy Constructor Constructs a new Vector initialized to the argument.
 
Method Summary
 Vector copyVector()
          Perform a deep copy of this Vector object
 double get(int iIndex)
          Get individual element of a vector
 int getSize()
          Get size of Vector (number of elements)
 double innerProd(Vector vec)
          Vector inner product.
 Vector leftMultiply(Jama.Matrix mat)
          Vector left multiplication (post-multiply vector by matrix).
 Jama.Matrix outerProd(Vector vec)
          Vector outer product - computes the tensor product of two vector objects.
 Vector plus(Vector vec)
          Vector addition without destruction
 void plusEquals(Vector vec)
          Vector in-place addition
 void print(java.io.PrintWriter os)
          Print the vector contents to an output stream, does not add new line.
 void println(java.io.PrintWriter os)
          Print the vector contents to an output stream, add new line character.
static Vector random(int nSize)
          Generate a vector with uniformly distributed random elements
 Vector rightMultiply(Jama.Matrix mat)
          Vector right multiplication (pre-multiply vector by matrix).
 void set(int iIndex, double dblVal)
          Set individual element of a vector
 Vector timesScalar(double s)
          Scalar multiplication
 void timesScalarEqual(double s)
          In place scalar multiplication
 
Methods inherited from class Jama.Matrix
arrayLeftDivide, arrayLeftDivideEquals, arrayRightDivide, arrayRightDivideEquals, arrayTimes, arrayTimesEquals, chol, clone, cond, constructWithCopy, copy, det, eig, get, getArray, getArrayCopy, getColumnDimension, getColumnPackedCopy, getMatrix, getMatrix, getMatrix, getMatrix, getRowDimension, getRowPackedCopy, identity, inverse, lu, minus, minusEquals, norm1, norm2, normF, normInf, plus, plusEquals, print, print, print, print, qr, random, rank, read, set, setMatrix, setMatrix, setMatrix, setMatrix, solve, solveTranspose, svd, times, times, timesEquals, trace, transpose, uminus
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vector

public Vector(int nSize)
Constructs a column vector of zeros

Parameters:
nSize - vector size

Vector

public Vector(int nSize,
              double dblVal)
Constructs a constant column vector

Parameters:
nSize - vector size
dblVal - constant value

Vector

public Vector(double[] arrVals)
Constructs a Vector specified by the double array

Parameters:
arrVals - element values for vector

Vector

public Vector(Vector vecInit)
Copy Constructor Constructs a new Vector initialized to the argument.

Parameters:
vecInit - initial value

Vector

public Vector(Jama.Matrix mat)
Constructs a new Vector from a Matrix object. Vector is initialized to the first column of the matrix. This constructor is meant to take a column vector in Matrix form to the standard vector format.

Parameters:
mat - initial values
Method Detail

random

public static Vector random(int nSize)
Generate a vector with uniformly distributed random elements

Parameters:
nSize - size of created vector

copyVector

public Vector copyVector()
Perform a deep copy of this Vector object


getSize

public int getSize()
Get size of Vector (number of elements)


get

public double get(int iIndex)
           throws java.lang.ArrayIndexOutOfBoundsException
Get individual element of a vector

Parameters:
iIndex - index of element
Returns:
value of element
Throws:
java.lang.ArrayIndexOutOfBoundsException - iIndex is larger than vector size

set

public void set(int iIndex,
                double dblVal)
         throws java.lang.ArrayIndexOutOfBoundsException
Set individual element of a vector

Parameters:
iIndex - index of element
dblVal - new value of element
Throws:
java.lang.ArrayIndexOutOfBoundsException - iIndex is larger than the vector

plusEquals

public void plusEquals(Vector vec)
                throws java.lang.IllegalArgumentException
Vector in-place addition

Parameters:
vec - Vector to add to this vector
Throws:
java.lang.IllegalArgumentException - vec is not proper dimension

plus

public Vector plus(Vector vec)
            throws java.lang.IllegalArgumentException
Vector addition without destruction

Parameters:
vec - vector to add
Throws:
java.lang.IllegalArgumentException - vec is not proper dimension

timesScalar

public Vector timesScalar(double s)
Scalar multiplication

Parameters:
s - scalar value
Returns:
result of scalar multiplication

timesScalarEqual

public void timesScalarEqual(double s)
In place scalar multiplication

Parameters:
s - scalar

innerProd

public double innerProd(Vector vec)
                 throws java.lang.IllegalArgumentException
Vector inner product. Computes the inner product of two vectors of the same dimension.

Parameters:
vec - second vector
Returns:
inner product of this vector and argument
Throws:
java.lang.IllegalArgumentException - dimensions must agree

outerProd

public Jama.Matrix outerProd(Vector vec)
                      throws java.lang.IllegalArgumentException
Vector outer product - computes the tensor product of two vector objects. Returns the value this*vec' where the prime indicates transposition

Parameters:
vec - right argument
Returns:
outer product
Throws:
java.lang.IllegalArgumentException - vector dimension must agree

leftMultiply

public Vector leftMultiply(Jama.Matrix mat)
                    throws java.lang.IllegalArgumentException
Vector left multiplication (post-multiply vector by matrix).

Parameters:
mat - matrix operator
Returns:
result of vector-matrix product
Throws:
java.lang.IllegalArgumentException - dimensions must agree

rightMultiply

public Vector rightMultiply(Jama.Matrix mat)
                     throws java.lang.IllegalArgumentException
Vector right multiplication (pre-multiply vector by matrix).

Parameters:
mat - matrix operator
Returns:
result of vector-matrix product
Throws:
java.lang.IllegalArgumentException - dimensions must agree

print

public void print(java.io.PrintWriter os)
Print the vector contents to an output stream, does not add new line.

Parameters:
os - output stream object

println

public void println(java.io.PrintWriter os)
Print the vector contents to an output stream, add new line character.

Parameters:
os - output stream object