|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object mpv2.AllMatrices mpv2.SparseVectorMatrix
public class SparseVectorMatrix
This class is a matrix implementation of the AllMatrices superclass, where each column is a SparseVector.
Field Summary |
---|
Fields inherited from class mpv2.AllMatrices |
---|
K, N |
Constructor Summary | |
---|---|
SparseVectorMatrix(AllMatrices B)
Construct a new matrix from another matrix (of any kind) |
|
SparseVectorMatrix(double[][] A)
Construct a matrix from a 2-D array, all values are copied. |
|
SparseVectorMatrix(double[] vals,
int m)
Construct a matrix from a one-dimensional packed array |
|
SparseVectorMatrix(int iN,
int iK)
Construct a N×K matrix with only zero values. |
Method Summary | |
---|---|
void |
addColumn(int k,
double factor,
double[] x)
Add a column of the matrix multiplied by a factor to a given vector. |
double |
get(int n,
int k)
Return an entry of the matrix. |
double[] |
getColumn(int k)
Get a column in the matrix as an array |
SparseVector |
getSparseColumn(int k)
Get a copy of a column in the matrix as a SparseVector |
double |
innerProduct(int k1,
int k2)
Returns the inner product of two matrix column vectors. |
void |
set(int n,
int k,
double val)
Set an entry (a value) in the matrix. |
void |
setAll(double[] vals)
Set all entries of to matrix to the supplied new values If argument is wrong length an IllegalArgumentException is thrown. |
void |
setColumn(int k,
double[] c)
Replace a column in the matrix with the given column vector. |
void |
setColumn(int k,
SparseVector c)
Replace a column in the matrix with a copy of the given column. |
void |
times(double[] y,
double[] x)
Multiplies the matrix by an array. |
void |
transposeTimes(double[] x,
double[] y)
Multiplies the transposed matrix by an array. |
Methods inherited from class mpv2.AllMatrices |
---|
chol, columnNorm0, columnNorm1, columnNorm2, columnNormInf, cond, det, eig, eqConstant, eqCopy, eqCopy, eqCopy, eqCopy, eqCopy, eqDifference, eqEProduct, eqEQuotient, eqIdentity, eqInverse, eqIProduct, eqNegate, eqOnes, eqPermuteColumns, eqPermuteRows, eqProduct, eqProduct, eqRandom, eqScaleColumns, eqScaleRows, eqSum, eqTProduct, eqTranspose, eqZeros, getAll, getAll, getColumn, getColumnDimension, getK, getN, getRow, getRow, getRowDimension, getSubMatrix, getSubMatrix, getSubMatrix, getSubMatrix, getValue, lu, lup, norm1, norm2, normF, normInf, pluseqOuterProduct, print, print, print, print, qr, rank, setRow, setValue, sumAll, svd, times, times, times, trace, transposeTimes, transposeTimes, transposeTimes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SparseVectorMatrix(int iN, int iK)
N×K
matrix with only zero values.
iN
- number of rows, i.e. length of column vectors of the matrix.iK
- number of columnspublic SparseVectorMatrix(double[] vals, int m)
vals
- One-dimensional array of doubles, packed by columns (ala Fortran).m
- Number of rows, i.e. length of columns.
java.lang.IllegalArgumentException
- Array length must be a multiple of m.public SparseVectorMatrix(double[][] A)
A
- Two-dimensional array of doubles.
java.lang.IllegalArgumentException
- All rows must have the same lengthpublic SparseVectorMatrix(AllMatrices B)
B
- a matrix of any kind, class is a subclass of AllMatricesMethod Detail |
---|
public double get(int n, int k)
0 <= n < N
and 0 <= k < K
.
If any argument is outside legal range 0.0 is returned without error or warning.
get
in class AllMatrices
n
- row number for the returned entry value.k
- column number for the returned entry value.
public void set(int n, int k, double val)
0 <= n < N
and 0 <= k < K
.
If any argument is outside legal range nothing is done.
set
in class AllMatrices
n
- row number for the entry value to be changed.k
- column number for the entry value to be changed.val
- the value to be put into the given entry of the dictionary.public double[] getColumn(int k)
getColumn
in class AllMatrices
k
- column number for the column to be returned
public SparseVector getSparseColumn(int k)
k
- column number for the column to be returned
public void setColumn(int k, double[] c)
N
.
We should have: 0 <= k < K
.
If any argument is outside legal dimension or range nothing is done.
setColumn
in class AllMatrices
k
- column number for the column to be changed.c
- the column as an array of length Npublic void setColumn(int k, SparseVector c)
N
.
We should have: 0 <= k < K
.
If any argument is outside legal dimension or range nothing is done.
k
- column number for the column to be changed.c
- the column as a SparseVectorpublic void addColumn(int k, double factor, double[] x)
0 <= k < K
. x = x+factor*D(:,k+1)
.
addColumn
in class AllMatrices
k
- number of the column in dictionary, i.e. matrix D
.factor
- a factor to multiply the column vector by.x
- an array of length N
.public void setAll(double[] vals)
setAll
in class AllMatrices
vals
- One-dimensional array of doubles, packed by columns (ala Fortran).public double innerProduct(int k1, int k2)
0 <= k1 < K
and 0 <= k2 < K
. k1
or k2
is out of range, 0.0 is returned.
innerProduct
in class AllMatrices
k1
- number for the first column.k2
- number for the second column.public void times(double[] y, double[] x)
A
is
N×K
, x
is N×1
,
and y
is K×1
.x = A*y
.
times
in class AllMatrices
y
- the input arrayx
- the results as an array of length N
.public void transposeTimes(double[] x, double[] y)
A
is
N×K
, x
is N×1
,
and y
is K×1
.y = A'*x
.
transposeTimes
in class AllMatrices
x
- the input arrayy
- the results as an array of length K
.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |