org.jmat.data
Class Matrix

java.lang.Object
  |
  +--org.jmat.data.Matrix
All Implemented Interfaces:
ClipBoardPrintable, java.lang.Cloneable, CommandLinePrintable, FilePrintable, java.io.Serializable, StringPrintable, XMLPrintable
Direct Known Subclasses:
RandomMatrix

public class Matrix
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, CommandLinePrintable, StringPrintable, XMLPrintable, FilePrintable, ClipBoardPrintable

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.

See Also:
Serialized Form

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

A

protected double[][] A
Array for internal storage of elements.


m

protected int m
Row and column dimensions.


n

protected int n
Row and column dimensions.

Constructor Detail

Matrix

public Matrix(int m,
              int n)
Construct an m-by-n matrix of zeros.

Parameters:
m - Number of rows.
n - Number of colums.

Matrix

public Matrix(int m,
              int n,
              double s)
Construct an m-by-n constant matrix.

Parameters:
m - Number of rows.
n - Number of colums.
s - Fill the matrix with this scalar value.

Matrix

public Matrix(double[][] B)
Construct a matrix from a 2D-array.

Parameters:
B - Two-dimensional array of doubles.
Throws:
java.lang.IllegalArgumentException - All rows must have the same length
See Also:
#constructWithCopy

Matrix

public Matrix(double[] vals,
              int m)
Construct a matrix from a one-dimensional packed array

Parameters:
vals - One-dimensional array of doubles, packed by columns (ala Fortran).
m - Number of rows.
Throws:
java.lang.IllegalArgumentException - Array length must be a multiple of m.
Method Detail

random

public static Matrix random(int m,
                            int n)
Generate matrix with random elements

Parameters:
m - Number of rows.
n - Number of colums.
Returns:
An m-by-n matrix with uniformly distributed random elements.

diagonal

public static Matrix diagonal(double[] d)
Generate matrix with only diagonel elements

Parameters:
d - Diagonal.
Returns:
An m-by-n matrix.

identity

public static Matrix identity(int m,
                              int n)
Generate identity matrix

Parameters:
m - Number of rows.
n - Number of colums.
Returns:
An m-by-n matrix with ones on the diagonal and zeros elsewhere.

incrementRows

public static Matrix incrementRows(int m,
                                   int n,
                                   double begin,
                                   double pitch)
Generate a matrix with a constant pitch beetwen each row

Parameters:
m - Number of rows.
n - Number of colums.
begin - begining value to increment.
pitch - pitch to add.
Returns:
An m-by-n matrix.

incrementColumns

public static Matrix incrementColumns(int m,
                                      int n,
                                      double begin,
                                      double pitch)
Generate a matrix with a constant pitch beetwen each column

Parameters:
m - Number of rows.
n - Number of colums.
begin - begining value to increment.
pitch - pitch to add.
Returns:
An m-by-n matrix.

mergeRows

public static Matrix mergeRows(Matrix[] Xs)
Generate a matrix from other matrix.

Parameters:
Xs - Matrix to merge.
Returns:
An m1+m2+...-by-n matrix.

mergeColumns

public static Matrix mergeColumns(Matrix[] Xs)
Generate a matrix from other matrix.

Parameters:
Xs - Matrix to merge.
Returns:
An m-by-n1+n2+... matrix.

clone

public java.lang.Object clone()
Clone the Matrix object.

Overrides:
clone in class java.lang.Object
Returns:
A matrix Object.

copy

public Matrix copy()
Copy the Matrix object.

Returns:
A matrix.

getArrayCopy

public double[][] getArrayCopy()
Copy the internal two-dimensional array.

Returns:
Two-dimensional array copy of matrix elements.

getRowArrayCopy

public double[] getRowArrayCopy(int i)
Copy an internal one-dimensional array from a row.

Parameters:
i - Row index
Returns:
one-dimensional array copy of matrix elements.

getColumnArrayCopy

public double[] getColumnArrayCopy(int j)
Copy an internal one-dimensional array from a column.

Parameters:
j - Column index
Returns:
one-dimensional array copy of matrix elements.

get

public double get(int i,
                  int j)
Get a single element.

Parameters:
i - Row index.
j - Column index.
Returns:
A(i,j)
Throws:
java.lang.ArrayIndexOutOfBoundsException

getSubMatrix

public Matrix getSubMatrix(int i0,
                           int i1,
                           int j0,
                           int j1)
Get a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
j0 - Initial column index
j1 - Final column index
Returns:
A(i0:i1,j0:j1)
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices

getRow

