|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object mp.MPDictionary mp.MPSparseMatrix
This class is a sparse matrix implementation of the MPDictionary superclass.
Constructor Summary | |
MPSparseMatrix(int iN,
int iK)
Constructs a N×K matrix or dictionary with only zeros. |
|
MPSparseMatrix(int iN,
int iK,
double[] val)
Constructs a N×K matrix or dictionary with values
from given one-dimensional array (which represents the matrix).
|
Method Summary | |
void |
addColumn(int k,
double factor,
double[] x)
Add a column of the matrix multiplied by a factor to a given vector. |
int |
getCapacity()
Returns current size (capacity for non-zero values) in sparse matrix. |
double[] |
getColumn(int k)
Returns a column of the matrix, i.e. a dictionary element or atom. |
void |
getColumn(int k,
double[] d)
Sets argument d to a column of the matrix, i.e. a dictionary element or atom. |
int |
getNonZeroCount()
Returns number of non-zeros elements in sparse matrix. |
double[] |
getRow(int n)
Returns a row of the matrix which represents the dictionary Legal range of the integer argument is 0 <= n < N .
|
double |
getValue(int n,
int k)
Returns an entry of the matrix, i.e. a single entry of a dictionary element (atom). |
double |
innerProduct(int k1,
int k2)
Returns the inner product of two dictionary elements, i.e. matrix column vectors. |
double[] |
multiply(double[] y)
Multiplies the dictionary D by array y .
|
void |
multiply(double[] y,
double[] x)
Multiplies the dictionary D by array y .
|
void |
normalize()
Normalize the dictionary, i.e. multiply each dictionary element (matrix column vector) by a number (scalar) such that the 2-norm, i.e. sum of squares, will be 1.0. |
void |
setValue(int n,
int k,
double val)
Set an entry (a value) in the dictionary. |
double[] |
transposeMultiply(double[] x)
Multiplies the transposed dictionary D' by array x .
|
void |
transposeMultiply(double[] x,
double[] y)
Multiplies the transposed dictionary D' by array x .
|
Methods inherited from class mp.MPDictionary |
getColumns, getK, getN, getRow, getRows, isNormalized, setColumn, setRow |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MPSparseMatrix(int iN, int iK)
N×K
matrix or dictionary with only zeros.
iN
- length of dictionary elements, i.e. column vectors of the matrixiK
- number of dictionary elementspublic MPSparseMatrix(int iN, int iK, double[] val)
N×K
matrix or dictionary with values
from given one-dimensional array (which represents the matrix).
Length of the array should be N*K
.
iN
- length of dictionary elements, i.e. column vectors of the matrixiK
- number of dictionary elementsval
- the values (ordered by column, i.e. by dictionary elements)Method Detail |
public int getNonZeroCount()
public int getCapacity()
public double getValue(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.
getValue
in class MPDictionary
n
- row number for the returned entry value.k
- column number for the returned entry value.public void setValue(int n, int k, double val)
0 <= n < N
and 0 <= k < K
.
If any argument is outside legal range nothing is done.
setValue
in class MPDictionary
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 innerProduct(int k1, int k2)
0 <= k1 < K
and 0 <= k2 < K
.
If k1
or k2
are out of range, 0.0 should be returned.
innerProduct
in class MPDictionary
k1
- number for the first dictionary element.k2
- number for the second dictionary element.public void normalize()
normalized
to true.
normalize
in class MPDictionary
public double[] getColumn(int k)
0 <= k < K
.
If argument is out of range a length N
array of zeros should be returned. D(:,k+1)
.
getColumn
in class MPDictionary
k
- number of the column in dictionary, i.e. matrix D
.public void getColumn(int k, double[] d)
0 <= k < K
.
If argument is out of range a length N
array of zeros should be returned. D(:,k+1)
.
getColumn
in class MPDictionary
k
- number of the column in dictionary, i.e. matrix D
.d
- the given column of matrix D
.public void addColumn(int k, double factor, double[] x)
0 <= k < K
. x = x+f*D(:,k+1)
.
addColumn
in class MPDictionary
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 double[] getRow(int n)
0 <= n < N
.
If argument is out of range a length K
array of zeros should be returned. D(n+1,:)
.
getRow
in class MPDictionary
n
- number of the row in dictionary, i.e. matrix D
.public double[] transposeMultiply(double[] x)
D'
by array x
.
D
is the matrix representing the dictionary, each column is a dictionary
element. An array y
is returned. D
is
N×K
, x
is N×1
,
and y
is K×1
. y = D'*x
.
transposeMultiply
in class MPDictionary
x
- the signal (column vector) that is multiplied by the transposed dictionary.
K
.public void transposeMultiply(double[] x, double[] y)
D'
by array x
.
D
is the matrix representing the dictionary, each column is a dictionary
element. An array y
is returned. D
is
N×K
, x
is N×1
,
and y
is K×1
. y = D'*x
.
transposeMultiply
in class MPDictionary
x
- the signal (column vector) that is multiplied by the transposed dictionary.y
- the results as an array of length K
.public double[] multiply(double[] y)
D
by array y
.
D
is the matrix representing the dictionary,
each column is a dictionary element.
An array x
is returned. D
is
N×K
, x
is N×1
,
and y
is K×1
. x = D*y
.
multiply
in class MPDictionary
y
- the coefficient vector that is multiplied by the dictionary.
N
.public void multiply(double[] y, double[] x)
D
by array y
.
D
is the matrix representing the dictionary,
each column is a dictionary element.
An array x
is returned. D
is
N×K
, x
is N×1
,
and y
is K×1
. x = D*y
.
multiply
in class MPDictionary
y
- the coefficient vector that is multiplied by the dictionary.x
- the results as an array of length N
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |