mpv2
Class AllMatrices

java.lang.Object
  extended by mpv2.AllMatrices
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BandMatrix, BlockMatrix, DiagonalMatrix, JamaMatrix, PermutationMatrix, RepeatBlockMatrix, SimpleMatrix, SparseMatrix, SparseVectorMatrix, SymmetricMatrix

public abstract class AllMatrices
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

mpv2 = Matrix package version 2

The abstract class AllMatrices contains common stuff for several kinds of matrices.

There is a quite large number of methods available for matrices in general and in this class specially. An overview may be helpful:

See Also:
Serialized Form

Field Summary
protected  int K
          Row and column dimensions.
protected  int N
          Row and column dimensions.
 
Constructor Summary
AllMatrices()
           
 
Method Summary
 void addColumn(int k, double s, double[] y)
          Add a column of the matrix multiplied by a factor to y, set y[n] = y[n] + s*A[n][k].
 CholeskyDecomposition chol()
          Cholesky Decomposition
 int columnNorm0(int k)
          The pseudo-zero-norm for a given column
 double columnNorm1(int k)
          One columnNorm for a given column
 double columnNorm2(int k)
          Two columnNorm for a given column
 double columnNormInf(int k)
          Inf columnNorm for a given column
 double cond()
          Matrix condition (2 norm)
 double det()
          Matrix determinant
 EigenvalueDecomposition eig()
          Eigenvalue Decomposition
 void eqConstant(double s)
          Set the matrix (this = A) to a constant s, A = s.
 void eqCopy(AllMatrices B)
          Set the matrix (this = A) to B, A = B.
 void eqCopy(AllMatrices B, int[] r, int[] c)
          Set the matrix (this = A) to a submatrix of B, A = B(r[], c[]).
 void eqCopy(AllMatrices B, int[] r, int j0, int j1)
          Set the matrix (this = A) to a submatrix of B, A = B(r[], j0:j1).
 void eqCopy(AllMatrices B, int i0, int i1, int[] c)
          Set the matrix (this = A) to a submatrix of B, A = B(i0:i1, c[]).
 void eqCopy(AllMatrices B, int i0, int i1, int j0, int j1)
          Set the matrix (this = A) to a submatrix of B, A = B(i0:i1, j0:j1).
 void eqDifference(AllMatrices B, AllMatrices C)
          Set the matrix (this = A) to difference of B and C, A = B - C.
 void eqEProduct(AllMatrices B, AllMatrices C)
          Set the matrix (this = A) to elementwise multiplication of B and C, A = B.
 void eqEQuotient(AllMatrices B, AllMatrices C)
          Set the matrix (this = A) to elementwise division of B and C, A = B.
 void eqIdentity()
          Set the matrix (this = A) to identity, A = I.
 void eqInverse(AllMatrices B)
          Set the matrix (this = A) to the inverse of B, A = inv(B) Matrix dimension must agree, if A is N-by-K then B is K-by-N If the (normal) inverse does not exist, then the Moore-Penrose pseudoivnverse should be returned
 void eqIProduct(AllMatrices A, AllMatrices B)
          Set the matrix (this = X) to product of A inverse and B, X = inv(A) * B.
 void eqNegate(AllMatrices B)
          Set the matrix (this = A) to the negative of B, A = -B.
 void eqOnes()
          Set the matrix (this = A) to ones, A = 1.
 void eqPermuteColumns(AllMatrices B, PermutationMatrix P)
          Permute the columns of matrix B and put result in this, A = B * P.
 void eqPermuteRows(PermutationMatrix P, AllMatrices B)
          Permute the rows of matrix B and put result in this, A = P * B.
 void eqProduct(AllMatrices B, AllMatrices C)
          Set the matrix (this = A) to product of B and C, A = B * C.
 void eqProduct(AllMatrices B, double s)
          Set the matrix (this = A) to B*s, A = B*s.
 void eqRandom()
          Set the matrix (this = A) to random elements, A = rand.
 void eqScaleColumns(AllMatrices B, DiagonalMatrix D)
          Scale the columns of matrix B and put result in this, A = B * D.
 void eqScaleRows(DiagonalMatrix D, AllMatrices B)
          Scale the rows of matrix B and put result in this, A = D * B.
 void eqSum(AllMatrices B, AllMatrices C)
          Set the matrix (this = A) to sum of B and C, A = B + C.
 void eqTProduct(AllMatrices B, AllMatrices C)
          Set the matrix (this = A) to product of B transposed and C, A = B' * C.
 void eqTranspose(AllMatrices B)
          Set the matrix (this = A) to the transposed of B, A = B' Matrix dimension must agree.
 void eqZeros()
          Set the matrix (this = A) to zeros, A = 0.
abstract  double get(int i, int j)
          Get a single element.
 double[] getAll()
          Get all entries of the matrix, as a one-dimensional column-packed array.
 void getAll(double[] vals)
          Get all entries of the matrix into argument vals in a column-packed way.
 double[] getColumn(int k)
          Get a column of the matrix.
 void getColumn(int k, double[] y)
          Get a column of the matrix into argument y.
 int getColumnDimension()
          Get column dimension.
 int getK()
          Get number of columns in the matrix, i.e. length of each row vector.
 int getN()
          Get number of rows in the matrix, i.e. length of each column vector.
 double[] getRow(int n)
          Get a row of the matrix.
 void getRow(int n, double[] x)
          Get a row of the matrix into argument x.
 int getRowDimension()
          Get row dimension.
 double[] getSubMatrix(int[] r, int[] c)
          Get a one-dimensional column packed copy of a submatrix.
 double[] getSubMatrix(int[] r, int j0, int j1)
          Get a one-dimensional column packed copy of a submatrix.
 double[] getSubMatrix(int i0, int i1, int[] c)
          Get a one-dimensional column packed copy of a submatrix.
 double[] getSubMatrix(int i0, int i1, int j0, int j1)
          Get a one-dimensional column packed copy of a submatrix.
 double getValue(int n, int k)
          Get a single element, i.e. the value of an entry of the matrix.
 double innerProduct(int k1, int k2)
          Returns the inner product of two matrix column vectors.
 LUDecomposition lu()
          LU Decomposition
 LUPDecomposition lup()
          LUP Decomposition
 double norm1()
          One norm
 double norm2()
          Two norm
 double normF()
          Frobenius norm
 double normInf()
          Infinity norm
 void pluseqOuterProduct(double s1, double s2, double[] u, double[] v)
          Add outer product of two vectors to this, A = s1*A + s2*(u*v').
 void print(int w, int d)
          Print the matrix to stdout.
 void print(java.text.NumberFormat format, int width)
          Print the matrix to stdout.
 void print(java.io.PrintWriter output, int w, int d)
          Print the matrix to the output stream.
 void print(java.io.PrintWriter output, java.text.NumberFormat format, int width)
          Print the matrix to the output stream.
 QRDecomposition qr()
          QR Decomposition
 int rank()
          Matrix rank
abstract  void set(int i, int j, double s)
          Set a single element.
 void setAll(double[] vals)
          Set all entries of the matrix to the supplied new values.
 void setColumn(int k, double[] y)
          Copy an array (y) into a column of the matrix.
 void setRow(int n, double[] x)
          Copy an array (x) into a row of the matrix.
 void setValue(int n, int k, double s)
          Set a single element, i.e. an entry (a value) in the matrix.
 double sumAll()
          Sum of all elements in matrix
 SingularValueDecomposition svd()
          Singular Value Decomposition
 double[] times(double[] x)
          Multiplies the matrix by an array (vector), return y = A*x.
 void times(double[] x, double[] y)
          Multiplies the matrix by an array (vector), set y = A*x.
 double[] times(SparseVector x)
          Multiplies the matrix by a SparseVector x, return y = A*x.
 void times(SparseVector x, double[] y)
          Multiplies the matrix by a SparseVector x, set y = A*x.
 double trace()
          Matrix trace.
 double[] transposeTimes(double[] y)
          Multiplies the transposed matrix by an array (vector), return x = A'*y.
 void transposeTimes(double[] y, double[] x)
          Multiplies the transposed matrix by an array (vector), set x = A'*y.
 double[] transposeTimes(SparseVector y)
          Multiplies the transposed matrix by a SparseVector y, return x = A'*y.
 void transposeTimes(SparseVector y, double[] x)
          Multiplies the transposed matrix by a SparseVector y, set x = A'*y.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N

protected int N
Row and column dimensions.


K

protected int K
Row and column dimensions.

Constructor Detail

AllMatrices

public AllMatrices()
Method Detail

get

public abstract double get(int i,
                           int j)
Get a single element.

Parameters:
i - Row index.
j - Column index.
Returns:
A(i,j)
Throws:
java.lang.ArrayIndexOutOfBoundsException

set

public abstract void set(int i,
                         int j,
                         double s)
Set a single element.

Parameters:
i - Row index.
j - Column index.
s - the value to be set into A(i,j).
Throws:
java.lang.ArrayIndexOutOfBoundsException

getN

public int getN()
Get number of rows in the matrix, i.e. length of each column vector.

Returns:
N, the number of rows.

getK

public int getK()
Get number of columns in the matrix, i.e. length of each row vector.

Returns:
K, the number of columns.

getRowDimension

public int getRowDimension()
Get row dimension.

Returns:
N, the number of rows.

getColumnDimension

public int getColumnDimension()
Get column dimension.

Returns:
K, the number of columns.

getValue

public double getValue(int n,
                       int k)
Get a single element, i.e. the value of an entry of the matrix. If arguments are outside legal range a zero is returned without error or warning.

Parameters:
n - Row index for the returned entry value.
k - Column index for the returned entry value.
Returns:
The matrix element, A(n,k).

getColumn

public double[] getColumn(int k)
Get a column of the matrix. If argument is out of range a length N array of zeros should be returned.

Parameters:
k - number of the column in the matrix
Returns:
the column

getColumn

public void getColumn(int k,
                      double[] y)
Get a column of the matrix into argument y. Legal range of the integer argument is 0 <= k < K.

Parameters:
k - number of the column in the matrix
y - is set to the given column of the matrix
Throws:
java.lang.IllegalArgumentException

getRow

public double[] getRow(int n)
Get a row of the matrix. Legal range of the integer argument is 0 <= n < N. If argument is out of range a length K array of zeros should be returned.

Parameters:
n - number of the row in the matrix A.
Returns:
the row

getRow

public void getRow(int n,
                   double[] x)
Get a row of the matrix into argument x. Legal range of the integer argument is 0 <= n < N.

Parameters:
n - number of the row in the matrix.
x - is set to the given row of matrix.
Throws:
java.lang.IllegalArgumentException

getAll

public double[] getAll()
Get all entries of the matrix, as a one-dimensional column-packed array.

Returns:
all entries in a one-dimensional array

getAll

public void getAll(double[] vals)
Get all entries of the matrix into argument vals in a column-packed way.

Parameters:
vals - an one-dimensional array where the values are copied into
Throws:
java.lang.IllegalArgumentException

getSubMatrix

public double[] getSubMatrix(int i0,
                             int i1,
                             int j0,
                             int j1)
Get a one-dimensional column packed copy of a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
j0 - Initial column index
j1 - Final column index
Returns:
Submatrix elements packed in a one-dimensional array by columns.

getSubMatrix

public double[] getSubMatrix(int[] r,
                             int[] c)
Get a one-dimensional column packed copy of a submatrix.

Parameters:
r - Array of row indices.
c - Array of column indices.
Returns:
Submatrix elements packed in a one-dimensional array by columns.

getSubMatrix

public double[] getSubMatrix(int i0,
                             int i1,
                             int[] c)
Get a one-dimensional column packed copy of a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
c - Array of column indices.
Returns:
Submatrix elements packed in a one-dimensional array by columns.

getSubMatrix

public double[] getSubMatrix(int[] r,
                             int j0,
                             int j1)
Get a one-dimensional column packed copy of a submatrix.

Parameters:
r - Array of row indices.
j0 - Initial column index
j1 - Final column index
Returns:
Submatrix elements packed in a one-dimensional array by columns.

setValue

public void setValue(int n,
                     int k,
                     double s)
Set a single element, i.e. an entry (a value) in the matrix. We should have: 0 <= n < N and 0 <= k < K. If any argument is outside legal range nothing is done.

Parameters:
n - Row index for the entry value to be changed.
k - Column index for the entry value to be changed.
s - Value to be put into the given entry of the matrix.

setColumn

public void setColumn(int k,
                      double[] y)
Copy an array (y) into a column of the matrix. Legal range of the integer argument is 0 <= k < K.

Parameters:
k - number of the column in the matrix
y - the values that are copied into the given column of the matrix
Throws:
java.lang.IllegalArgumentException

setRow

public void setRow(int n,
                   double[] x)
Copy an array (x) into a row of the matrix. Legal range of the integer argument is 0 <= n < N.

Parameters:
n - number of the row in the matrix A.
x - the given row of matrix A.
Throws:
java.lang.IllegalArgumentException

setAll

public void setAll(double[] vals)
Set all entries of the matrix to the supplied new values. If argument is wrong length an IllegalArgumentException is thrown.

Parameters:
vals - One-dimensional array of doubles, packed by columns (ala Fortran).
Throws:
java.lang.IllegalArgumentException

addColumn

public void addColumn(int k,
                      double s,
                      double[] y)
Add a column of the matrix multiplied by a factor to y, set y[n] = y[n] + s*A[n][k]. Legal range of the integer argument is 0 <= k < K.

Parameters:
k - number of the column the matrix A.
s - a scale factor to multiply the column vector by.
y - an array of length N.
Throws:
java.lang.IllegalArgumentException

times

public double[] times(double[] x)
Multiplies the matrix by an array (vector), return y = A*x.

Parameters:
x - the input array
Returns:
the results as an array of length N.

times

public double[] times(SparseVector x)
Multiplies the matrix by a SparseVector x, return y = A*x.

Parameters:
x - the input sparse vector of class SparseVector
Returns:
the results as an array of length N.

times

public void times(double[] x,
                  double[] y)
Multiplies the matrix by an array (vector), set y = A*x.

Parameters:
x - the input array
y - the results as an array of length N.
Throws:
java.lang.IllegalArgumentException

times

public void times(SparseVector x,
                  double[] y)
Multiplies the matrix by a SparseVector x, set y = A*x.

Parameters:
x - the input sparse vector
y - the results as an array of length N.
Throws:
java.lang.IllegalArgumentException

transposeTimes

public double[] transposeTimes(double[] y)
Multiplies the transposed matrix by an array (vector), return x = A'*y.

Parameters:
y - the input array
Returns:
the results as an array of length K.

transposeTimes

public double[] transposeTimes(SparseVector y)
Multiplies the transposed matrix by a SparseVector y, return x = A'*y.

Parameters:
y - the input sparse vector
Returns:
the results as an array of length K.

transposeTimes

public void transposeTimes(double[] y,
                           double[] x)
Multiplies the transposed matrix by an array (vector), set x = A'*y.

Parameters:
y - the input array
x - the results as an array of length K.
Throws:
java.lang.IllegalArgumentException

transposeTimes

public void transposeTimes(SparseVector y,
                           double[] x)
Multiplies the transposed matrix by a SparseVector y, set x = A'*y.

Parameters:
y - the input sparse vector
x - the results as an array of length K.
Throws:
java.lang.IllegalArgumentException

eqIdentity

public void eqIdentity()
Set the matrix (this = A) to identity, A = I. The elements along the main diagonal is set to 1, the other elements to 0.


eqZeros

public void eqZeros()
Set the matrix (this = A) to zeros, A = 0.


eqOnes

public void eqOnes()
Set the matrix (this = A) to ones, A = 1.


eqConstant

public void eqConstant(double s)
Set the matrix (this = A) to a constant s, A = s.

Parameters:
s - A single value

eqRandom

public void eqRandom()
Set the matrix (this = A) to random elements, A = rand. all random elements are different and between 0 and 1.


eqCopy

public void eqCopy(AllMatrices B)
Set the matrix (this = A) to B, A = B.

Parameters:
B - Matrix of same size as A
Throws:
java.lang.IllegalArgumentException

eqCopy

public void eqCopy(AllMatrices B,
                   int i0,
                   int i1,
                   int j0,
                   int j1)
Set the matrix (this = A) to a submatrix of B, A = B(i0:i1, j0:j1). The submatrix of B should be same size as A.

Parameters:
B - Matrix
i0 - Initial row index
i1 - Final row index
j0 - Initial column index
j1 - Final column index
Throws:
java.lang.IllegalArgumentException

eqCopy

public void eqCopy(AllMatrices B,
                   int[] r,
                   int[] c)
Set the matrix (this = A) to a submatrix of B, A = B(r[], c[]). The submatrix of B should be same size as A.

Parameters:
B - Matrix
r - Array of row indices.
c - Array of column indices.
Throws:
java.lang.IllegalArgumentException

eqCopy

public void eqCopy(AllMatrices B,
                   int i0,
                   int i1,
                   int[] c)
Set the matrix (this = A) to a submatrix of B, A = B(i0:i1, c[]). The submatrix of B should be same size as A.

Parameters:
B - Matrix
i0 - Initial row index
i1 - Final row index
c - Array of column indices.
Throws:
java.lang.IllegalArgumentException

eqCopy

public void eqCopy(AllMatrices B,
                   int[] r,
                   int j0,
                   int j1)
Set the matrix (this = A) to a submatrix of B, A = B(r[], j0:j1). The submatrix of B should be same size as A.

Parameters:
B - Matrix
r - Array of row indices.
j0 - Initial column index
j1 - Final column index
Throws:
java.lang.IllegalArgumentException

eqNegate

public void eqNegate(AllMatrices B)
Set the matrix (this = A) to the negative of B, A = -B.

Parameters:
B - Matrix of same size as A
Throws:
java.lang.IllegalArgumentException

eqProduct

public void eqProduct(AllMatrices B,
                      double s)
Set the matrix (this = A) to B*s, A = B*s.

Parameters:
B - Matrix of same size as A
Throws:
java.lang.IllegalArgumentException

eqSum

public void eqSum(AllMatrices B,
                  AllMatrices C)
Set the matrix (this = A) to sum of B and C, A = B + C.

Parameters:
B - Matrix of same size as A
C - Matrix of same size as A
Throws:
java.lang.IllegalArgumentException

eqDifference

public void eqDifference(AllMatrices B,
                         AllMatrices C)
Set the matrix (this = A) to difference of B and C, A = B - C.

Parameters:
B - Matrix of same size as A
C - Matrix of same size as A
Throws:
java.lang.IllegalArgumentException

eqEProduct

public void eqEProduct(AllMatrices B,
                       AllMatrices C)
Set the matrix (this = A) to elementwise multiplication of B and C, A = B.*C.

Parameters:
B - Matrix of same size as A
C - Matrix of same size as A
Throws:
java.lang.IllegalArgumentException

eqEQuotient

public void eqEQuotient(AllMatrices B,
                        AllMatrices C)
Set the matrix (this = A) to elementwise division of B and C, A = B./C. This is right division, left division can be done by switching arguments.

Parameters:
B - Matrix of same size as A
C - Matrix of same size as A
Throws:
java.lang.IllegalArgumentException

eqTranspose

public void eqTranspose(AllMatrices B)
Set the matrix (this = A) to the transposed of B, A = B' Matrix dimension must agree.

Parameters:
B - Matrix of 'opposite' size as A
Throws:
java.lang.IllegalArgumentException

eqInverse

public void eqInverse(AllMatrices B)
Set the matrix (this = A) to the inverse of B, A = inv(B) Matrix dimension must agree, if A is N-by-K then B is K-by-N If the (normal) inverse does not exist, then the Moore-Penrose pseudoivnverse should be returned

Parameters:
B - Matrix of 'opposite' size as A
Throws:
java.lang.IllegalArgumentException

eqProduct

public void eqProduct(AllMatrices B,
                      AllMatrices C)
Set the matrix (this = A) to product of B and C, A = B * C.

Parameters:
B - Matrix of size N-by-L
C - Matrix of size L-by-K, size of result is N-by-K
Throws:
java.lang.IllegalArgumentException

eqTProduct

public void eqTProduct(AllMatrices B,
                       AllMatrices C)
Set the matrix (this = A) to product of B transposed and C, A = B' * C.

Parameters:
B - Matrix of size L-by-N (the transposed is N-by-L)
C - Matrix of size L-by-K, size of result is N-by-K
Throws:
java.lang.IllegalArgumentException

eqIProduct

public void eqIProduct(AllMatrices A,
                       AllMatrices B)
Set the matrix (this = X) to product of A inverse and B, X = inv(A) * B. It should set this to the least square solution X to the equation: A*X=B. The JamaMatrix class is used, and the arguments names are as in that class, hopefully this helps not mixing them.

Parameters:
A - Matrix of size L-by-N (the (pseudo)inverse is N-by-L)
B - Matrix of size L-by-K, size of result is N-by-K
Throws:
java.lang.IllegalArgumentException

eqPermuteRows

public void eqPermuteRows(PermutationMatrix P,
                          AllMatrices B)
Permute the rows of matrix B and put result in this, A = P * B.

Parameters:
P - Permutation matrix of size N-by-N
B - Matrix of size N-by-K, size of result (this) is also N-by-K
Throws:
java.lang.IllegalArgumentException

eqPermuteColumns

public void eqPermuteColumns(AllMatrices B,
                             PermutationMatrix P)
Permute the columns of matrix B and put result in this, A = B * P.

Parameters:
B - Matrix of size N-by-K, size of result (this) is also N-by-K
P - Permutation matrix of size K-by-K
Throws:
java.lang.IllegalArgumentException

eqScaleRows

public void eqScaleRows(DiagonalMatrix D,
                        AllMatrices B)
Scale the rows of matrix B and put result in this, A = D * B.

Parameters:
D - Diagonal matrix of size N-by-N, class DiagonalMatrix
B - Matrix of size N-by-K, size of result (this) is also N-by-K
Throws:
java.lang.IllegalArgumentException

eqScaleColumns

public void eqScaleColumns(AllMatrices B,
                           DiagonalMatrix D)
Scale the columns of matrix B and put result in this, A = B * D.

Parameters:
B - Matrix of size N-by-K, size of result (this) is also N-by-K
D - Diagonal matrix of size N-by-N, class DiagonalMatrix
Throws:
java.lang.IllegalArgumentException

pluseqOuterProduct

public void pluseqOuterProduct(double s1,
                               double s2,
                               double[] u,
                               double[] v)
Add outer product of two vectors to this, A = s1*A + s2*(u*v'). This matrix, A, is of size N-by-K. If (s1 == 1): Each element is updated as: A(n,k) += s2*u(n)*v(k) Else if (s1 == 0): Each element is updated as: A(n,k) = s2*u(n)*v(k) Else: Each element is updated as: A(n,k) = s1*A(n,k) + s2*u(n)*v(k)

Parameters:
s1 - A single value
s2 - A single value
u - A vector with N elements
v - A vector with K elements
Throws:
java.lang.IllegalArgumentException

sumAll

public double sumAll()
Sum of all elements in matrix

Returns:
sum of all elements

norm1

public double norm1()
One norm

Returns:
maximum column sum.

norm2

public double norm2()
Two norm

Returns:
maximum singular value.

normInf

public double normInf()
Infinity norm

Returns:
maximum row sum.

normF

public double normF()
Frobenius norm

Returns:
sqrt of sum of squares of all elements.

trace

public double trace()
Matrix trace.

Returns:
sum of the diagonal elements.

det

public double det()
Matrix determinant

Returns:
determinant

rank

public int rank()
Matrix rank

Returns:
effective numerical rank, obtained from SVD.

cond

public double cond()
Matrix condition (2 norm)

Returns:
ratio of largest to smallest singular value.

columnNorm0

public int columnNorm0(int k)
The pseudo-zero-norm for a given column

Parameters:
k - number of the column in the matrix
Returns:
number of non-zero values in the column

columnNorm1

public double columnNorm1(int k)
One columnNorm for a given column

Parameters:
k - number of the column in the matrix
Returns:
sum of absulute values for a column

columnNorm2

public double columnNorm2(int k)
Two columnNorm for a given column

Parameters:
k - number of the column in the matrix
Returns:
sum of squared values for a column

columnNormInf

public double columnNormInf(int k)
Inf columnNorm for a given column

Parameters:
k - number of the column in the matrix
Returns:
maximum absulute values for a column

lu

public LUDecomposition lu()
LU Decomposition

Returns:
LUDecomposition
See Also:
LUDecomposition

lup

public LUPDecomposition lup()
LUP Decomposition

Returns:
LUPDecomposition
See Also:
LUPDecomposition

qr

public QRDecomposition qr()
QR Decomposition

Returns:
QRDecomposition
See Also:
QRDecomposition

chol

public CholeskyDecomposition chol()
Cholesky Decomposition

Returns:
CholeskyDecomposition
See Also:
CholeskyDecomposition

svd

public SingularValueDecomposition svd()
Singular Value Decomposition

Returns:
SingularValueDecomposition
See Also:
SingularValueDecomposition

eig

public EigenvalueDecomposition eig()
Eigenvalue Decomposition

Returns:
EigenvalueDecomposition
See Also:
EigenvalueDecomposition

print

public void print(int w,
                  int d)
Print the matrix to stdout. Line the elements up in columns with a Fortran-like 'Fw.d' style format.

Parameters:
w - Column width.
d - Number of digits after the decimal.

print

public void print(java.io.PrintWriter output,
                  int w,
                  int d)
Print the matrix to the output stream. Line the elements up in columns with a Fortran-like 'Fw.d' style format.

Parameters:
output - Output stream.
w - Column width.
d - Number of digits after the decimal.

print

public void print(java.text.NumberFormat format,
                  int width)
Print the matrix to stdout. Line the elements up in columns. Use the format object, and right justify within columns of width characters. Note that is the matrix is to be read back in, you probably will want to use a NumberFormat that is set to US Locale.

Parameters:
format - A Formatting object for individual elements.
width - Field width for each column.
See Also:
DecimalFormat.setDecimalFormatSymbols(java.text.DecimalFormatSymbols)

print

public void print(java.io.PrintWriter output,
                  java.text.NumberFormat format,
                  int width)
Print the matrix to the output stream. Line the elements up in columns. Use the format object, and right justify within columns of width characters. Note that is the matrix is to be read back in, you probably will want to use a NumberFormat that is set to US Locale.

Parameters:
output - the output stream.
format - A formatting object to format the matrix elements
width - Column width.
See Also:
DecimalFormat.setDecimalFormatSymbols(java.text.DecimalFormatSymbols)

innerProduct

public double innerProduct(int k1,
                           int k2)
Returns the inner product of two matrix column vectors. Legal range is 0 <= k1 < K and 0 <= k2 < K. If k1 or k2 are out of range, 0.0 should be returned.

Parameters:
k1 - number for the first dictionary element.
k2 - number for the second dictionary element.