public Matrix getRow(int i)
Copy an internal one-dimensional array from a row.

Parameters:
i - Row index
Returns:
one-dimensional array copy of matrix elements.

getRows

public Matrix getRows(int[] I)
Copy an internal one-dimensional array from many rows.

Parameters:
I - Rows indexes
Returns:
one-dimensional array copy of matrix elements.

getRows

public Matrix getRows(int I0,
                      int I1)
Copy an internal one-dimensional array from many rows.

Parameters:
I0 - First Rows index
I1 - Last Rows index
Returns:
one-dimensional array copy of matrix elements.

getColumn

public Matrix getColumn(int j)
Copy an internal one-dimensional array from a column.

Parameters:
j - Column index
Returns:
one-dimensional array copy of matrix elements.

getColumns

public Matrix getColumns(int[] J)
Copy an internal one-dimensional array from a column.

Parameters:
J - Columns indexes
Returns:
one-dimensional array copy of matrix elements.

getColumns

public Matrix getColumns(int J0,
                         int J1)
Copy an internal one-dimensional array from a column.

Parameters:
J0 - First Columns index
J1 - Last Columns index
Returns:
one-dimensional array copy of matrix elements.

getRowDimension

public int getRowDimension()
Get row dimension.

Returns:
m, the number of rows.

getColumnDimension

public int getColumnDimension()
Get column dimension.

Returns:
n, the number of columns.

getDiagonal

public Matrix getDiagonal()
Matrix diagonal extraction.

Returns:
An d*1 Matrix of diagonal elements, d = min(m,n).

getDiagonal

public Matrix getDiagonal(int num)
Matrix diagonal extraction.

Parameters:
num - diagonal number.
Returns:
Matrix of the n-th diagonal elements.

set

public void set(int i,
                int j,
                double s)
Set a single element.

Parameters:
i - Row index.
j - Column index.
s - A(i,j).
Throws:
java.lang.ArrayIndexOutOfBoundsException

setSubMatrix

public void setSubMatrix(int i0,
                         int j0,
                         Matrix X)
Set a submatrix.

Parameters:
i0 - Initial row index
j0 - Initial column index
X - subMatrix to set
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices

setSubMatrix

public void setSubMatrix(int i0,
                         int i1,
                         int j0,
                         int j1,
                         double v)
Set a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
j0 - Initial column index
j1 - Final column index
v - Value to set in the submatrix
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices

setRow

public void setRow(int i,
                   Matrix B)
Copy an internal one-dimensional array from a row.

Parameters:
i - Row index
B - Row-matrix

setRow

public void setRow(int i,
                   double B)
Copy an internal one-dimensional array from a row.

Parameters:
i - Row index
B - Row-matrix

setRows

public void setRows(int[] I,
                    Matrix B)
Copy an internal one-dimensional array from many rows.

Parameters:
I - Rows indexes
B - Rows-matrix

setRows

public void setRows(int i0,
                    Matrix B)
Copy an internal one-dimensional array from a row.

Parameters:
i0 - First Row index
B - Row-matrix

setColumn

public void setColumn(int j,
                      Matrix B)
Set a column to an internal one-dimensional Column.

Parameters:
j - Column index
B - Column-matrix

setColumn

public void setColumn(int j,
                      double B)
Set a column to an internal one-dimensional Column.

Parameters:
j - Column index
B - Column-matrix

setColumns

public void setColumns(int[] J,
                       Matrix B)
Copy an internal one-dimensional array from a column.

Parameters:
J - Columns indexes
B - Columns-matrix

setColumns

public void setColumns(int j0,
                       Matrix B)
Set a column to an internal one-dimensional Column.

Parameters:
j0 - First Column index
B - Column-matrix

insertRows

public void insertRows(int I,
                       Matrix rows)
Insert a Row into Matrix.

Parameters:
I - first row to add index
rows - rows to add

insertColumns

public void insertColumns(int J,
                          Matrix columns)
Insert a Column into Matrix.

Parameters:
J - first column to add index
columns - column to add

deleteRow

public void deleteRow(int I)
delete a Row to Matrix.

Parameters:
I - row number to delete

deleteRows

public void deleteRows(int[] I)
delete a Row to Matrix.

Parameters:
I - row number to delete

deleteRows

public void deleteRows(int i0,
                       int i1)
delete a Row to Matrix.

Parameters:
i0 - first row index to delete
i1 - last row index to delete

deleteColumn

public void deleteColumn(int J)
Delete a Column to Matrix.

Parameters:
J - column number to delete

deleteColumns

public void deleteColumns(int[] J)
Delete a Column to Matrix.

Parameters:
J - column numbers to delete

deleteColumns

public void deleteColumns(int j0,
                          int j1)
Delete a Column to Matrix.

Parameters:
j0 - first column index to delete
j1 - last column index to delete

resize

public Matrix resize(int m2,
                     int n2)
Matrix resize.

Parameters:
m2 - number of rows
n2 - number of columns
Returns:
resized matrix

reshapeRows

public Matrix reshapeRows(int m2,
                          int n2)
Matrix reshape by Row.

Parameters:
m2 - number of rows
n2 - number of columns
Returns:
reshaped matrix

reshapeColumns

public Matrix reshapeColumns(int m2,
                             int n2)
Matrix reshape by Column.

Parameters:
m2 - number of rows
n2 - number of columns
Returns:
reshaped matrix

mergeRows

public Matrix mergeRows(Matrix B)
Matrix merge.

Parameters:
B - matrix to merge
Returns:
An m.B+m-by-n matrix

mergeColumns

public Matrix mergeColumns(Matrix B)
Matrix merge.

Parameters:
B - matrix to merge
Returns:
An m-by-n+B.n matrix

norm1

public double norm1()
One norm

Returns:
maximum column sum.

norm2

public double norm2()
Two norm

Returns:
maximum singular value.

normInfinity

public double normInfinity()
Infinity norm

Returns:
maximum row sum.

normFrobenius

public double normFrobenius()
Frobenius norm

Returns:
sqrt of sum of squares of all elements.

determinant

public double determinant()
Matrix determinant

Returns:
determinant

rank

public int rank()
Matrix rank

Returns:
effective numerical rank, obtained from SVD.

condition

public double condition()
Matrix condition (2 norm)

Returns:
ratio of largest to smallest singular value.

trace

public double trace()
Matrix trace.

Returns:
sum of the diagonal elements.

min

public Matrix min()
Generate a row matrix, each column contents the minimum value of the columns.

Returns:
An 1-by-n matrix.

max

public Matrix max()
Generate a row matrix, each column contents the maximum value of the columns.

Returns:
An 1-by-n matrix.

sum

public Matrix sum()
Generate a row matrix, each column contents the sum value of the columns.

Returns:
An 1-by-n matrix.

cumsum

public Matrix cumsum()
Generate a row matrix, each column contents the sum value of the columns.

Returns:
An 1-by-n matrix.

product

public Matrix product()
Generate a row matrix, each column contents the product value of the columns.

Returns:
An 1-by-n matrix.

distance

public Matrix distance(Matrix B,
                       double pow)
Generate a matrix, each column contents the N-distance between the columns.

Parameters:
pow - N
B - Matrix
Returns:
An m-by-B.m matrix.

mean

public Matrix mean()
Generate a row matrix, each column contents the mean value of the columns.

Returns:
An 1-by-n matrix.

covariance

public Matrix covariance()
Generate a covariance matrix, each column contains values of a pulling.

Returns:
An n-by-n matrix.

correlation

public Matrix correlation()
Generate a correlation matrix, each column contains values of a pulling.

Returns:
An n-by-n matrix.

variance

public Matrix variance()
Generate a variance matrix, each column contains values of a pulling.

Returns:
An 1-by-n matrix.

transpose

public Matrix transpose()
Matrix transpose.

Returns:
A'

transposeEquals

public void transposeEquals()
Matrix transpose.


uminus

public Matrix uminus()
Unary minus

Returns:
-A

uminusEquals

public void uminusEquals()
Unary minus


plus

public Matrix plus(Matrix B)
C = A + B

Parameters:
B - another matrix
Returns:
A + B

plusEquals

public void plusEquals(Matrix B)
C = A + B

Parameters:
B - another matrix

minus

public Matrix minus(Matrix B)
C = A - B

Parameters:
B - another matrix
Returns:
A - B

minusEquals

public void minusEquals(Matrix B)
C = A - B

Parameters:
B - another matrix

times

public Matrix times(Matrix B)
Linear algebraic matrix multiplication, A * B

Parameters:
B - another matrix
Returns:
Matrix product, A * B
Throws:
java.lang.IllegalArgumentException - Matrix inner dimensions must agree.

divide

public Matrix divide(double s)
Divide a matrix by a scalar, C = A/s

Parameters:
s - scalar
Returns:
A/s

divide

public Matrix divide(Matrix B)
Linear algebraic matrix division, A / B

Parameters:
B - another matrix
Returns:
Matrix division, A / B

solve

public Matrix solve(Matrix B)
Solve A*X = B

Parameters:
B - right hand side
Returns:
solution if A is square, least squares solution otherwise

inverse

public Matrix inverse()
Matrix inverse or pseudoinverse

Returns:
inverse(A) if A is square, pseudoinverse otherwise.

plus

public Matrix plus(double s)
Add a scalar to each element of a matrix, C = A .+ s

Parameters:
s - double
Returns:
A .+ s

plusEquals

public void plusEquals(double s)
Add a scalar to each element of a matrix, C = A .+ s

Parameters:
s - double

minus

public Matrix minus(double s)
Sub a scalar to each element of a matrix, C = A .- B

Parameters:
s - double
Returns:
A .- s

minusEquals

public void minusEquals(double s)
Sub a scalar to each element of a matrix, C = A .- B

Parameters:
s - double

times

public Matrix times(double s)
Multiply a matrix by a scalar, C = s*A

Parameters:
s - scalar
Returns:
s*A

timesEquals

public void timesEquals(double s)
Multiply a matrix by a scalar, C = s*A

Parameters:
s - scalar

ebeTimes

public Matrix ebeTimes(Matrix B)
Element-by-element multiplication, C = A.*B

Parameters:
B - another matrix
Returns:
A.*B

ebeTimesEquals

public void ebeTimesEquals(Matrix B)
Element-by-element multiplication, C = A.*B

Parameters:
B - another matrix

ebeDivide

public Matrix ebeDivide(Matrix B)
Element-by-element right division, C = A./B

Parameters:
B - another matrix
Returns:
A./B

ebeDivideEquals

public void ebeDivideEquals(Matrix B)
Element-by-element right division, C = A./B

Parameters:
B - another matrix

ebeCos

public Matrix ebeCos()
Element-by-element cosinus

Returns:
cos.(A)

ebeSin

public Matrix ebeSin()
Element-by-element sinus

Returns:
sin.(A)

ebeExp

public Matrix ebeExp()
Element-by-element exponential

Returns:
exp.(A)

ebePower

public Matrix ebePower(double p)
Element-by-element power

Parameters:
p - double
Returns:
A.^p

ebePower

public Matrix ebePower(Matrix B)
Element-by-element power

Parameters:
B - another matrix
Returns:
A.^B

ebeLog

public Matrix ebeLog()
Element-by-element neperian logarithm

Returns:
log.(A)

ebeInverse

public Matrix ebeInverse()
Element-by-element inverse

Returns:
A.^-1

ebeSqrt

public Matrix ebeSqrt()
Square root of each element

Returns:
sqrt.(A)

abs

public Matrix abs()
Absolute value of each element

Returns:
|A|

ebeFunction

public Matrix ebeFunction(DoubleFunction fun)
Element-by-element function evaluation

Parameters:
fun - function to apply : f(Aij)
Returns:
f.(A)

ebeIndicesFunction

public Matrix ebeIndicesFunction(DoubleFunction fun)
Element-by-element indicial function evaluation

Parameters:
fun - function to apply : f(Aij,i,j)
Returns:
f.(A)

lu

public LUDecomposition lu()
LU Decomposition

Returns:
LUDecomposition
See Also:
LUDecomposition

qr

public QRDecomposition qr()
QR Decomposition

Returns:
QRDecomposition
See Also:
QRDecomposition

cholesky

public CholeskyDecomposition cholesky()
Cholesky Decomposition

Returns:
CholeskyDecomposition
See Also:
CholeskyDecomposition

svd

public SingularValueDecomposition svd()
Singular Value Decomposition

Returns:
SingularValueDecomposition
See Also:
SingularValueDecomposition

eig

public EigenvalueDecomposition eig()
Eigenvalue Decomposition

Returns:
EigenvalueDecomposition
See Also:
EigenvalueDecomposition

sort

public Matrix sort(int j)
Generate a row-permuted matrix, rows are permuted in order to sort the column 'c'

Parameters:
j - Number of the colum which leads the permuation
Returns:
A Sort.

find

public Matrix find(double min,
                   double max)
Find an element

Parameters:
min - Inf bound of values to find
max - Sup bound of values to find
Returns:
A Find.

find

public Matrix find(java.lang.String test,
                   double val)
Find an element

Parameters:
test - Test
val - Element (value) to compare
Returns:
A Find.

slice

public Matrix slice(int[] N)
Slice the matrix

Parameters:
N - Array of number of slices for each column.
Returns:
A Slice.

slice

public Matrix slice(int n)
Slice the matrix

Parameters:
n - Number of slices for each column.
Returns:
A Slice.

