org.dolben.iiid
Class Rn

java.lang.Object
  extended by org.dolben.iiid.Rn

public class Rn
extends java.lang.Object

These are collected functions on generic vectors and matrices.

A scalar is represented by a double. (gratuitous comment;-)

A vector is represented by a one dimensional array of doubles.

A matrix is represented by a two dimensional array of doubles where the row is indexed first.

None of these functions modify their arguments. A returned vector or matrix result is a new array.


Constructor Summary
Rn()
           
 
Method Summary
static double[] add(double[] u, double[] v)
          Adds two vectors
static double angle(double[] u, double[] v)
          Computes the angle between two vectors
static double dot(double[] u, double[] v)
          Computes the dot product of two vectors
static double magnitude(double[] v)
          Computes the magnitude of a vector
static double[] multiply(double[][] a, double[] v)
          Multiplies a vector by a matrix
static double[][] multiply(double[][] b, double[][] a)
          Multiplies two matrices
static double[] multiply(double s, double[] v)
          Multiplies a vector by a scalar
static double[] subtract(double[] u, double[] v)
          Subtracts one vector from another
static double[][] transpose(double[][] a)
          Transposes a matrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rn

public Rn()
Method Detail

multiply

public static double[] multiply(double s,
                                double[] v)
Multiplies a vector by a scalar

Parameters:
s - a scalar
v - a vector
Returns:
the scaled vector

dot

public static double dot(double[] u,
                         double[] v)
Computes the dot product of two vectors

Parameters:
u - one vector
v - another vector
Returns:
the dot product

magnitude

public static double magnitude(double[] v)
Computes the magnitude of a vector

Parameters:
v - a vector
Returns:
the magnitude

angle

public static double angle(double[] u,
                           double[] v)
Computes the angle between two vectors

Parameters:
u - one vector
v - another vector
Returns:
the angle in radians

add

public static double[] add(double[] u,
                           double[] v)
Adds two vectors

Parameters:
u - one vector
v - another vector
Returns:
the vector sum

subtract

public static double[] subtract(double[] u,
                                double[] v)
Subtracts one vector from another

Parameters:
u - another vector
v - one vector
Returns:
the vector difference, u-v

multiply

public static double[] multiply(double[][] a,
                                double[] v)
Multiplies a vector by a matrix

Parameters:
a - the matrix
v - the vector
Returns:
the transformed vector

multiply

public static double[][] multiply(double[][] b,
                                  double[][] a)
Multiplies two matrices

Parameters:
b - one matrix
a - another matrix
Returns:
the matrix product

transpose

public static double[][] transpose(double[][] a)
Transposes a matrix

Parameters:
a - a matrix
Returns:
the transpose