|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object mpv2.AllMatrices mpv2.SimpleMatrix
public class SimpleMatrix
This is a simple matrix class made by implementing AllMatrices as simple as possible. Only som constructors, and get and set are added here.
Also added some more methods, getColum, setColumn, addColum, getRow and setRow. But this implementation is still simple.
Field Summary |
---|
Fields inherited from class mpv2.AllMatrices |
---|
K, N |
Constructor Summary | |
---|---|
SimpleMatrix(AllMatrices B)
Construct a new matrix from another matrix (of any kind) if argument B is an object of class SimpleMatrix this is the same as (deep) copy (or clone). |
|
SimpleMatrix(double[][] A)
Construct a matrix from a 2-D array, all values are copied. |
|
SimpleMatrix(double[] vals,
int n)
Construct a matrix from a one-dimensional packed array |
|
SimpleMatrix(int n,
int k)
Construct an m-by-n matrix of zeros. |
|
SimpleMatrix(int n,
int k,
double s)
Construct an m-by-n constant matrix. |
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. |
SimpleMatrix |
copy()
Make a deep copy of a matrix |
double |
get(int n,
int k)
Get a single element. |
void |
getColumn(int k,
double[] d)
Copy a column of the matrix into argument d Legal range of the integer argument is 0 <= k < K . |
void |
getRow(int n,
double[] r)
Copy a row of the matrix Legal range of the integer argument is 0 <= n < N . |
void |
set(int n,
int k,
double s)
Set a single element. |
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[] d)
Copy an array (d) into a column of the matrix Legal range of the integer argument is 0 <= k < K . |
void |
setRow(int n,
double[] r)
Set a row of the matrix Legal range of the integer argument is 0 <= n < N . |
double |
sumAll()
Sum of all elements in matrix |
void |
timeseqScaleColumns(DiagonalMatrix D)
Scale the columns of this, A *= D which is A = A * D. |
void |
timeseqScaleRows(DiagonalMatrix D)
Scale the rows of this, A *= D which is A = D * A. |
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, getRowDimension, getSubMatrix, getSubMatrix, getSubMatrix, getSubMatrix, getValue, innerProduct, lu, lup, norm1, norm2, normF, normInf, pluseqOuterProduct, print, print, print, print, qr, rank, setValue, svd, times, times, times, times, trace, transposeTimes, transposeTimes, transposeTimes, transposeTimes |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleMatrix(int n, int k)
n
- Number of rows.k
- Number of colums.public SimpleMatrix(int n, int k, double s)
n
- Number of rows.k
- Number of colums.s
- Fill the matrix with this scalar value.public SimpleMatrix(double[][] A)
A
- Two-dimensional array of doubles.
java.lang.IllegalArgumentException
- All rows must have the same lengthpublic SimpleMatrix(double[] vals, int n)
vals
- One-dimensional array of doubles, packed by columns (ala Fortran).n
- Number of rows, i.e. length of columns.
java.lang.IllegalArgumentException
- Array length must be a multiple of m.public SimpleMatrix(AllMatrices B)
B
- a matrix of any kind, class is a subclass of AllMatricescopy()
Method Detail |
---|
public SimpleMatrix copy()
public java.lang.Object clone()
clone
in class java.lang.Object
public double get(int n, int k)
get
in class AllMatrices
n
- Row index.k
- Column index.
java.lang.ArrayIndexOutOfBoundsException
public void set(int n, int k, double s)
set
in class AllMatrices
n
- Row index.k
- Column index.s
- A(n,k).
java.lang.ArrayIndexOutOfBoundsException
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. A(:,k+1)
.
getColumn
in class AllMatrices
k
- number of the column in the matrixd
- the given column of the matrixpublic void setColumn(int k, double[] d)
0 <= k < K
.
If argument is out of range an IllegalArgumentException is thrown. A(:,k+1) = d
.
setColumn
in class AllMatrices
k
- number of the column in the matrixd
- the given column of the matrixpublic 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 AllMatrices
k
- number of the column the matrix A
.factor
- a factor to multiply the column vector by.x
- an array of length N
.public void getRow(int n, double[] r)
0 <= n < N
.
If argument is out of range a length K
array of zeros should be returned. r = A(n+1,:)
.
getRow
in class AllMatrices
n
- number of the row in the matrix A
.r
- the given row of matrix A
.public void setRow(int n, double[] r)
0 <= n < N
.
If argument is out of range an IllegalArgumentException is thrown. A(n+1,:) = r
.
setRow
in class AllMatrices
n
- number of the row in the matrix A
.r
- the given row of matrix A
.public void setAll(double[] vals)
setAll
in class AllMatrices
vals
- One-dimensional array of doubles, packed by columns (ala Fortran).public double sumAll()
sumAll
in class AllMatrices
public void timeseqScaleColumns(DiagonalMatrix D)
D
- Diagonal matrix of size K-by-K, class DiagonalMatrix
java.lang.IllegalArgumentException
public void timeseqScaleRows(DiagonalMatrix D)
D
- Diagonal matrix of size N-by-N, class DiagonalMatrix
java.lang.IllegalArgumentException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |