|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jmat.data.Matrix
The Matrix Class provides the fundamental operations of numerical linear algebra (from the package JAMA), basic manipulations, and visualization tools. All the operations in this version of the Matrix Class involve only real matrices.
Field Summary | |
protected double[][] |
A
Array for internal storage of elements. |
protected int |
m
Row and column dimensions. |
protected int |
n
Row and column dimensions. |
Constructor Summary | |
Matrix(double[][] B)
Construct a matrix from a 2D-array. |
|
Matrix(double[] vals,
int m)
Construct a matrix from a one-dimensional packed array |
|
Matrix(int m,
int n)
Construct an m-by-n matrix of zeros. |
|
Matrix(int m,
int n,
double s)
Construct an m-by-n constant matrix. |
Method Summary | |
Matrix |
abs()
Absolute value of each element |
void |
checkColumnDimension(int column)
Check if number of Columns(A) == column. |
void |
checkColumnDimension(Matrix B)
Check if number of Columns(A) == number of Columns(B). |
void |
checkDiagonal()
Check if A is Diagonal. |
void |
checkDimensions(int m2,
int n2)
Check if size(A) == m2*n2. |
void |
checkDimensions(Matrix B)
Check if size(A) == size(B). |
void |
checkRowDimension(int row)
Check if number of Rows(A) == row. |
void |
checkRowDimension(Matrix B)
Check if number of Rows(A) == number of Rows(B). |
void |
checkSymetric()
Check if A is Symetric. |
CholeskyDecomposition |
cholesky()
Cholesky Decomposition |
java.lang.Object |
clone()
Clone the Matrix object. |
double |
condition()
Matrix condition (2 norm) |
Matrix |
copy()
Copy the Matrix object. |
Matrix |
correlation()
Generate a correlation matrix, each column contains values of a pulling. |
Matrix |
covariance()
Generate a covariance matrix, each column contains values of a pulling. |
Matrix |
cumsum()
Generate a row matrix, each column contents the sum value of the columns. |
void |
deleteColumn(int J)
Delete a Column to Matrix. |
void |
deleteColumns(int[] J)
Delete a Column to Matrix. |
void |
deleteColumns(int j0,
int j1)
Delete a Column to Matrix. |
void |
deleteRow(int I)
delete a Row to Matrix. |
void |
deleteRows(int[] I)
delete a Row to Matrix. |
void |
deleteRows(int i0,
int i1)
delete a Row to Matrix. |
double |
determinant()
Matrix determinant |
static Matrix |
diagonal(double[] d)
Generate matrix with only diagonel elements |
Matrix |
distance(Matrix B,
double pow)
Generate a matrix, each column contents the N-distance between the columns. |
Matrix |
divide(double s)
Divide a matrix by a scalar, C = A/s |
Matrix |
divide(Matrix B)
Linear algebraic matrix division, A / B |
Matrix |
ebeCos()
Element-by-element cosinus |
Matrix |
ebeDivide(Matrix B)
Element-by-element right division, C = A. |
void |
ebeDivideEquals(Matrix B)
Element-by-element right division, C = A. |
Matrix |
ebeExp()
Element-by-element exponential |
Matrix |
ebeFunction(DoubleFunction fun)
Element-by-element function evaluation |
Matrix |
ebeIndicesFunction(DoubleFunction fun)
Element-by-element indicial function evaluation |
Matrix |
ebeInverse()
Element-by-element inverse |
Matrix |
ebeLog()
Element-by-element neperian logarithm |
Matrix |
ebePower(double p)
Element-by-element power |
Matrix |
ebePower(Matrix B)
Element-by-element power |
Matrix |
ebeSin()
Element-by-element sinus |
Matrix |
ebeSqrt()
Square root of each element |
Matrix |
ebeTimes(Matrix B)
Element-by-element multiplication, C = A. |
void |
ebeTimesEquals(Matrix B)
Element-by-element multiplication, C = A. |
EigenvalueDecomposition |
eig()
Eigenvalue Decomposition |
Matrix |
find(double min,
double max)
Find an element |
Matrix |
find(java.lang.String test,
double val)
Find an element |
static Matrix |
fromASCIIFile(java.io.File file)
Load the Matrix from a file |
static Matrix |
fromClipBoard()
Load the Matrix from the clipboard |
static Matrix |
fromString(java.lang.String s)
Load the Matrix from a String |
static Matrix |
fromXMLElement(org.jdom.Element e)
Load the Matrix from a MathML (XML) Element |
double |
get(int i,
int j)
Get a single element. |
double[][] |
getArrayCopy()
Copy the internal two-dimensional array. |
Matrix |
getColumn(int j)
Copy an internal one-dimensional array from a column. |
double[] |
getColumnArrayCopy(int j)
Copy an internal one-dimensional array from a column. |
int |
getColumnDimension()
Get column dimension. |
Matrix |
getColumns(int[] J)
Copy an internal one-dimensional array from a column. |
Matrix |
getColumns(int J0,
int J1)
Copy an internal one-dimensional array from a column. |
Matrix |
getDiagonal()
Matrix diagonal extraction. |
Matrix |
getDiagonal(int num)
Matrix diagonal extraction. |
Matrix |
getRow(int i)
Copy an internal one-dimensional array from a row. |
double[] |
getRowArrayCopy(int i)
Copy an internal one-dimensional array from a row. |
int |
getRowDimension()
Get row dimension. |
Matrix |
getRows(int[] I)
Copy an internal one-dimensional array from many rows. |
Matrix |
getRows(int I0,
int I1)
Copy an internal one-dimensional array from many rows. |
Matrix |
getSubMatrix(int i0,
int i1,
int j0,
int j1)
Get a submatrix. |
static Matrix |
identity(int m,
int n)
Generate identity matrix |
static Matrix |
incrementColumns(int m,
int n,
double begin,
double pitch)
Generate a matrix with a constant pitch beetwen each column |
static Matrix |
incrementRows(int m,
int n,
double begin,
double pitch)
Generate a matrix with a constant pitch beetwen each row |
void |
insertColumns(int J,
Matrix columns)
Insert a Column into Matrix. |
void |
insertRows(int I,
Matrix rows)
Insert a Row into Matrix. |
Matrix |
inverse()
Matrix inverse or pseudoinverse |
boolean |
isDiagonal()
Test if A is Diagonal. |
boolean |
isEqual(Matrix B)
Test if A == B. |
boolean |
isSymetric()
Test if A is Symetric. |
LUDecomposition |
lu()
LU Decomposition |
Matrix |
max()
Generate a row matrix, each column contents the maximum value of the columns. |
Matrix |
mean()
Generate a row matrix, each column contents the mean value of the columns. |
Matrix |
mergeColumns(Matrix B)
Matrix merge. |
static Matrix |
mergeColumns(Matrix[] Xs)
Generate a matrix from other matrix. |
Matrix |
mergeRows(Matrix B)
Matrix merge. |
static Matrix |
mergeRows(Matrix[] Xs)
Generate a matrix from other matrix. |
Matrix |
min()
Generate a row matrix, each column contents the minimum value of the columns. |
Matrix |
minus(double s)
Sub a scalar to each element of a matrix, C = A .- B |
Matrix |
minus(Matrix B)
C = A - B |
void |
minusEquals(double s)
Sub a scalar to each element of a matrix, C = A .- B |
void |
minusEquals(Matrix B)
C = A - B |
double |
norm1()
One norm |
double |
norm2()
Two norm |
double |
normFrobenius()
Frobenius norm |
double |
normInfinity()
Infinity norm |
Matrix |
plus(double s)
Add a scalar to each element of a matrix, C = A .+ s |
Matrix |
plus(Matrix B)
C = A + B |
void |
plusEquals(double s)
Add a scalar to each element of a matrix, C = A .+ s |
void |
plusEquals(Matrix B)
C = A + B |
Matrix |
product()
Generate a row matrix, each column contents the product value of the columns. |
QRDecomposition |
qr()
QR Decomposition |
static Matrix |
random(int m,
int n)
Generate matrix with random elements |
int |
rank()
Matrix rank |
Matrix |
reshapeColumns(int m2,
int n2)
Matrix reshape by Column. |
Matrix |
reshapeRows(int m2,
int n2)
Matrix reshape by Row. |
Matrix |
resize(int m2,
int n2)
Matrix resize. |
void |
set(int i,
int j,
double s)
Set a single element. |
void |
setColumn(int j,
double B)
Set a column to an internal one-dimensional Column. |
void |
setColumn(int j,
Matrix B)
Set a column to an internal one-dimensional Column. |
void |
setColumns(int[] J,
Matrix B)
Copy an internal one-dimensional array from a column. |
void |
setColumns(int j0,
Matrix B)
Set a column to an internal one-dimensional Column. |
void |
setRow(int i,
double B)
Copy an internal one-dimensional array from a row. |
void |
setRow(int i,
Matrix B)
Copy an internal one-dimensional array from a row. |
void |
setRows(int[] I,
Matrix B)
Copy an internal one-dimensional array from many rows. |
void |
setRows(int i0,
Matrix B)
Copy an internal one-dimensional array from a row. |
void |
setSubMatrix(int i0,
int i1,
int j0,
int j1,
double v)
Set a submatrix. |
void |
setSubMatrix(int i0,
int j0,
Matrix X)
Set a submatrix. |
Matrix |
slice(int n)
Slice the matrix |
Matrix |
slice(int[] N)
Slice the matrix |
Matrix |
solve(Matrix B)
Solve A*X = B |
Matrix |
sort(int j)
Generate a row-permuted matrix, rows are permuted in order to sort the column 'c' |
Matrix |
sum()
Generate a row matrix, each column contents the sum value of the columns. |
SingularValueDecomposition |
svd()
Singular Value Decomposition |
Matrix |
times(double s)
Multiply a matrix by a scalar, C = s*A |
Matrix |
times(Matrix B)
Linear algebraic matrix multiplication, A * B |
void |
timesEquals(double s)
Multiply a matrix by a scalar, C = s*A |
void |
toASCIIFile(java.io.File file)
Save the Matrix in a file. |
void |
toClipBoard()
Copy the Matrix into the clipboard |
void |
toCommandLine(java.lang.String title)
Print the Matrix in the Command Line. |
double |
toDouble()
convert the Matrix into a double value if the matrix is 1*1. |
double[] |
toDoubleArray()
convert the Matrix into a double value if the matrix is 1*1. |
void |
toPlot2DPanel(Plot2DPanel panel,
java.lang.String name,
java.lang.String type)
Print the Matrix in a JPanel. |
Plot2DPanel |
toPlot2DPanel(java.lang.String name,
java.lang.String type)
Print the Matrix in a JPanel. |
void |
toPlot3DPanel(Plot3DPanel panel,
java.lang.String name,
java.lang.String type)
Print the Matrix in a JPanel. |
Plot3DPanel |
toPlot3DPanel(java.lang.String name,
java.lang.String type)
Print the Matrix in a JPanel. |
java.lang.String |
toString()
Convert the Matrix into a String |
MatrixTablePanel |
toTablePanel()
Print the Matrix in a JPanel. |
org.jdom.Element |
toXMLElement()
Convert the Matrix into a MathML (XML) Element |
double |
trace()
Matrix trace. |
Matrix |
transpose()
Matrix transpose. |
void |
transposeEquals()
Matrix transpose. |
Matrix |
uminus()
Unary minus |
void |
uminusEquals()
Unary minus |
Matrix |
variance()
Generate a variance matrix, each column contains values of a pulling. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected double[][] A
protected int m
protected int n
Constructor Detail |
public Matrix(int m, int n)
m
- Number of rows.n
- Number of colums.public Matrix(int m, int n, double s)
m
- Number of rows.n
- Number of colums.s
- Fill the matrix with this scalar value.public Matrix(double[][] B)
B
- Two-dimensional array of doubles.
java.lang.IllegalArgumentException
- All rows must have the same length#constructWithCopy
public Matrix(double[] vals, int m)
vals
- One-dimensional array of doubles, packed by columns (ala Fortran).m
- Number of rows.
java.lang.IllegalArgumentException
- Array length must be a multiple of m.Method Detail |
public static Matrix random(int m, int n)
m
- Number of rows.n
- Number of colums.
public static Matrix diagonal(double[] d)
d
- Diagonal.
public static Matrix identity(int m, int n)
m
- Number of rows.n
- Number of colums.
public static Matrix incrementRows(int m, int n, double begin, double pitch)
m
- Number of rows.n
- Number of colums.begin
- begining value to increment.pitch
- pitch to add.
public static Matrix incrementColumns(int m, int n, double begin, double pitch)
m
- Number of rows.n
- Number of colums.begin
- begining value to increment.pitch
- pitch to add.
public static Matrix mergeRows(Matrix[] Xs)
Xs
- Matrix to merge.
public static Matrix mergeColumns(Matrix[] Xs)
Xs
- Matrix to merge.
public java.lang.Object clone()
clone
in class java.lang.Object
public Matrix copy()
public double[][] getArrayCopy()
public double[] getRowArrayCopy(int i)
i
- Row index
public double[] getColumnArrayCopy(int j)
j
- Column index
public double get(int i, int j)
i
- Row index.j
- Column index.
java.lang.ArrayIndexOutOfBoundsException
public Matrix getSubMatrix(int i0, int i1, int j0, int j1)
i0
- Initial row indexi1
- Final row indexj0
- Initial column indexj1
- Final column index
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic Matrix getRow(int i)
i
- Row index
public Matrix getRows(int[] I)
I
- Rows indexes
public Matrix getRows(int I0, int I1)
I0
- First Rows indexI1
- Last Rows index
public Matrix getColumn(int j)
j
- Column index
public Matrix getColumns(int[] J)
J
- Columns indexes
public Matrix getColumns(int J0, int J1)
J0
- First Columns indexJ1
- Last Columns index
public int getRowDimension()
public int getColumnDimension()
public Matrix getDiagonal()
public Matrix getDiagonal(int num)
num
- diagonal number.
public void set(int i, int j, double s)
i
- Row index.j
- Column index.s
- A(i,j).
java.lang.ArrayIndexOutOfBoundsException
public void setSubMatrix(int i0, int j0, Matrix X)
i0
- Initial row indexj0
- Initial column indexX
- subMatrix to set
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setSubMatrix(int i0, int i1, int j0, int j1, double v)
i0
- Initial row indexi1
- Final row indexj0
- Initial column indexj1
- Final column indexv
- Value to set in the submatrix
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setRow(int i, Matrix B)
i
- Row indexB
- Row-matrixpublic void setRow(int i, double B)
i
- Row indexB
- Row-matrixpublic void setRows(int[] I, Matrix B)
I
- Rows indexesB
- Rows-matrixpublic void setRows(int i0, Matrix B)
i0
- First Row indexB
- Row-matrixpublic void setColumn(int j, Matrix B)
j
- Column indexB
- Column-matrixpublic void setColumn(int j, double B)
j
- Column indexB
- Column-matrixpublic void setColumns(int[] J, Matrix B)
J
- Columns indexesB
- Columns-matrixpublic void setColumns(int j0, Matrix B)
j0
- First Column indexB
- Column-matrixpublic void insertRows(int I, Matrix rows)
I
- first row to add indexrows
- rows to addpublic void insertColumns(int J, Matrix columns)
J
- first column to add indexcolumns
- column to addpublic void deleteRow(int I)
I
- row number to deletepublic void deleteRows(int[] I)
I
- row number to deletepublic void deleteRows(int i0, int i1)
i0
- first row index to deletei1
- last row index to deletepublic void deleteColumn(int J)
J
- column number to deletepublic void deleteColumns(int[] J)
J
- column numbers to deletepublic void deleteColumns(int j0, int j1)
j0
- first column index to deletej1
- last column index to deletepublic Matrix resize(int m2, int n2)
m2
- number of rowsn2
- number of columns
public Matrix reshapeRows(int m2, int n2)
m2
- number of rowsn2
- number of columns
public Matrix reshapeColumns(int m2, int n2)
m2
- number of rowsn2
- number of columns
public Matrix mergeRows(Matrix B)
B
- matrix to merge
public Matrix mergeColumns(Matrix B)
B
- matrix to merge
public double norm1()
public double norm2()
public double normInfinity()
public double normFrobenius()
public double determinant()
public int rank()
public double condition()
public double trace()
public Matrix min()
public Matrix max()
public Matrix sum()
public Matrix cumsum()
public Matrix product()
public Matrix distance(Matrix B, double pow)
pow
- NB
- Matrix
public Matrix mean()
public Matrix covariance()
public Matrix correlation()
public Matrix variance()
public Matrix transpose()
public void transposeEquals()
public Matrix uminus()
public void uminusEquals()
public Matrix plus(Matrix B)
B
- another matrix
public void plusEquals(Matrix B)
B
- another matrixpublic Matrix minus(Matrix B)
B
- another matrix
public void minusEquals(Matrix B)
B
- another matrixpublic Matrix times(Matrix B)
B
- another matrix
java.lang.IllegalArgumentException
- Matrix inner dimensions must agree.public Matrix divide(double s)
s
- scalar
public Matrix divide(Matrix B)
B
- another matrix
public Matrix solve(Matrix B)
B
- right hand side
public Matrix inverse()
public Matrix plus(double s)
s
- double
public void plusEquals(double s)
s
- doublepublic Matrix minus(double s)
s
- double
public void minusEquals(double s)
s
- doublepublic Matrix times(double s)
s
- scalar
public void timesEquals(double s)
s
- scalarpublic Matrix ebeTimes(Matrix B)
B
- another matrix
public void ebeTimesEquals(Matrix B)
B
- another matrixpublic Matrix ebeDivide(Matrix B)
B
- another matrix
public void ebeDivideEquals(Matrix B)
B
- another matrixpublic Matrix ebeCos()
public Matrix ebeSin()
public Matrix ebeExp()
public Matrix ebePower(double p)
p
- double
public Matrix ebePower(Matrix B)
B
- another matrix
public Matrix ebeLog()
public Matrix ebeInverse()
public Matrix ebeSqrt()
public Matrix abs()
public Matrix ebeFunction(DoubleFunction fun)
fun
- function to apply : f(Aij)
public Matrix ebeIndicesFunction(DoubleFunction fun)
fun
- function to apply : f(Aij,i,j)
public LUDecomposition lu()
LUDecomposition
public QRDecomposition qr()
QRDecomposition
public CholeskyDecomposition cholesky()
CholeskyDecomposition
public SingularValueDecomposition svd()
SingularValueDecomposition
public EigenvalueDecomposition eig()
EigenvalueDecomposition
public Matrix sort(int j)
j
- Number of the colum which leads the permuation
public Matrix find(double min, double max)
min
- Inf bound of values to findmax
- Sup bound of values to find
public Matrix find(java.lang.String test, double val)
test
- Testval
- Element (value) to compare
public Matrix slice(int[] N)
N
- Array of number of slices for each column.
public Matrix slice(int n)
n
- Number of slices for each column.
public double toDouble()
public double[] toDoubleArray()
public java.lang.String toString()
toString
in interface StringPrintable
toString
in class java.lang.Object
public void toClipBoard()
toClipBoard
in interface ClipBoardPrintable
public org.jdom.Element toXMLElement()
toXMLElement
in interface XMLPrintable
public void toASCIIFile(java.io.File file)
toASCIIFile
in interface FilePrintable
file
- file to save in.public void toCommandLine(java.lang.String title)
toCommandLine
in interface CommandLinePrintable
title
- title to display in the command line.public MatrixTablePanel toTablePanel()
public Plot2DPanel toPlot2DPanel(java.lang.String name, java.lang.String type)
name
- name of the plot.type
- type of displaying.
public Plot3DPanel toPlot3DPanel(java.lang.String name, java.lang.String type)
type
- type of displaying.name
- name of the plot.
public void toPlot2DPanel(Plot2DPanel panel, java.lang.String name, java.lang.String type)
panel
- Panel to modify.name
- name of the plot.type
- type of displaying.public void toPlot3DPanel(Plot3DPanel panel, java.lang.String name, java.lang.String type)
panel
- Panel to modify.name
- name of the plot.type
- type of displaying.public static Matrix fromASCIIFile(java.io.File file)
file
- file to load
public static Matrix fromString(java.lang.String s)
s
- String to load
public static Matrix fromClipBoard() throws java.io.IOException, java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException
java.awt.datatransfer.UnsupportedFlavorException
public static Matrix fromXMLElement(org.jdom.Element e)
e
- Element public boolean isEqual(Matrix B)
B
- Matrix to compare.
public boolean isDiagonal()
public boolean isSymetric()
public void checkDiagonal()
public void checkSymetric()
public void checkDimensions(Matrix B)
B
- Matrix to test.public void checkDimensions(int m2, int n2)
m2
- Number of rows.n2
- Number of columns.public void checkRowDimension(Matrix B)
B
- Matrix to test.public void checkRowDimension(int row)
row
- number of rows.public void checkColumnDimension(Matrix B)
B
- Matrix to test.public void checkColumnDimension(int column)
column
- number of columns.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |