com.gregdennis.drej
Class Matrices

java.lang.Object
  extended by com.gregdennis.drej.Matrices

public final class Matrices
extends java.lang.Object

Utility methods for matrices and vectors.

Author:
Greg Dennis (gdennis@mit.edu)

Method Summary
static double distance(GVector x1, GVector x2)
          Returns the distance between the two specified vectors: ∥x1 - x2∥
static double distanceSquared(GVector x1, GVector x2)
          Returns the squared distance between the two specified vectors: ∥x1 - x2∥²
static GVector mapCols(Function fun, GMatrix points)
          Maps the given function to each column in the points matrix and returns the vector of values.
static GVector mapRows(Function fun, GMatrix points)
          Maps the given function to each row in the points matrix and returns the vector of values.
static GMatrix randomGaussianMatrix(int rows, int cols)
          Returns a matrix with the specified number of rows and columns where each element is randomly chosen from a Gaussian ("normal") distribution with mean 0.0 and standard deviation 1.0.
static GVector randomGaussianVector(int size)
          Returns a vector of the given size where each element is randomly chosen from a Gaussian ("normal") distribution with mean 0.0 and standard deviation 1.0.
static GMatrix randomUniformMatrix(int rows, int cols)
          Returns a matrix with the specified number of rows and columns where each element is randomly chosen from a uniform distribution on the interval [0, 1].
static GVector randomUniformVector(int size)
          Returns a vector of the given size where each element is randomly chosen from a uniform distribution on the interval [0, 1].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

distance

public static double distance(GVector x1,
                              GVector x2)
Returns the distance between the two specified vectors:
∥x1 - x2∥

Throws:
MismatchedSizeException - if vectors have different sizes

distanceSquared

public static double distanceSquared(GVector x1,
                                     GVector x2)
Returns the squared distance between the two specified vectors:
∥x1 - x2∥²

Throws:
MismatchedSizeException - if vectors have different sizes

mapCols

public static GVector mapCols(Function fun,
                              GMatrix points)
Maps the given function to each column in the points matrix and returns the vector of values.


mapRows

public static GVector mapRows(Function fun,
                              GMatrix points)
Maps the given function to each row in the points matrix and returns the vector of values.


randomUniformMatrix

public static GMatrix randomUniformMatrix(int rows,
                                          int cols)
Returns a matrix with the specified number of rows and columns where each element is randomly chosen from a uniform distribution on the interval [0, 1].


randomGaussianMatrix

public static GMatrix randomGaussianMatrix(int rows,
                                           int cols)
Returns a matrix with the specified number of rows and columns where each element is randomly chosen from a Gaussian ("normal") distribution with mean 0.0 and standard deviation 1.0.


randomUniformVector

public static GVector randomUniformVector(int size)
Returns a vector of the given size where each element is randomly chosen from a uniform distribution on the interval [0, 1].


randomGaussianVector

public static GVector randomGaussianVector(int size)
Returns a vector of the given size where each element is randomly chosen from a Gaussian ("normal") distribution with mean 0.0 and standard deviation 1.0.