edu.stanford.rsl.konrad.numerics
Class SimpleOperators

java.lang.Object
  extended by edu.stanford.rsl.konrad.numerics.SimpleOperators

public abstract class SimpleOperators
extends java.lang.Object

Author:
Andreas Keil

Constructor Summary
SimpleOperators()
           
 
Method Summary
static SimpleMatrix add(SimpleMatrix... addends)
          Computes the sum of provided matrices
static SimpleVector add(SimpleVector... addends)
          Computes the sum of supplied vectors
static SimpleMatrix concatenateHorizontally(SimpleVector... columns)
          Creates a new matrix which is composed of all input column vectors, stacked next to each other.
static SimpleVector concatenateVertically(SimpleVector... parts)
          Creates a new vector which is composed of all input vectors, stacked over each other.
static SimpleMatrix divideElementWise(SimpleMatrix M1, SimpleMatrix M2)
           
static SimpleVector divideElementWise(SimpleVector v1, SimpleVector v2)
          Computes the element wise division of v1 by v2.
static boolean equalElementWise(SimpleMatrix M1, SimpleMatrix M2, double delta)
           
static boolean equalElementWise(SimpleVector v1, SimpleVector v2, double delta)
           
static SimpleMatrix max(SimpleMatrix... matrices)
          Computes and returns the element-wise maximum of all given matrices.
static SimpleVector max(SimpleVector... vectors)
          Computes and returns the element-wise maximum of all given vectors.
static SimpleMatrix min(SimpleMatrix... matrices)
          Computes and returns the element-wise minimum of all given matrices.
static SimpleVector min(SimpleVector... vectors)
          Computes and returns the element-wise minimum of all given vectors.
static SimpleVector multiply(SimpleMatrix M, SimpleVector v)
          Performs a standard matrix-vector product.
static SimpleVector multiply(SimpleVector v, SimpleMatrix M)
          Performs a vector-matrix product, assuming a row vector.
static SimpleMatrix multiplyElementWise(SimpleMatrix... factors)
           
static SimpleVector multiplyElementWise(SimpleVector... factors)
          Multiplies the supplied vectors element wise
static double multiplyInnerProd(SimpleVector v1, SimpleVector v2)
           Computes the inner product multiplication (dot product) of v1 and v2.
static SimpleMatrix multiplyMatrixProd(SimpleMatrix M1, SimpleMatrix M2)
          Computes the product of two matrices
static SimpleMatrix multiplyOuterProd(SimpleVector v1, SimpleVector v2)
          Computes the outer product multiplication of v1 and v2; i.e v1 x v2
static SimpleMatrix subtract(SimpleMatrix M1, SimpleMatrix M2)
          Subtracts M2 from M1
static SimpleVector subtract(SimpleVector v1, SimpleVector v2)
          subtracts v2 from v1
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleOperators

public SimpleOperators()
Method Detail

add

public static SimpleVector add(SimpleVector... addends)

Computes the sum of supplied vectors

e.g. SimpleVector x = new SimpleVector(1,2,3);
SimpleVector y = new SimpleVector(1,2,3);
SimpleVector z = new SimpleVector(1,0,0);
SimpleOperators.add(x,y,z) returns [3,4,6];

Parameters:
addends - is comma-separated list or an array of vectors.
Returns:
the sum of supplied vectors.

subtract

public static SimpleVector subtract(SimpleVector v1,
                                    SimpleVector v2)

subtracts v2 from v1


multiplyElementWise

public static SimpleVector multiplyElementWise(SimpleVector... factors)

Multiplies the supplied vectors element wise

e.g. SimpleVector x = new SimpleVector(1,2,3);
SimpleVector y = new SimpleVector(1,2,3);
SimpleVector z = new SimpleVector(1,0,0);
SimpleOperators.multiplyElementWise(x,y,z) returns [1,0,0];

Parameters:
factors - is a comma-separated list or an array of vectors.
Returns:
element wise multiplication for supplied vectors

divideElementWise

public static SimpleVector divideElementWise(SimpleVector v1,
                                             SimpleVector v2)

Computes the element wise division of v1 by v2.

e.g. SimpleVector x = new SimpleVector(1,2,3);
SimpleVector y = new SimpleVector(2,10,5);
SimpleOperations.divideElementWise(x,y) returns [0.5,0.2,0.6];

