public class Matrix3d extends Matrix3dBase implements VectorObject<Matrix3d>
Matrix.Partition, Matrix.WriteFormat
Modifier and Type | Field and Description |
---|---|
static Matrix3d |
IDENTITY
Global identity matrix.
|
static Matrix3d |
ZERO
Global zero matrix.
|
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC
Constructor and Description |
---|
Matrix3d()
Creates a matrix and initializes it to zero.
|
Matrix3d(double[] vals)
Creates a matrix and initializes its elements from an array of values.
|
Matrix3d(double m00,
double m01,
double m02,
double m10,
double m11,
double m12,
double m20,
double m21,
double m22)
Creates a matrix and initializes its elements from the specified values.
|
Matrix3d(Matrix M)
Creates a matrix and initializes its elements to those of the matrix M.
|
Matrix3d(Matrix3dBase M)
Creates a matrix and initializes its elements to those of the matrix M.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Matrix3dBase M1)
Adds this matrix to M1 and places the result in this matrix.
|
void |
add(Matrix3dBase M1,
Matrix3dBase M2)
Adds matrix M1 to M2 and places the result in this matrix.
|
void |
addDiagonal(double s)
Adds s to the diagonal elements of this matrix.
|
void |
addObj(Matrix3d M1)
Adds
v1 to this vector. |
void |
addOuterProduct(double x0,
double y0,
double z0,
double x1,
double y1,
double z1)
Adds an outer product to this matrix.
|
void |
addOuterProduct(Vector3d v0,
Vector3d v1)
Adds an outer product to this matrix.
|
void |
addScaledOuterProduct(double s,
Vector3d v)
Adds a scaled outer product to this matrix.
|
void |
addScaledOuterProduct(double s,
Vector3d v0,
Vector3d v1)
Adds a scaled outer product to this matrix.
|
Matrix3d |
clone() |
void |
crossProduct(Matrix3dBase M,
Vector3d v)
Computes the cross product of each row of M with v and places the result
in this matrix.
|
void |
crossProduct(Vector3d v,
Matrix3dBase M)
Computes the cross product of v with each column of M and places the
result in this matrix.
|
boolean |
epsilonEquals(Matrix3d M1,
double tol)
Returns true if the components of this vector are equal to those of
v1 , within the tolerance tol . |
void |
factorQR(Matrix3d Q,
Matrix3d R)
Computes the QR decompostion for this matrix, for which
|
double |
fastInvert(Matrix3dBase M)
Quickly inverts the matrix M using the determinant formula and returns
the computed determinant.
|
void |
inverseTransform(RotationMatrix3d R)
Applies an inverse rotational transformation R to this matrix, in place.
|
void |
inverseTransform(RotationMatrix3d R,
Matrix3dBase M)
Applies an inverse rotational transformation R to a matrix M, and place
the result in this matrix.
|
boolean |
invert()
Inverts this matrix in place, returning false if the matrix is detected to
be singular.
|
boolean |
invert(Matrix3dBase M)
Inverts the matrix M and places the result in this matrix, return false if
M is detected to be singular.
|
static void |
main(java.lang.String[] args) |
void |
mul(Matrix3dBase M1)
Multiplies this matrix by M1 and places the result in this matrix.
|
void |
mul(Matrix3dBase M1,
Matrix3dBase M2)
Multiplies matrix M1 by M2 and places the result in this matrix.
|
void |
mulCols(double d00,
double d11,
double d22)
Multiples the columns of this matrix by the values specified by
d00 , d11 , and d22 and places the
result in this matrix. |
void |
mulCols(Vector3d diag)
Multiples the columns of this matrix by the values specified by
diag and places the result in this matrix. |
boolean |
mulInverse(Matrix3dBase M1)
Multiplies this matrix by the inverse of M1 and places the result in this
matrix.
|
boolean |
mulInverseBoth(Matrix3dBase M1,
Matrix3dBase M2)
Multiplies the inverse of matrix M1 by the inverse of M2 and places the
result in this matrix.
|
boolean |
mulInverseLeft(Matrix3dBase M1,
Matrix3dBase M2)
Multiplies the inverse of matrix M1 by M2 and places the result in this
matrix.
|
boolean |
mulInverseRight(Matrix3dBase M1,
Matrix3dBase M2)
Multiplies matrix M1 by the inverse of M2 and places the result in this
matrix.
|
void |
mulRows(double d00,
double d11,
double d22)
Multiples the rows of this matrix by the values specified by
d00 , d11 , and d22 and places the
result in this matrix. |
void |
mulRows(Vector3d diag)
Multiples the rows of this matrix by the values specified by
diag and places the result in this matrix. |
void |
mulTranspose(Matrix3dBase M1)
Multiplies this matrix by the transpose of M1 and places the result in
this matrix.
|
void |
mulTransposeBoth(Matrix3dBase M1,
Matrix3dBase M2)
Multiplies the transpose of matrix M1 by the transpose of M2 and places
the result in this matrix.
|
void |
mulTransposeLeft(Matrix3dBase M1,
Matrix3dBase M2)
Multiplies the transpose of matrix M1 by M2 and places the result in this
matrix.
|
void |
mulTransposeRight(Matrix3dBase M1,
Matrix3dBase M2)
Multiplies matrix M1 by the transpose of M2 and places the result in this
matrix.
|
void |
negate(Matrix3dBase M1)
Sets this matrix to the negative of M1.
|
void |
outerProduct(Vector3d v1,
Vector3d v2)
Sets this matrix to the outer product of the two vectors v1 and v2.
|
void |
permuteColumns(int[] permutation)
Rearrange the columns of this matrix according to the specified
permutation, such that each column j is replaced by column permutation[j].
|
void |
permuteColumns(int col0,
int col1,
int col2)
Rearrange the columns of this matrix according to the specified
permutation.
|
void |
permuteRows(int[] permutation)
Rearrange the rows of this matrix according to the specified permutation,
such that each row i is replaced by row permutation[i].
|
void |
permuteRows(int row0,
int row1,
int row2)
Rearrange the rows of this matrix according to the specified permutation.
|
void |
scale(double s)
Scales the elements of this matrix by
s . |
void |
scale(double s,
Matrix3dBase M1)
Scales the elements of matrix M1 by
s and places the
results in this matrix. |
void |
scaledAdd(double s,
Matrix3dBase M1)
Computes s M1 and adds the result to this matrix.
|
void |
scaledAdd(double s,
Matrix3dBase M1,
Matrix3dBase M2)
Computes s M1 + M2 and places the result in this matrix.
|
void |
scaledAddObj(double s,
Matrix3d M1)
Scales
v1 by s and adds it to this vector. |
void |
scaleObj(double s)
Scales this vector by
s . |
void |
set(double m00,
double m01,
double m02,
double m10,
double m11,
double m12,
double m20,
double m21,
double m22)
Sets the values of this matrix.
|
void |
set(Matrix3d M1)
Sets this vector to
v1 |
void |
setColumns(Vector3d v0,
Vector3d v1,
Vector3d v2)
Sets the columns of this matrix to the vectors v0, v1, and v2.
|
void |
setDiagonal(double s)
Sets the diagonal elements of this matrix to s.
|
void |
setDiagonal(double[] vals)
Sets this matrix to a diagonal matrix whose values are specified by the
array vals.
|
void |
setDiagonal(double m00,
double m11,
double m22)
Sets this matrix to a diagonal matrix whose values are specified.
|
void |
setDiagonal(Vector3d diag)
Sets this matrix to a diagonal matrix whose values are specified by diag.
|
void |
setRandom()
Sets the elements of this matrix to uniformly distributed random values in
the range -0.5 (inclusive) to 0.5 (exclusive).
|
void |
setRandom(double lower,
double upper)
Sets the elements of this matrix to uniformly distributed random values in
a specified range.
|
void |
setRandom(double lower,
double upper,
java.util.Random generator)
Sets the elements of this matrix to uniformly distributed random values in
a specified range, using a supplied random number generator.
|
void |
setRows(Vector3d v0,
Vector3d v1,
Vector3d v2)
Sets the rows of this matrix to the vectors v0, v1, and v2.
|
void |
setSkewSymmetric(Vector3d v)
Sets this matrix to the skew-symmetric matrix of vector v
|
void |
setSymmetric(Matrix3dBase M1)
Sets this matrix to the symmetric component of matrix M1
|
void |
setZero()
Sets the elements of this matrix to zero.
|
void |
sub(Matrix3dBase M1)
Subtracts this matrix from M1 and places the result in this matrix.
|
void |
sub(Matrix3dBase M1,
Matrix3dBase M2)
Subtracts matrix M1 from M2 and places the result in this matrix.
|
void |
transform(RotationMatrix3d R)
Applies a rotational transformation R to this matrix, in place.
|
void |
transform(RotationMatrix3d R,
Matrix3dBase M)
Applies a rotational transformation R to a matrix M, and place the result
in this matrix.
|
void |
transpose(Matrix3dBase M1)
Sets this matrix to the transpose of M
|
colSize, determinant, epsilonEquals, equals, factorQR, frobeniusNorm, get, get, getColumn, getColumn, getColumn, getRow, getRow, getRow, infinityNorm, isIdentity, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulInverse, mulInverse, mulInverseTranspose, mulInverseTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeLeftAdd, mulTransposeRightAdd, negate, negateColumn, negateRow, oneNorm, orthogonalDeterminant, rowSize, scaleColumn, scaleRow, set, set, set, set, setColumn, setColumn, setIdentity, setRow, setRow, solve, solveTranspose, trace, transpose
add, checkConsistency, set, set, set, setCCSValues, setColumn, setCRSValues, setRow, setSubMatrix
containsNaN, epsilonEquals, equals, frobeniusNormSquared, get, getCCSIndices, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getCRSValues, getDefaultFormat, getRow, getSize, getSubMatrix, hasNaN, idString, isFixedSize, isWritable, maxNorm, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, scan, scan, setCRSValues, setDefaultFormat, setSize, toString, toString, toString, write, write, write, write, write, write, write, writeToFile
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getThreeVectorValue
isWritable, scan, write
epsilonEquals, equals, frobeniusNormSquared, getCCSIndices, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getCRSValues, getRow, getSize, getSubMatrix, isFixedSize, maxNorm, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, scan, setSize, toString, toString, write, write, write
public static final Matrix3d IDENTITY
public static final Matrix3d ZERO
public Matrix3d()
public Matrix3d(Matrix M)
M
- matrix object to be copied.public Matrix3d(double[] vals)
vals
- element values for the matrix, with element (i,j) stored at location
i*3+j
public Matrix3d(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
m00
- element (0,0)m01
- element (0,1)m02
- element (0,2)m10
- element (1,0)m11
- element (1,1)m12
- element (1,2)m20
- element (2,0)m21
- element (2,1)m22
- element (2,2)public Matrix3d(Matrix3dBase M)
M
- matrix object to be copied.public void setColumns(Vector3d v0, Vector3d v1, Vector3d v2)
v0
- values for the first columnv1
- values for the second columnv2
- values for the third columnpublic void set(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
m00
- element (0,0)m01
- element (0,1)m02
- element (0,2)m10
- element (1,0)m11
- element (1,1)m12
- element (1,2)m20
- element (2,0)m21
- element (2,1)m22
- element (2,2)public void setRows(Vector3d v0, Vector3d v1, Vector3d v2)
v0
- values for the first rowv1
- values for the second rowv2
- values for the third rowpublic void mul(Matrix3dBase M1)
M1
- right-hand matrixpublic void mul(Matrix3dBase M1, Matrix3dBase M2)
mul
in class Matrix3dBase
M1
- left-hand matrixM2
- right-hand matrixpublic void mulTranspose(Matrix3dBase M1)
M1
- right-hand matrixpublic void mulTransposeLeft(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrixpublic void mulTransposeRight(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrixpublic void mulTransposeBoth(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrixpublic boolean mulInverse(Matrix3dBase M1)
M1
- right-hand matrixpublic boolean mulInverseRight(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrixpublic boolean mulInverseLeft(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrixpublic boolean mulInverseBoth(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrixpublic void mulRows(Vector3d diag)
diag
and places the result in this matrix. This is
equivalent to pre-multiplying this matrix by a diagonal matrix whose
(diagonal) elements are specified by diag
.diag
- specifies the row multiplierspublic void mulRows(double d00, double d11, double d22)
d00
, d11
, and d22
and places the
result in this matrix. This is equivalent to pre-multiplying this matrix
by a diagonal matrix with the specified diagonal elements.d00
- multiplier for the first rowd11
- multiplier for the second rowd22
- multiplier for the third rowpublic void mulCols(Vector3d diag)
diag
and places the result in this matrix. This is
equivalent to post-multiplying this matrix by a diagonal matrix whose
(diagonal) elements are specified by diag
.diag
- specifies the column multiplierspublic void mulCols(double d00, double d11, double d22)
d00
, d11
, and d22
and places the
result in this matrix. This is equivalent to post-multiplying this matrix
by a diagonal matrix with the specified diagonal elements.d00
- multiplier for the first columnd11
- multiplier for the second columnd22
- multiplier for the third columnpublic void add(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrixpublic void add(Matrix3dBase M1)
M1
- right-hand matrixpublic void sub(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrixpublic void sub(Matrix3dBase M1)
M1
- right-hand matrixpublic void scale(double s)
s
.s
- scaling factorpublic void scale(double s, Matrix3dBase M1)
s
and places the
results in this matrix.s
- scaling factorM1
- matrix to be scaledpublic void scaledAdd(double s, Matrix3dBase M1, Matrix3dBase M2)
s
- scaling factorM1
- matrix to be scaledM2
- matrix to be addedpublic void scaledAdd(double s, Matrix3dBase M1)
s
- scaling factorM1
- matrix to be scaled and addedpublic void negate(Matrix3dBase M1)
M1
- matrix to negatepublic void transpose(Matrix3dBase M1)
M1
- matrix to take the transpose ofpublic void setZero()
setZero
in interface VectorObject<Matrix3d>
public void setRandom()
setRandom
in class DenseMatrixBase
public void setRandom(double lower, double upper)
lower
- lower random value (inclusive)upper
- upper random value (exclusive)public void setRandom(double lower, double upper, java.util.Random generator)
lower
- lower random value (inclusive)upper
- upper random value (exclusive)generator
- random number generatorpublic boolean invert()
invert
in class Matrix3dBase
public double fastInvert(Matrix3dBase M)
M
- matrix to invertpublic boolean invert(Matrix3dBase M)
M
- matrix to invertpublic void setDiagonal(Vector3d diag)
diag
- diagonal valuespublic void setDiagonal(double[] vals)
vals
- diagonal valuespublic void setDiagonal(double m00, double m11, double m22)
m00
- first diagonal valuem11
- second diagonal valuem22
- third diagonal valuepublic void setDiagonal(double s)
s
- value for each diagonal elementpublic void addDiagonal(double s)
s
- value to add to the diagonalpublic void setSymmetric(Matrix3dBase M1)
public void setSkewSymmetric(Vector3d v)
public void outerProduct(Vector3d v1, Vector3d v2)
v1
- first vectorv2
- second vectorpublic void addOuterProduct(double x0, double y0, double z0, double x1, double y1, double z1)
x0
- first vector x coordinatey0
- first vector y coordinatez0
- first vector z coordinatex1
- second vector x coordinatey1
- second vector y coordinatez1
- second vector z coordinatepublic void addOuterProduct(Vector3d v0, Vector3d v1)
v0
- first vectorv1
- second vectorpublic void addScaledOuterProduct(double s, Vector3d v0, Vector3d v1)
T s v1 v2
s
- scaling factorv0
- first vectorv1
- second vectorpublic void addScaledOuterProduct(double s, Vector3d v)
v
and takes
the form
T s v vThe product is hence symmetric.
s
- scaling factorv
- vector used to form outer productpublic void crossProduct(Vector3d v, Matrix3dBase M)
this = [v] M
v
- first cross product argumentM
- matrix whose columns supply the second cross product argumentpublic void crossProduct(Matrix3dBase M, Vector3d v)
this = M [v]
M
- matrix whose rows supply the first cross product argumentv
- second cross product argumentpublic void permuteColumns(int col0, int col1, int col2)
col0
- index of the original column which is to replace column 0col1
- index of the original column which is to replace column 1col2
- index of the original column which is to replace column 2public void permuteColumns(int[] permutation)
permutation
- describes the column exchangesImproperSizeException
- if the length of permutation
is less than 3public void permuteRows(int row0, int row1, int row2)
row0
- index of the original row which is to replace row 0row1
- index of the original row which is to replace row 1row2
- index of the original row which is to replace row 2public void permuteRows(int[] permutation)
permutation
- describes the row exchangesImproperSizeException
- if the length of permutation
is less than 3.public void transform(RotationMatrix3d R)
R M R^Twhere M is this matrix.
R
- rotational transformation matrixpublic void transform(RotationMatrix3d R, Matrix3dBase M)
R M R^T
R
- rotational transformation matrixM
- matrix to transformpublic void inverseTransform(RotationMatrix3d R)
R^T M Rwhere M is this matrix.
R
- rotational transformation matrixpublic void inverseTransform(RotationMatrix3d R, Matrix3dBase M)
R^T M R
inverseTransform
in class Matrix3dBase
R
- rotational transformation matrixM
- matrix to transformpublic static void main(java.lang.String[] args)
public void factorQR(Matrix3d Q, Matrix3d R)
M = Q Rwhere Q is orthogonal and R is upper triangular.
Q
- if non-null, returns QR
- if non-null, returns R
The computation is the same as that performed by the QRDecomposition
class, except significantly faster.public Matrix3d clone()
clone
in interface Clonable
clone
in class Matrix3dBase
public void scaleObj(double s)
s
.scaleObj
in interface VectorObject<Matrix3d>
public void addObj(Matrix3d M1)
v1
to this vector.addObj
in interface VectorObject<Matrix3d>
public void scaledAddObj(double s, Matrix3d M1)
v1
by s
and adds it to this vector.scaledAddObj
in interface VectorObject<Matrix3d>
public void set(Matrix3d M1)
v1
set
in interface VectorObject<Matrix3d>
public boolean epsilonEquals(Matrix3d M1, double tol)
v1
, within the tolerance tol
. If tol
= 0, then
exact equality is required.epsilonEquals
in interface VectorObject<Matrix3d>