|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectmpv2.AllMatrices
mpv2.DiagonalMatrix
public class DiagonalMatrix
This is a diagonal matrix class made by implementing AllMatrices.
| Field Summary |
|---|
| Fields inherited from class mpv2.AllMatrices |
|---|
K, N |
| Constructor Summary | |
|---|---|
DiagonalMatrix(AllMatrices B)
Construct a diagonal matrix from another matrix (of any kind) by extracting the elements on the diagonal. |
|
DiagonalMatrix(double[] vals)
Construct a diagonal matrix from a one-dimensional array |
|
DiagonalMatrix(double[][] A)
Construct a diagonal matrix from a 2-D array, only values in the diagonal are copied. |
|
DiagonalMatrix(int n)
Construct an n-by-n diagonal matrix of zeros. |
|
DiagonalMatrix(int n,
double s)
Construct an n-by-n diagonal matrix with constant value in each element |
|
| Method Summary | |
|---|---|
void |
addColumn(int k,
double factor,
double[] x)
Add a column of the matrix multiplied by a factor to x, x = x + A[][k] Legal range of the integer argument is 0 <= k < K. |
java.lang.Object |
clone()
Clone the Matrix object. |
double |
cond()
Matrix condition (2 norm) |
DiagonalMatrix |
copy()
Make a deep copy of a matrix |
double |
det()
Matrix determinant |
double |
get(int n)
Get a single element, A(n,n). |
double |
get(int n,
int k)
Get a single element, A(n,k). |
double |
innerProduct(int k1,
int k2)
Returns the inner product of two matrix column vectors, which for a diagonal matrix is zero. |
double |
norm2()
Two norm |
double |
normF()
Frobenius norm |
int |
rank()
Matrix rank |
void |
set(int n,
double s)
Set a single element, A(n,n)=s. |
void |
set(int n,
int k,
double s)
Set a single element, A(n,k)=s, but only if (n==k). |
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 |
times(double[] y,
double[] x)
Multiplies the matrix by an array, x = A*y. |
void |
transposeTimes(double[] x,
double[] y)
Multiplies the transposed matrix by an array, y = A'*x. |
| Methods inherited from class mpv2.AllMatrices |
|---|
chol, columnNorm0, columnNorm1, columnNorm2, columnNormInf, 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, getColumn, getColumnDimension, getK, getN, getRow, getRow, getRowDimension, getSubMatrix, getSubMatrix, getSubMatrix, getSubMatrix, getValue, lu, lup, norm1, normInf, pluseqOuterProduct, print, print, print, print, qr, setColumn, setRow, setValue, sumAll, svd, times, times, times, trace, transposeTimes, transposeTimes, transposeTimes |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DiagonalMatrix(int n)
n - Number of rows and columns
public DiagonalMatrix(int n,
double s)
n - Number of rows and columnss - Fill the matrix with this scalar value.public DiagonalMatrix(double[][] A)
A - Two-dimensional array of doubles.
java.lang.IllegalArgumentException - All rows must have the same lengthpublic DiagonalMatrix(double[] vals)
vals - One-dimensional arraypublic DiagonalMatrix(AllMatrices B)
B - a matrix of any kind, class is a subclass of AllMatrices| Method Detail |
|---|
public DiagonalMatrix copy()
public java.lang.Object clone()
clone in class java.lang.Objectpublic double get(int n)
n - Row and column index.
java.lang.ArrayIndexOutOfBoundsException
public double get(int n,
int k)
get in class AllMatricesn - Row index.k - Column index.
java.lang.ArrayIndexOutOfBoundsException
public void set(int n,
double s)
n - Row and column index.s - A(n,n).
java.lang.ArrayIndexOutOfBoundsException
public void set(int n,
int k,
double s)
set in class AllMatricesn - Row index.k - Column index.s - A(n,k).
java.lang.ArrayIndexOutOfBoundsException
public void addColumn(int k,
double factor,
double[] x)
0 <= k < K. x = x+f*A(:,k+1).
Note that this function can not be used from Matlab, use getColumn(k) to
get A(:,k+1) and calculate the new x in Matlab.
addColumn in class AllMatricesk - number of the column the matrix A.factor - a factor to multiply the column vector by.x - an array of length N.public void setAll(double[] vals)
setAll in class AllMatricesvals - One-dimensional array of doubles, packed by columns (ala Fortran).public double normF()
normF in class AllMatricespublic double det()
det in class AllMatricespublic int rank()
rank in class AllMatricespublic double cond()
cond in class AllMatricespublic double norm2()
norm2 in class AllMatrices
public double innerProduct(int k1,
int k2)
innerProduct in class AllMatricesk1 - number for the first dictionary element.k2 - number for the second dictionary element.
public void times(double[] y,
double[] x)
times in class AllMatricesy - the input arrayx - the results as an array of length N.
public void transposeTimes(double[] x,
double[] y)
transposeTimes in class AllMatricesx - 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 | |||||||