|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.MatrixBase
maspack.matrix.DenseMatrixBase
maspack.matrix.Matrix3dBase
maspack.matrix.Matrix3d
public class Matrix3d
A general 3 x 3 matrix with the elements stored as explicit fields.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface maspack.matrix.Matrix |
---|
Matrix.Partition, Matrix.WriteFormat |
Field Summary | |
---|---|
static Matrix3d |
IDENTITY
Global identity matrix. |
static Matrix3d |
ZERO
Global zero matrix. |
Fields inherited from class maspack.matrix.Matrix3dBase |
---|
m00, m01, m02, m10, m11, m12, m20, m21, m22 |
Fields inherited from interface maspack.matrix.Matrix |
---|
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC |
Constructor Summary | |
---|---|
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(Matrix3dBase M)
Creates a matrix and initializes its elements to those of the matrix M. |
Method Summary | |
---|---|
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 |
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 v0,
Vector3d v1)
Adds a scaled outer product to this matrix. |
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. |
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,
Matrix3d 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 |
mulDiagonalLeft(double d00,
double d11,
double d22)
Pre-multiplies, in place, this matrix by a diagonal matrix whose (diagonal) elements are explicitly specified. |
void |
mulDiagonalLeft(Vector3d diag)
Pre-multiplies, in place, this matrix by a diagonal matrix whose (diagonal) elements are specified by a vector. |
void |
mulDiagonalRight(double d00,
double d11,
double d22)
Post-multiplies, in place, this matrix by a diagonal matrix whose (diagonal) elements are explicitly specified. |
void |
mulDiagonalRight(Vector3d diag)
Post-multiplies, in place, this matrix by a diagonal matrix whose (diagonal) elements are specified by a vector. |
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 |
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,
Matrix3d M1)
Scales this matrix by s, adds M1, and places the result 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 |
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 |
setColumns(Vector3d v0,
Vector3d v1,
Vector3d v2)
Sets the columns of this matrix to the vectors v0, v1, and v2. |
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(Matrix3d 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,
Matrix3d M)
Applies a rotational transformation R to a matrix M, and place the result in this matrix. |
void |
transpose(Matrix3dBase M1)
Takes the transpose of matrix M1 and places the result in this matrix. |
Methods inherited from class maspack.matrix.Matrix3dBase |
---|
clone, colSize, determinant, epsilonEquals, equals, factorQR, frobeniusNorm, get, get, getColumn, getColumn, getColumn, getRow, getRow, getRow, infinityNorm, isIdentity, mul, mul, mul, mulAdd, mulInverse, mulInverse, mulInverseTranspose, mulInverseTranspose, mulTranspose, mulTranspose, mulTransposeAdd, negate, oneNorm, orthogonalDeterminant, rowSize, set, set, set, set, setColumn, setColumn, setIdentity, setRow, setRow, trace, transpose |
Methods inherited from class maspack.matrix.DenseMatrixBase |
---|
add, checkConsistency, set, set, set, setCCSValues, setColumn, setCRSValues, setRow, setSubMatrix |
Methods inherited from class maspack.matrix.MatrixBase |
---|
containsNaN, epsilonEquals, equals, get, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getDefaultFormat, getRow, getSize, getSubMatrix, hasNaN, idString, isFixedSize, isSymmetric, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, scan, setCRSValues, setDefaultFormat, setSize, toString, toString, toString, write, write, write, write, write, writeToFile |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface maspack.matrix.Matrix |
---|
epsilonEquals, equals, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getRow, getSize, getSubMatrix, isFixedSize, isSymmetric, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, scan, setSize, toString, write, write, write |
Field Detail |
---|
public static final Matrix3d IDENTITY
public static final Matrix3d ZERO
Constructor Detail |
---|
public Matrix3d()
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.Method Detail |
---|
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)
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 matrix
public boolean mulInverseRight(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrix
public boolean mulInverseLeft(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrix
public boolean mulInverseBoth(Matrix3dBase M1, Matrix3dBase M2)
M1
- left-hand matrixM2
- right-hand matrix
public void mulDiagonalLeft(Vector3d diag)
diag
- specifies the diagonal elements of the implied left-hand matrixpublic void mulDiagonalLeft(double d00, double d11, double d22)
d00
- first diagnonal element of the implied left-hand matrixd11
- second diagonal element of the implied left-hand matrixd22
- third diagnonal element of the implied left-hand matrixpublic void mulDiagonalRight(Vector3d diag)
diag
- specifies the diagonal elements of the implied right-hand matrixpublic void mulDiagonalRight(double d00, double d11, double d22)
d00
- first diagnonal element of the implied right-hand matrixd11
- second diagonal element of the implied right-hand matrixd22
- third diagnonal element of the implied right-hand matrixpublic 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 scaledAdd(double s, Matrix3d M1)
s
- scaling factorM1
- matrix to be addedpublic void negate(Matrix3dBase M1)
M1
- matrix to negatepublic void transpose(Matrix3dBase M1)
M1
- matrix to take the transpose ofpublic void setZero()
public void setRandom()
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 invert
public boolean invert(Matrix3dBase M)
M
- matrix to invert
public 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 setSymmetric(Matrix3d 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)
s
- scaling factorv0
- first vectorv1
- second vectorpublic void crossProduct(Vector3d v, Matrix3dBase M)
v
- first cross product argumentM
- matrix whose columns supply the second cross product argumentpublic void crossProduct(Matrix3dBase M, Vector3d 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 exchanges
ImproperSizeException
- 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 exchanges
ImproperSizeException
- 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, Matrix3d 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, Matrix3d 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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |