Class CommonOps_DDF4
Common matrix operations for fixed sized matrices which are 4 x 4 or 4 element vectors.
DO NOT MODIFY. Automatically generated code created by GenerateCommonOps_DDF
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidPerforms the following operation:
c = a + b
ci = ai + bistatic voidadd(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = a + b
cij = aij + bijstatic voidPerforms the following operation:
a = a + b
ai = ai + bistatic voidaddEquals(DMatrix4x4 a, DMatrix4x4 b) Performs the following operation:
a = a + b
aij = aij + bijstatic voidChanges the sign of every element in the vector.
ai = -aistatic voidChanges the sign of every element in the matrix.
aij = -aijstatic booleancholL(DMatrix4x4 A) Performs a lower Cholesky decomposition of matrix 'A' and stores result in A.static booleancholU(DMatrix4x4 A) Performs an upper Cholesky decomposition of matrix 'A' and stores result in A.static doubledet(DMatrix4x4 mat) Computes the determinant using minor matrices.
WARNING: Potentially less stable than using LU decomposition.static voiddiag(DMatrix4x4 input, DMatrix4 out) Extracts all diagonal elements from 'input' and places them inside the 'out' vector.static voidPerforms an in-place element by element scalar division.static voidPerforms an element by element scalar division.static voiddivide(DMatrix4x4 a, double alpha) Performs an in-place element by element scalar division.static voiddivide(DMatrix4x4 a, double alpha, DMatrix4x4 b) Performs an element by element scalar division.static doublePerforms the vector dot product:
c = a * b
c ≥ ∑k=1:n { bk * ak }static voidelementDiv(DMatrix4 a, DMatrix4 b) Performs an element by element division operation:
ai = ai / bistatic voidelementDiv(DMatrix4 a, DMatrix4 b, DMatrix4 c) Performs an element by element division operation:
ci = ai / bistatic voidelementDiv(DMatrix4x4 a, DMatrix4x4 b) Performs an element by element division operation:
aij = aij / bijstatic voidelementDiv(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs an element by element division operation:
cij = aij / bijstatic doubleReturns the value of the element in the vector that has the largest value.
Max{ ai } for all istatic doubleReturns the value of the element in the matrix that has the largest value.
Max{ aij } for all i and jstatic doubleReturns the absolute value of the element in the vector that has the largest absolute value.
Max{ |ai| } for all istatic doubleReturns the absolute value of the element in the matrix that has the largest absolute value.
Max{ |aij| } for all i and jstatic doubleReturns the value of the element in the vector that has the minimum value.
Min{ ai } for allstatic doubleReturns the value of the element in the matrix that has the minimum value.
Min{ aij } for all i and jstatic doubleReturns the absolute value of the element in the vector that has the smallest absolute value.
Min{ |ai| } for all istatic doubleReturns the absolute value of the element in the matrix that has the smallest absolute value.
Min{ |aij| } for all i and jstatic voidelementMult(DMatrix4 a, DMatrix4 b) Performs an element by element multiplication operation:
ai = ai * bistatic voidelementMult(DMatrix4 a, DMatrix4 b, DMatrix4 c) Performs an element by element multiplication operation:
ci = ai * bjstatic voidelementMult(DMatrix4x4 a, DMatrix4x4 b) Performs an element by element multiplication operation:
aij = aij * bijstatic voidelementMult(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs an element by element multiplication operation:
cij = aij * bijstatic DMatrix4extractColumn(DMatrix4x4 a, int column, DMatrix4 out) Extracts the column from the matrix a.static DMatrix4extractRow(DMatrix4x4 a, int row, DMatrix4 out) Extracts the row from the matrix a.static voidSets every element in the vector to the specified value.
ai = valuestatic voidfill(DMatrix4x4 a, double v) Sets every element in the matrix to the specified value.
aij = valuestatic booleaninvert(DMatrix4x4 a, DMatrix4x4 inv) Inverts matrix 'a' using minor matrices and stores the results in 'inv'.static voidmult(double alpha, DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = α * a * b
cij = α ∑k=1:n { aik * bkj}static voidmult(DMatrix4 a, DMatrix4x4 b, DMatrix4 c) Performs vector to matrix multiplication:
c = a * b
cj = ∑k=1:n { bk * akj }static voidmult(DMatrix4x4 a, DMatrix4 b, DMatrix4 c) Performs matrix to vector multiplication:
c = a * b
ci = ∑k=1:n { aik * bk}static voidmult(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = a * b
cij = ∑k=1:n { aik * bkj}static voidmultAdd(double alpha, DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c += α * a * b
cij += α ∑k=1:n { aik * bkj}static voidmultAdd(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c += a * b
cij += ∑k=1:n { aik * bkj}static voidmultAddOuter(double alpha, DMatrix4x4 A, double beta, DMatrix4 u, DMatrix4 v, DMatrix4x4 C) C = αA + βu*vTstatic voidmultAddTransA(double alpha, DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c += α * aT * b
cij += α * ∑k=1:n { aki * bkj}static voidmultAddTransA(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c += aT * b
cij += ∑k=1:n { aki * bkj}static voidmultAddTransAB(double alpha, DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c += α*aT * bT
cij += α*∑k=1:n { aki * bjk}static voidmultAddTransAB(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c += aT * bT
cij += ∑k=1:n { aki * bjk}static voidmultAddTransB(double alpha, DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c += α * a * bT
cij += α*∑k=1:n { aik * bjk}static voidmultAddTransB(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c += a * bT
cij += ∑k=1:n { aik * bjk}static voidmultTransA(double alpha, DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = α * aT * b
cij = α * ∑k=1:n { aki * bkj}static voidmultTransA(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = aT * b
cij = ∑k=1:n { aki * bkj}static voidmultTransAB(double alpha, DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = α*aT * bT
cij = α*∑k=1:n { aki * bjk}static voidmultTransAB(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = aT * bT
cij = ∑k=1:n { aki * bjk}static voidmultTransB(double alpha, DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = α * a * bT
cij = α*∑k=1:n { aik * bjk}static voidmultTransB(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = a * bT
cij = ∑k=1:n { aik * bjk}static voidPerforms an in-place element by element scalar multiplication.
aij = α*aijstatic voidPerforms an element by element scalar multiplication.
bi = α*aistatic voidscale(double alpha, DMatrix4x4 a) Performs an in-place element by element scalar multiplication.
aij = α*aijstatic voidscale(double alpha, DMatrix4x4 a, DMatrix4x4 b) Performs an element by element scalar multiplication.
bij = α*aijstatic voidSets all the diagonal elements equal to one and everything else equal to zero.static voidPerforms the following operation:
c = a - b
ci = ai - bistatic voidsubtract(DMatrix4x4 a, DMatrix4x4 b, DMatrix4x4 c) Performs the following operation:
c = a - b
cij = aij - bijstatic voidsubtractEquals(DMatrix4 a, DMatrix4 b) Performs the following operation:
a = a - b
ai = ai - bistatic voidPerforms the following operation:
a = a - b
aij = aij - bijstatic doubletrace(DMatrix4x4 a) This computes the trace of the matrix:
trace = ∑i=1:n { aii }static voidPerforms an in-place transpose.static DMatrix4x4transpose(DMatrix4x4 input, DMatrix4x4 output) Transposes matrix 'a' and stores the results in 'b':
bij = aji
where 'b' is the transpose of 'a'.
-
Constructor Details
-
CommonOps_DDF4
public CommonOps_DDF4()
-
-
Method Details
-
add
Performs the following operation:
c = a + b
cij = aij + bij
Matrix C can be the same instance as Matrix A and/or B.
- Parameters:
a- A Matrix. Not modified.b- A Matrix. Not modified.c- A Matrix where the results are stored. Modified.
-
add
Performs the following operation:
c = a + b
ci = ai + bi
Vector C can be the same instance as Vector A and/or B.
- Parameters:
a- A Vector. Not modified.b- A Vector. Not modified.c- A Vector where the results are stored. Modified.
-
addEquals
Performs the following operation:
a = a + b
aij = aij + bij
- Parameters:
a- A Matrix. Modified.b- A Matrix. Not modified.
-
addEquals
Performs the following operation:
a = a + b
ai = ai + bi
- Parameters:
a- A Vector. Modified.b- A Vector. Not modified.
-
subtract
Performs the following operation:
c = a - b
cij = aij - bij
Matrix C can be the same instance as Matrix A and/or B.
- Parameters:
a- A Matrix. Not modified.b- A Matrix. Not modified.c- A Matrix where the results are stored. Modified.
-
subtract
Performs the following operation:
c = a - b
ci = ai - bi
Vector C can be the same instance as Vector A and/or B.
- Parameters:
a- A Vector. Not modified.b- A Vector. Not modified.c- A Vector where the results are stored. Modified.
-
subtractEquals
Performs the following operation:
a = a - b
aij = aij - bij
- Parameters:
a- A Matrix. Modified.b- A Matrix. Not modified.
-
subtractEquals
Performs the following operation:
a = a - b
ai = ai - bi
- Parameters:
a- A Vector. Modified.b- A Vector. Not modified.
-
transpose
Performs an in-place transpose. This algorithm is only efficient for square matrices.- Parameters:
m- The matrix that is to be transposed. Modified.
-
transpose
Transposes matrix 'a' and stores the results in 'b':
bij = aji
where 'b' is the transpose of 'a'.- Parameters:
input- The original matrix. Not modified.output- Where the transpose is stored. If null a new matrix is created. Modified.- Returns:
- The transposed matrix.
-
mult
Performs the following operation:
c = a * b
cij = ∑k=1:n { aik * bkj}- Parameters:
a- The left matrix in the multiplication operation. Not modified.b- The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
mult
Performs the following operation:
c = α * a * b
cij = α ∑k=1:n { aik * bkj}- Parameters:
alpha- Scaling factor.a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multTransA
Performs the following operation:
c = aT * b
cij = ∑k=1:n { aki * bkj}- Parameters:
a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multTransA
Performs the following operation:
c = α * aT * b
cij = α * ∑k=1:n { aki * bkj}- Parameters:
alpha- Scaling factor.a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multTransAB
Performs the following operation:
c = aT * bT
cij = ∑k=1:n { aki * bjk}- Parameters:
a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multTransAB
Performs the following operation:
c = α*aT * bT
cij = α*∑k=1:n { aki * bjk}- Parameters:
alpha- Scaling factor.a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multTransB
Performs the following operation:
c = a * bT
cij = ∑k=1:n { aik * bjk}- Parameters:
a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multTransB
Performs the following operation:
c = α * a * bT
cij = α*∑k=1:n { aik * bjk}- Parameters:
alpha- Scaling factor.a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAdd
Performs the following operation:
c += a * b
cij += ∑k=1:n { aik * bkj}- Parameters:
a- The left matrix in the multiplication operation. Not modified.b- The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAdd
Performs the following operation:
c += α * a * b
cij += α ∑k=1:n { aik * bkj}- Parameters:
alpha- Scaling factor.a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAddTransA
Performs the following operation:
c += aT * b
cij += ∑k=1:n { aki * bkj}- Parameters:
a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAddTransA
Performs the following operation:
c += α * aT * b
cij += α * ∑k=1:n { aki * bkj}- Parameters:
alpha- Scaling factor.a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAddTransAB
Performs the following operation:
c += aT * bT
cij += ∑k=1:n { aki * bjk}- Parameters:
a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAddTransAB
Performs the following operation:
c += α*aT * bT
cij += α*∑k=1:n { aki * bjk}- Parameters:
alpha- Scaling factor.a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAddTransB
Performs the following operation:
c += a * bT
cij += ∑k=1:n { aik * bjk}- Parameters:
a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAddTransB
Performs the following operation:
c += α * a * bT
cij += α*∑k=1:n { aik * bjk}- Parameters:
alpha- Scaling factor.a- (Input) The left matrix in the multiplication operation. Not modified.b- (Input) The right matrix in the multiplication operation. Not modified.c- (Output) Where the results of the operation are stored. Modified.
-
multAddOuter
public static void multAddOuter(double alpha, DMatrix4x4 A, double beta, DMatrix4 u, DMatrix4 v, DMatrix4x4 C) C = αA + βu*vT- Parameters:
alpha- scale factor applied to AA- matrixbeta- scale factor applies to outer productu- vectorv- vectorC- Storage for solution. Can be same instance as A.
-
mult
Performs matrix to vector multiplication:
c = a * b
ci = ∑k=1:n { aik * bk}- Parameters:
a- The left matrix in the multiplication operation. Not modified.b- The right vector in the multiplication operation. Not modified.c- Where the results of the operation are stored. Modified.
-
mult
Performs vector to matrix multiplication:
c = a * b
cj = ∑k=1:n { bk * akj }- Parameters:
a- The left vector in the multiplication operation. Not modified.b- The right matrix in the multiplication operation. Not modified.c- Where the results of the operation are stored. Modified.
-
dot
Performs the vector dot product:
c = a * b
c ≥ ∑k=1:n { bk * ak }- Parameters:
a- The left vector in the multiplication operation. Not modified.b- The right matrix in the multiplication operation. Not modified.- Returns:
- The dot product
-
setIdentity
Sets all the diagonal elements equal to one and everything else equal to zero. If this is a square matrix then it will be an identity matrix.- Parameters:
a- A matrix.
-
invert
Inverts matrix 'a' using minor matrices and stores the results in 'inv'. Scaling is applied to improve stability against overflow and underflow. WARNING: Potentially less stable than using LU decomposition.- Parameters:
a- (Input) Matrix.inv- (Output) Inverted matrix. Can be the same as 'a'.- Returns:
- true if it was successful or false if it failed. Not reliable.
-
det
Computes the determinant using minor matrices.
WARNING: Potentially less stable than using LU decomposition.- Parameters:
mat- Input matrix. Not modified.- Returns:
- The determinant.
-
cholL
Performs a lower Cholesky decomposition of matrix 'A' and stores result in A.- Parameters:
A- (Input) SPD Matrix. (Output) lower cholesky.- Returns:
- true if it was successful or false if it failed. Not always reliable.
-
cholU
Performs an upper Cholesky decomposition of matrix 'A' and stores result in A.- Parameters:
A- (Input) SPD Matrix. (Output) upper cholesky.- Returns:
- true if it was successful or false if it failed. Not always reliable.
-
trace
This computes the trace of the matrix:
trace = ∑i=1:n { aii }The trace is only defined for square matrices.
- Parameters:
a- A square matrix. Not modified.
-
diag
Extracts all diagonal elements from 'input' and places them inside the 'out' vector. Elements are in sequential order.
- Parameters:
input- Matrix. Not modified.out- Vector containing diagonal elements. Modified.
-
elementMax
Returns the value of the element in the matrix that has the largest value.
Max{ aij } for all i and j
- Parameters:
a- A matrix. Not modified.- Returns:
- The max element value of the matrix.
-
elementMax
Returns the value of the element in the vector that has the largest value.
Max{ ai } for all i
- Parameters:
a- A vector. Not modified.- Returns:
- The max element value of the matrix.
-
elementMaxAbs
Returns the absolute value of the element in the matrix that has the largest absolute value.
Max{ |aij| } for all i and j
- Parameters:
a- A matrix. Not modified.- Returns:
- The max abs element value of the matrix.
-
elementMaxAbs
Returns the absolute value of the element in the vector that has the largest absolute value.
Max{ |ai| } for all i
- Parameters:
a- A matrix. Not modified.- Returns:
- The max abs element value of the vector.
-
elementMin
Returns the value of the element in the matrix that has the minimum value.
Min{ aij } for all i and j
- Parameters:
a- A matrix. Not modified.- Returns:
- The value of element in the matrix with the minimum value.
-
elementMin
Returns the value of the element in the vector that has the minimum value.
Min{ ai } for all
- Parameters:
a- A matrix. Not modified.- Returns:
- The value of element in the vector with the minimum value.
-
elementMinAbs
Returns the absolute value of the element in the matrix that has the smallest absolute value.
Min{ |aij| } for all i and j
- Parameters:
a- A matrix. Not modified.- Returns:
- The max element value of the matrix.
-
elementMinAbs
Returns the absolute value of the element in the vector that has the smallest absolute value.
Min{ |ai| } for all i
- Parameters:
a- A matrix. Not modified.- Returns:
- The max element value of the vector.
-
elementMult
Performs an element by element multiplication operation:
aij = aij * bij
- Parameters:
a- The left matrix in the multiplication operation. Modified.b- The right matrix in the multiplication operation. Not modified.
-
elementMult
Performs an element by element multiplication operation:
ai = ai * bi
- Parameters:
a- The left vector in the multiplication operation. Modified.b- The right vector in the multiplication operation. Not modified.
-
elementMult
Performs an element by element multiplication operation:
cij = aij * bij
- Parameters:
a- The left matrix in the multiplication operation. Not modified.b- The right matrix in the multiplication operation. Not modified.c- Where the results of the operation are stored. Modified.
-
elementMult
Performs an element by element multiplication operation:
ci = ai * bj
- Parameters:
a- The left vector in the multiplication operation. Not modified.b- The right vector in the multiplication operation. Not modified.c- Where the results of the operation are stored. Modified.
-
elementDiv
Performs an element by element division operation:
aij = aij / bij
- Parameters:
a- The left matrix in the division operation. Modified.b- The right matrix in the division operation. Not modified.
-
elementDiv
Performs an element by element division operation:
ai = ai / bi
- Parameters:
a- The left vector in the division operation. Modified.b- The right vector in the division operation. Not modified.
-
elementDiv
Performs an element by element division operation:
cij = aij / bij
- Parameters:
a- The left matrix in the division operation. Not modified.b- The right matrix in the division operation. Not modified.c- Where the results of the operation are stored. Modified.
-
elementDiv
Performs an element by element division operation:
ci = ai / bi
- Parameters:
a- The left vector in the division operation. Not modified.b- The right vector in the division operation. Not modified.c- Where the results of the operation are stored. Modified.
-
scale
Performs an in-place element by element scalar multiplication.
aij = α*aij- Parameters:
a- The matrix that is to be scaled. Modified.alpha- the amount each element is multiplied by.
-
scale
Performs an in-place element by element scalar multiplication.
aij = α*aij- Parameters:
a- The vector that is to be scaled. Modified.alpha- the amount each element is multiplied by.
-
scale
Performs an element by element scalar multiplication.
bij = α*aij- Parameters:
alpha- the amount each element is multiplied by.a- The matrix that is to be scaled. Not modified.b- Where the scaled matrix is stored. Modified.
-
scale
Performs an element by element scalar multiplication.
bi = α*ai- Parameters:
alpha- the amount each element is multiplied by.a- The vector that is to be scaled. Not modified.b- Where the scaled matrix is stored. Modified.
-
divide
Performs an in-place element by element scalar division. Scalar denominator.
aij = aij/α- Parameters:
a- The matrix whose elements are to be divided. Modified.alpha- the amount each element is divided by.
-
divide
Performs an in-place element by element scalar division. Scalar denominator.
ai = ai/α- Parameters:
a- The vector whose elements are to be divided. Modified.alpha- the amount each element is divided by.
-
divide
Performs an element by element scalar division. Scalar denominator.
bij = aij /α- Parameters:
alpha- the amount each element is divided by.a- The matrix whose elements are to be divided. Not modified.b- Where the results are stored. Modified.
-
divide
Performs an element by element scalar division. Scalar denominator.
bi = ai /α- Parameters:
alpha- the amount each element is divided by.a- The vector whose elements are to be divided. Not modified.b- Where the results are stored. Modified.
-
changeSign
Changes the sign of every element in the matrix.
aij = -aij- Parameters:
a- A matrix. Modified.
-
changeSign
Changes the sign of every element in the vector.
ai = -ai- Parameters:
a- A vector. Modified.
-
fill
Sets every element in the matrix to the specified value.
aij = value- Parameters:
a- A matrix whose elements are about to be set. Modified.v- The value each element will have.
-
fill
Sets every element in the vector to the specified value.
ai = value- Parameters:
a- A vector whose elements are about to be set. Modified.v- The value each element will have.
-
extractRow
Extracts the row from the matrix a.- Parameters:
a- Input matrixrow- Which row is to be extractedout- output. Storage for the extracted row. If null then a new vector will be returned.- Returns:
- The extracted row.
-
extractColumn
Extracts the column from the matrix a.- Parameters:
a- Input matrixcolumn- Which column is to be extractedout- output. Storage for the extracted column. If null then a new vector will be returned.- Returns:
- The extracted column.
-