Parameters:
v1 - is vector to be divided
v2 - is divisor
Returns:

multiplyInnerProd

public static double multiplyInnerProd(SimpleVector v1,
                                       SimpleVector v2)

Computes the inner product multiplication (dot product) of v1 and v2.

SimpleVector x = new SimpleVector(1,2);
SimpleVector y = new SimpleVector(3,10);
SimpleOperations.multiplyInnerProd(x,y) = 1*3 + 2*10 = 23;

Parameters:
v1 - is first vector
v2 - is second vector
Returns:
the inner product multiplication of v1 and v2

multiplyOuterProd

public static SimpleMatrix multiplyOuterProd(SimpleVector v1,
                                             SimpleVector v2)
Computes the outer product multiplication of v1 and v2; i.e v1 x v2

Parameters:
v1 - is first vector
v2 - is second vector
Returns:
matrix representing v1 x v2

concatenateVertically

public static SimpleVector concatenateVertically(SimpleVector... parts)
Creates a new vector which is composed of all input vectors, stacked over each other.

Parameters:
parts - The vectors to concatenate.
Returns:
The vertically concatenated vector.

concatenateHorizontally

public static SimpleMatrix concatenateHorizontally(SimpleVector... columns)
Creates a new matrix which is composed of all input column vectors, stacked next to each other.

Parameters:
columns - The vectors to stack.
Returns:
The horizontally concatenated matrix.

equalElementWise

public static boolean equalElementWise(SimpleVector v1,
                                       SimpleVector v2,
                                       double delta)

max

public static SimpleVector max(SimpleVector... vectors)
Computes and returns the element-wise maximum of all given vectors.

Parameters:
vectors - A comma-separated list or an array of vectors.
Returns:
A new vector with the element-wise maximums of all given input vectors.

min

public static SimpleVector min(SimpleVector... vectors)
Computes and returns the element-wise minimum of all given vectors.

Parameters:
vectors - A comma-separated list or an array of vectors.
Returns:
A new vector with the element-wise minimums of all given input vectors.

add

public static SimpleMatrix add(SimpleMatrix... addends)
Computes the sum of provided matrices

Parameters:
addends - A comma-separated list or an array of matrices.
Returns:
a matrix representing the sum of provided matrices

subtract

public static SimpleMatrix subtract(SimpleMatrix M1,
                                    SimpleMatrix M2)
Subtracts M2 from M1

Parameters:
M1 -
M2 -
Returns:
matrix representing the subtraction of M2 from M1

multiplyMatrixProd

public static SimpleMatrix multiplyMatrixProd(SimpleMatrix M1,
                                              SimpleMatrix M2)
Computes the product of two matrices

Parameters:
M1 - is left matrix
M2 - is right matrix
Returns:
a matrix representing the product of provided matrices

multiplyElementWise

public static SimpleMatrix multiplyElementWise(SimpleMatrix... factors)

divideElementWise

public static SimpleMatrix divideElementWise(SimpleMatrix M1,
                                             SimpleMatrix M2)

equalElementWise

public static boolean equalElementWise(SimpleMatrix M1,
                                       SimpleMatrix M2,
                                       double delta)

max

public static SimpleMatrix max(SimpleMatrix... matrices)
Computes and returns the element-wise maximum of all given matrices.

Parameters:
matrices - A comma-separated list or an array of matrices.
Returns:
A new matrix with the element-wise maximums of all given input matrices.

min

public static SimpleMatrix min(SimpleMatrix... matrices)
Computes and returns the element-wise minimum of all given matrices.

Parameters:
matrices - A comma-separated list or an array of matrices.
Returns:
A new matrix with the element-wise minimums of all given input matrices.

multiply

public static SimpleVector multiply(SimpleMatrix M,
                                    SimpleVector v)
Performs a standard matrix-vector product.

Parameters:
M - A matrix, used as first factor.
v - A vector, used as second factor.
Returns:
The matrix-vector product $\mathbf{M} \cdot \mathbf{v}$.

multiply

public static SimpleVector multiply(SimpleVector v,
                                    SimpleMatrix M)
Performs a vector-matrix product, assuming a row vector.

Parameters:
v - A vector, assumed to be a row vector, used as first factor.
M - A matrix, used as second factor.
Returns:
The vector-matrix product $\mathbf{v}^T \cdot \mathbf{M}$.