public final class Matrix3D<Q extends Quantity> extends Matrix<Parameter<Q>> implements javolution.lang.Realtime, javolution.lang.ValueType, javolution.xml.XMLSerializable
This class represents a 3x3 matrix
implementation for
parameter
elements.
Instances of this class can be created from Vector3D
, either as rows or columns
if the matrix is transposed. For example:
Vector3Dcolumn0 = Vector3D.valueOf(...); Vector3D column1 = Vector3D.valueOf(...); Vector3D column2 = Vector3D.valueOf(...); Matrix3D M = Matrix3D.valueOf(column0, column1, column2).transpose();
Modified by: Joseph A. Huwaldt
Modifier and Type | Method and Description |
---|---|
Matrix3D |
adjoint()
Returns the adjoint of this matrix.
|
<T extends Quantity> |
asType(java.lang.Class<T> type)
Casts this Matrix3D to a parameterized unit of specified nature or throw a
ClassCastException if the specified quantity and this matrix unit
dimension do not match. |
Parameter |
cofactor(int i,
int j)
Returns the cofactor of an element in this matrix.
|
Matrix3D<Q> |
copy()
Returns a copy of this matrix allocated by the calling thread (possibly on the
stack).
|
Parameter |
determinant()
Returns the determinant of this matrix.
|
Parameter<Q> |
get(int i,
int j)
Returns a single element from this matrix.
|
Vector3D<Q> |
getColumn(int j)
Returns the column identified by the specified index in this matrix.
|
Vector3D<Q> |
getDiagonal()
Returns the diagonal vector.
|
int |
getNumberOfColumns()
Returns the number of columns n for this matrix.
|
int |
getNumberOfRows()
Returns the number of rows m for this matrix.
|
Vector3D<Q> |
getRow(int i)
Returns the row identified by the specified index in this matrix.
|
Unit<Q> |
getUnit()
Returns the unit in which the
values in this vector are stated. |
double |
getValue(int i,
int j)
Returns a single element from this matrix as a
double . |
Matrix3D |
inverse()
Returns the inverse of this matrix.
|
boolean |
isApproxZero()
Compares this Matrix3D for approximate equality to zero (all the values are within
the numerical roundoff error of zero).
|
static void |
main(java.lang.String[] args)
Tests the methods in this class.
|
Matrix3D<Q> |
minus(Matrix<Parameter<Q>> that)
Returns the difference between this matrix and the one specified.
|
Matrix3D<Q> |
opposite()
Returns the negation of this matrix.
|
Matrix3D<Q> |
plus(Matrix<Parameter<Q>> that)
Returns the sum of this matrix with the one specified.
|
Matrix |
tensor(Matrix that)
Returns the linear algebraic matrix tensor product of this matrix and another
(Kronecker product).
|
Matrix3D<Q> |
times(double k)
Returns the product of this matrix by the specified factor.
|
Matrix3D |
times(Matrix that)
Returns the product of this matrix with the one specified.
|
Matrix3D |
times(Parameter k)
Returns the product of this matrix by the specified factor.
|
Vector3D |
times(Vector v)
Returns the product of this matrix by the specified vector.
|
<R extends Quantity> |
to(Unit<R> unit)
Returns the equivalent to this matrix but stated in the specified unit.
|
Float64Matrix |
toFloat64Matrix()
Returns a Float64Matrix containing the data in this matrix in the current units of
this matrix.
|
Matrix3D<Q> |
transpose()
Returns the transpose of this matrix.
|
static <Q extends Quantity> |
valueOf(double[][] matrix,
Unit<Q> unit)
Returns a
Matrix3D instance containing the specified matrix of double
values stated in the specified units. |
static <Q extends Quantity> |
valueOf(double a,
double b,
double c,
double d,
double e,
double f,
double g,
double h,
double i,
Unit<Q> unit)
Returns 3D matrix from a sequence of 9
double values. |
static <Q extends Quantity> |
valueOf(Float64Vector row0,
Float64Vector row1,
Float64Vector row2,
Unit<Q> unit)
Returns a 3D matrix holding the specified row vectors in the stated units (column
vectors if
transposed ). |
static <Q extends Quantity> |
valueOf(java.util.List<Vector3D<Q>> rows)
Returns a 3D matrix holding the row
vectors from the specified
collection (column vectors if transposed ). |
static <Q extends Quantity> |
valueOf(Matrix<Float64> matrix,
Unit<Q> unit)
Returns a
Matrix3D instance containing the specified matrix of Float64
values stated in the specified units. |
static <Q extends Quantity> |
valueOf(Matrix<Parameter<Q>> that)
Returns a 3D matrix equivalent to the specified matrix.
|
static <Q extends Quantity> |
valueOf(Vector3D<Q> row0,
Vector3D<Q> row1,
Vector3D<Q> row2)
Returns a 3D matrix holding the specified row vectors (column vectors if
transposed ). |
Vector<Parameter<Q>> |
vectorization()
Returns the vectorization of this matrix.
|
public static <Q extends Quantity> Matrix3D<Q> valueOf(double a, double b, double c, double d, double e, double f, double g, double h, double i, Unit<Q> unit)
double
values.
Values are ordered as follows:
| a b c | | d e f | | g h i |
a
- matrix element 0,0b
- matrix element 0,1c
- matrix element 0,2d
- matrix element 1,0e
- matrix element 1,1f
- matrix element 1,2g
- matrix element 2,0h
- matrix element 2,1i
- matrix element 2,2unit
- the unit in which the elements are stated.public static <Q extends Quantity> Matrix3D<Q> valueOf(Float64Vector row0, Float64Vector row1, Float64Vector row2, Unit<Q> unit)
transposed
).row0
- the 1st row vector.row1
- the 2nd row vector.row2
- the 3rd row vector.unit
- the unit in which the elements are stated.public static <Q extends Quantity> Matrix3D<Q> valueOf(Vector3D<Q> row0, Vector3D<Q> row1, Vector3D<Q> row2)
transposed
). All the values are converted to the same units as
the 1st row (row0).row0
- the 1st row vector.row1
- the 2nd row vector.row2
- the 3rd row vector.public static <Q extends Quantity> Matrix3D<Q> valueOf(java.util.List<Vector3D<Q>> rows)
vectors
from the specified
collection (column vectors if transposed
). All the values are
converted to the same units as the 1st row (row0).rows
- The list of row vectors. If there are more than 3 elements, an
exception is thrown.DimensionException
- if the rows do not have a dimension of 3.public static <Q extends Quantity> Matrix3D<Q> valueOf(Matrix<Float64> matrix, Unit<Q> unit)
Matrix3D
instance containing the specified matrix of Float64
values stated in the specified units. The input matrix must have dimensions of 3x3.matrix
- the matrix of Float64 values stated in the specified unit (must have
dimension of 3x3).unit
- the unit in which the elements are stated.public static <Q extends Quantity> Matrix3D<Q> valueOf(double[][] matrix, Unit<Q> unit)
Matrix3D
instance containing the specified matrix of double
values stated in the specified units. The input matrix must have dimensions of 3x3.matrix
- the matrix of double values stated in the specified unit (must have
dimension of 3x3).unit
- the unit in which the elements are stated.public static <Q extends Quantity> Matrix3D<Q> valueOf(Matrix<Parameter<Q>> that)
that
- the matrix to convert.that
or a 3D matrix holding the same elements as the specified
matrix.public int getNumberOfRows()
getNumberOfRows
in class Matrix<Parameter<Q extends Quantity>>
public int getNumberOfColumns()
getNumberOfColumns
in class Matrix<Parameter<Q extends Quantity>>
public <R extends Quantity> Matrix3D<R> to(Unit<R> unit)
unit
- the unit of the matrix to be returned.ConversionException
- if the current model does not allows for conversion to
the specified unit.public <T extends Quantity> Matrix3D<T> asType(java.lang.Class<T> type) throws java.lang.ClassCastException
ClassCastException
if the specified quantity and this matrix unit
dimension do not match.type
- the quantity class identifying the nature of the unit.java.lang.ClassCastException
- if the dimension of this parameter's unit is different
from the specified quantity dimension.java.lang.UnsupportedOperationException
- if the specified quantity class does not have
a public static field named "UNIT" holding the standard unit for the quantity.public double getValue(int i, int j)
double
.i
- the row index (range [0..3[).j
- the column index (range [0..3[).public Vector3D<Q> getRow(int i)
public Vector3D<Q> getColumn(int j)
public Vector3D<Q> getDiagonal()
getDiagonal
in class Matrix<Parameter<Q extends Quantity>>
public Matrix3D<Q> plus(Matrix<Parameter<Q>> that)
public Matrix3D<Q> minus(Matrix<Parameter<Q>> that)
public Matrix3D times(Parameter k)
public Matrix3D<Q> times(double k)
k
- the coefficient multiplierthis · k
public Matrix3D inverse()
determinant()
will be zero (or nearly zero).public Parameter determinant()
determinant
in class Matrix<Parameter<Q extends Quantity>>
public Parameter cofactor(int i, int j)
public Matrix3D adjoint()
public Matrix tensor(Matrix that)
public boolean isApproxZero()
true
if this Matrix3D is approximately equal to zero;
false
otherwise.public Vector<Parameter<Q>> vectorization()
DenseVector>
.vectorization
in class Matrix<Parameter<Q extends Quantity>>
public Matrix3D<Q> copy()
public Float64Matrix toFloat64Matrix()
public static void main(java.lang.String[] args)