Package javajs.util
Class Matrix
java.lang.Object
javajs.util.Matrix
- All Implemented Interfaces:
Cloneable
streamlined and refined for Jmol by Bob Hanson
from http://math.nist.gov/javanumerics/jama/
Jama = Java Matrix class.
- Version:
- 5 August 1998
- Author:
- The MathWorks, Inc. and the National Institute of Standards and Technology.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMatrix
(double[][] a, int m, int n) Construct a matrix quickly without checking arguments. -
Method Summary
Modifier and TypeMethodDescriptionadd two matricesclone()
Clone the Matrix object.copy()
Make a deep copy of a matrixdouble[][]
getArray()
Access the internal two-dimensional array.double[][]
Copy the internal two-dimensional array.int
Get column dimension.getMatrixSelected
(int[] r, int n) Get a submatrix for a give number of columns and selected row set.similarly to M3/M4 standard rotation/translation matrix we set a rotationTranslation matrix to be: [ nxn rot nx1 trans 1xn 0 1x1 1 ]int
Get row dimension.getSubmatrix
(int i0, int j0, int nrows, int ncols) Get a submatrix.static Matrix
identity
(int m, int n) Generate identity matrixinverse()
Matrix inverse or pseudoinverseLinear algebraic matrix multiplication, A * Bstatic Matrix
X = A + B*scalesubtract two matricestoString()
double
trace()
Matrix trace.Matrix transpose.
-
Field Details
-
a
public double[][] a -
m
protected int m -
n
protected int n
-
-
Constructor Details
-
Matrix
public Matrix(double[][] a, int m, int n) Construct a matrix quickly without checking arguments.- Parameters:
a
- Two-dimensional array of doubles or nullm
- Number of rows.n
- Number of colums.
-
-
Method Details
-
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.
-
getArray
public double[][] getArray()Access the internal two-dimensional array.- Returns:
- Pointer to the two-dimensional array of matrix elements.
-
getArrayCopy
public double[][] getArrayCopy()Copy the internal two-dimensional array.- Returns:
- Two-dimensional array copy of matrix elements.
-
copy
Make a deep copy of a matrix- Returns:
- copy
-
clone
Clone the Matrix object. -
getSubmatrix
Get a submatrix.- Parameters:
i0
- Initial row indexj0
- Initial column indexnrows
- Number of rowsncols
- Number of columns- Returns:
- submatrix
-
getMatrixSelected
Get a submatrix for a give number of columns and selected row set.- Parameters:
r
- Array of row indices.n
- number of rows- Returns:
- submatrix
-
transpose
Matrix transpose.- Returns:
- A'
-
add
add two matrices- Parameters:
b
-- Returns:
- new Matrix this + b
-
sub
subtract two matrices- Parameters:
b
-- Returns:
- new Matrix this - b
-
scaleAdd
X = A + B*scale- Parameters:
b
-scale
-- Returns:
- X
-
mul
Linear algebraic matrix multiplication, A * B- Parameters:
b
- another matrix- Returns:
- Matrix product, A * B or null for wrong dimension
-
inverse
Matrix inverse or pseudoinverse- Returns:
- inverse (m == n) or pseudoinverse (m != n)
-
trace
public double trace()Matrix trace.- Returns:
- sum of the diagonal elements.
-
identity
Generate identity matrix- Parameters:
m
- Number of rows.n
- Number of columns.- Returns:
- An m-by-n matrix with ones on the diagonal and zeros elsewhere.
-
getRotation
similarly to M3/M4 standard rotation/translation matrix we set a rotationTranslation matrix to be: [ nxn rot nx1 trans 1xn 0 1x1 1 ]- Returns:
- rotation matrix
-
getTranslation
-
newT
-
toString
-