toDouble

public double toDouble()
convert the Matrix into a double value if the matrix is 1*1.

Returns:
A(0,0).

toDoubleArray

public double[] toDoubleArray()
convert the Matrix into a double value if the matrix is 1*1.

Returns:
A(0,0).

toString

public java.lang.String toString()
Convert the Matrix into a String

Specified by:
toString in interface StringPrintable
Overrides:
toString in class java.lang.Object
Returns:
A String

toClipBoard

public void toClipBoard()
Copy the Matrix into the clipboard

Specified by:
toClipBoard in interface ClipBoardPrintable

toXMLElement

public org.jdom.Element toXMLElement()
Convert the Matrix into a MathML (XML) Element

Specified by:
toXMLElement in interface XMLPrintable
Returns:
An XML Element

toASCIIFile

public void toASCIIFile(java.io.File file)
Save the Matrix in a file.

Specified by:
toASCIIFile in interface FilePrintable
Parameters:
file - file to save in.

toCommandLine

public void toCommandLine(java.lang.String title)
Print the Matrix in the Command Line.

Specified by:
toCommandLine in interface CommandLinePrintable
Parameters:
title - title to display in the command line.

toTablePanel

public MatrixTablePanel toTablePanel()
Print the Matrix in a JPanel.

Returns:
A JPanel.

toPlot2DPanel

public Plot2DPanel toPlot2DPanel(java.lang.String name,
                                 java.lang.String type)
Print the Matrix in a JPanel.

Parameters:
name - name of the plot.
type - type of displaying.
Returns:
A JPanel.

toPlot3DPanel

public Plot3DPanel toPlot3DPanel(java.lang.String name,
                                 java.lang.String type)
Print the Matrix in a JPanel.

Parameters:
type - type of displaying.
name - name of the plot.
Returns:
A JPanel.

toPlot2DPanel

public void toPlot2DPanel(Plot2DPanel panel,
                          java.lang.String name,
                          java.lang.String type)
Print the Matrix in a JPanel.

Parameters:
panel - Panel to modify.
name - name of the plot.
type - type of displaying.

toPlot3DPanel

public void toPlot3DPanel(Plot3DPanel panel,
                          java.lang.String name,
                          java.lang.String type)
Print the Matrix in a JPanel.

Parameters:
panel - Panel to modify.
name - name of the plot.
type - type of displaying.

fromASCIIFile

public static Matrix fromASCIIFile(java.io.File file)
Load the Matrix from a file

Parameters:
file - file to load
Returns:
A matrix

fromString

public static Matrix fromString(java.lang.String s)
Load the Matrix from a String

Parameters:
s - String to load
Returns:
A matrix

fromClipBoard

public static Matrix fromClipBoard()
                            throws java.io.IOException,
                                   java.awt.datatransfer.UnsupportedFlavorException
Load the Matrix from the clipboard

Returns:
A matrix
Throws:
java.io.IOException
java.awt.datatransfer.UnsupportedFlavorException

fromXMLElement

public static Matrix fromXMLElement(org.jdom.Element e)
Load the Matrix from a MathML (XML) Element

Parameters:
e - Element to load
Returns:
A matrix

isEqual

public boolean isEqual(Matrix B)
Test if A == B.

Parameters:
B - Matrix to compare.
Returns:
boolean

isDiagonal

public boolean isDiagonal()
Test if A is Diagonal.

Returns:
boolean

isSymetric

public boolean isSymetric()
Test if A is Symetric.

Returns:
boolean

checkDiagonal

public void checkDiagonal()
Check if A is Diagonal.


checkSymetric

public void checkSymetric()
Check if A is Symetric.


checkDimensions

public void checkDimensions(Matrix B)
Check if size(A) == size(B).

Parameters:
B - Matrix to test.

checkDimensions

public void checkDimensions(int m2,
                            int n2)
Check if size(A) == m2*n2.

Parameters:
m2 - Number of rows.
n2 - Number of columns.

checkRowDimension

public void checkRowDimension(Matrix B)
Check if number of Rows(A) == number of Rows(B).

Parameters:
B - Matrix to test.

checkRowDimension

public void checkRowDimension(int row)
Check if number of Rows(A) == row.

Parameters:
row - number of rows.

checkColumnDimension

public void checkColumnDimension(Matrix B)
Check if number of Columns(A) == number of Columns(B).

Parameters:
B - Matrix to test.

checkColumnDimension

public void checkColumnDimension(int column)
Check if number of Columns(A) == column.

Parameters:
column - number of columns.