public class PdMatrix extends java.lang.Object implements java.io.Serializable, PdMatrixIf
PnMatrix
.PnMatrix
,
Serialized FormModifier and Type | Field and Description |
---|---|
double[][] |
m_data
Data array containing the components of the vector.
|
Constructor and Description |
---|
PdMatrix()
Create a new matrix of zero size.
|
PdMatrix(double[][] x)
Constructs a matrix having same size and given initial data as given array.
|
PdMatrix(int aSize)
Create a square matrix with given dimension.
|
PdMatrix(int iSize,
int jSize)
Create a non-square matrix with given dimensions.
|
Modifier and Type | Method and Description |
---|---|
void |
add(PdMatrix m)
Add given matrix to this, this = this+m.
|
void |
add(PdMatrix m1,
PdMatrix m2)
Add two matrices and assign to this, this = m1+m2.
|
void |
addEntry(int i,
int j,
double value)
Add value to component of matrix, and possibly enlarge matrix if too small.
|
boolean |
adjoint(PdVector v)
Compute
this = v * v^t unsing adjoint(v, v). |
boolean |
adjoint(PdVector v,
PdVector w)
Compute this = v * w^t.
|
void |
blend(double a,
PdMatrix u,
double b,
PdMatrix v,
double c,
PdMatrix w)
Interpolate between three matrices with given weights, i.e.
|
void |
blend(PdBary bary,
PdMatrix u,
PdMatrix v,
PdMatrix w)
Interpolate between three matrices with given barycentric weights.
|
void |
clear()
Set all entries to zero.
|
java.lang.Object |
clone()
Duplicate matrix and data array.
|
void |
copy(PdMatrix m)
Copy given matrix to this, this = m.
|
static boolean |
copy(PdMatrix[] dataDest,
int destInd,
PdMatrix[] dataSrc,
int srcInd,
int size) |
static PdMatrix |
copyNew(PdMatrix mat)
Create a new matrix as clone of argument matrix.
|
static PdMatrix[] |
copyNew(PdMatrix[] data) |
static PdMatrix[] |
copyNew(PdMatrix[] data,
int size) |
double |
det()
Compute determinant square matrix with dimensions less or equal four.
|
double |
det33()
Compute determinant of (3*3) left upper block of matrix.
|
static PdMatrix |
expandComponents(PdMatrix mat,
int dim)
Create a bigger matrix such that each original entry expands to a (dim, dim)-diagonal matrix.
|
PdVector |
getColumn(int aColumn)
Get column vector of matrix.
|
double[][] |
getEntries()
Return a copy of content of matrix as array of arrays of doubles.
|
double |
getEntry(int i,
int j)
Get the component of matrix at (i-th row, j-th column).
|
int |
getISize()
Get number of rows of matrix.
|
int |
getJSize()
Get number of columns of matrix.
|
int |
getNumCols()
Get number of columns of matrix.
|
int |
getNumRows()
Get number of rows of matrix.
|
PdVector |
getRow(int aRow)
Get row vector of matrix.
|
int |
getSize()
Get dimension of square matrix, return -1 for non-square matrices.
|
boolean |
invert()
Invert a square matrix of dimension less than five by
this = inverse(this) . |
boolean |
invert(PdMatrix m)
Invert a square matrix of dimension less than five by
this = inverse(m) . |
boolean |
invert34(PdMatrix m)
Invert the top-left 3x4 square of a matrix44 in place.
|
boolean |
invertTopLeft(PdMatrix m,
int aSubSize)
Invert the top-left subSize x subSize square of a matrix m in place
and assign full matrix m to this matrix.
|
boolean |
isSquare()
Check if matrix is square.
|
void |
leftMult(PdMatrix m)
Multiply with square matrix from left of same sizes using
this = m*this . |
void |
leftMult(PdMatrix m,
int size)
Multiply a submatrix of this matrix with a submatrix of the parameter matrix.
|
PdVector |
leftMultMatrix(PdVector out,
PdVector in)
Multiply this matrix with vector and fill output vector,
out = this*in. |
void |
mult(PdMatrix mat1,
PdMatrix mat2)
Multiply two matrices of possibly different sizes using
this = mat1*mat2 . |
double |
multQuadratic(PdVector left,
PdVector right)
Compute
left^T*this*right . |
void |
multScalar(double scalar)
Multiply all matrix components with scalar.
|
void |
multScalar(PdMatrix m,
double scalar)
Multiply all matrix components of m with scalar s, this = m*s.
|
static PdMatrix[] |
realloc(PdMatrix[] data,
int arraySize) |
static PdMatrix[] |
realloc(PdMatrix[] data,
int arraySize,
int iSize,
int jSize) |
void |
rightMult(PdMatrix m)
Multiply with square matrix from right of same sizes using
this = this*m . |
void |
rightMult(PdMatrix m,
int size)
Multiply a submatrix of this matrix with a submatrix of the parameter matrix.
|
PdVector |
rightMultMatrix(PdVector out,
PdVector in)
Multiply this matrix with vector and fill output vector,
out = in*this. |
void |
set(double[][] x)
Assign values of array, and adjust length of matrix if different from length of array.
|
void |
setColumn(int aColumn,
PdVector aVector)
Set column vector of matrix.
|
void |
setColumns(PdVector[] aVector)
Fill matrix with array of column vectors.
|
void |
setConstant(double aValue)
Set all matrix entries to a constant value.
|
void |
setDiagonal(PdVector diag)
Set diagonal entries of a square matrix to components of a given vector.
|
void |
setEntry(int i,
int j,
double value)
Assign value to component of matrix, and possibly enlarge matrix if too small.
|
void |
setIdentity()
Initialize square matrix to be identity matrix.
|
void |
setRow(int aRow,
PdVector aVector)
Set row vector of matrix.
|
void |
setRows(PdVector[] aVector)
Fill matrix with array of row vectors.
|
void |
setSize(int size)
Resize square matrix with new dimension (size, size).
|
void |
setSize(int iSize,
int jSize)
Resize matrix to new dimension (iSize, jSize) with iSize rows and jSize columns.
|
void |
sub(PdMatrix m)
Subtract given matrix from this, this = this-m.
|
void |
sub(PdMatrix m1,
PdMatrix m2)
Subtract two matrices and assign to this, this = m1-m2.
|
java.lang.String |
toShortString()
Create a short string representation of matrix with all instance variables.
|
java.lang.String |
toString()
Create a multi-line string representation
with detailed information about all instance variables.
|
void |
transpose()
Transpose a square matrix by
this = transpose(this) . |
void |
transpose(PdMatrix m)
Transpose a matrix by
this = transpose(m) . |
public double[][] m_data
public PdMatrix()
public PdMatrix(int aSize)
public PdMatrix(int iSize, int jSize)
public PdMatrix(double[][] x)
public java.lang.Object clone()
copyNew(PdMatrix)
.clone
in class java.lang.Object
copyNew(PdMatrix)
public static PdMatrix copyNew(PdMatrix mat)
public static boolean copy(PdMatrix[] dataDest, int destInd, PdMatrix[] dataSrc, int srcInd, int size)
public void set(double[][] x)
public int getNumRows()
getNumRows
in interface PdMatrixIf
public int getNumCols()
getNumCols
in interface PdMatrixIf
public int getISize()
public int getJSize()
public int getSize()
public void setSize(int size)
public void setSize(int iSize, int jSize)
public double[][] getEntries()
public double getEntry(int i, int j)
getEntry
in interface PdMatrixIf
public void setEntry(int i, int j, double value)
setEntry
in interface PdMatrixIf
public void addEntry(int i, int j, double value)
addEntry
in interface PdMatrixIf
public boolean isSquare()
isSquare
in interface PdMatrixIf
public void setIdentity()
public void setConstant(double aValue)
public void clear()
clear
in interface PdMatrixIf
public void setDiagonal(PdVector diag)
diag
- Vector with diagonal componentspublic PdVector getRow(int aRow)
public void setRow(int aRow, PdVector aVector)
public PdVector getColumn(int aColumn)
public void setColumn(int aColumn, PdVector aVector)
public void setRows(PdVector[] aVector)
public void setColumns(PdVector[] aVector)
public void add(PdMatrix m)
public void add(PdMatrix m1, PdMatrix m2)
public void sub(PdMatrix m)
public void sub(PdMatrix m1, PdMatrix m2)
public void copy(PdMatrix m)
public void multScalar(double scalar)
multScalar
in interface PdMatrixIf
public void multScalar(PdMatrix m, double scalar)
public double det()
public double det33()
public void leftMult(PdMatrix m, int size)
m
- parameter matrixsize
- size of square sub matrix affected within this.public void leftMult(PdMatrix m)
this = m*this
.
Size of 'this' does not change.public void rightMult(PdMatrix m, int size)
m
- parameter matrixsize
- size of square sub matrix affected within this.public void rightMult(PdMatrix m)
this = this*m
.
Size of 'this' does not change.public void mult(PdMatrix mat1, PdMatrix mat2)
this = mat1*mat2
.
Size of 'this' is adjusted to have number of rows equal to first factor
and number of columns equal to second factor.
public PdVector leftMultMatrix(PdVector out, PdVector in)
out = this*in.
.
Matrix need not be square.
Input vector must have same size as number of columns of this matrix.
Method modifies size of output vector to number of rows of this matrix.
If output vector is null then it is created.
Method calls PdVector.leftMultMatrix(PdMatrix, PdVector)
.
leftMultMatrix
in interface PdMatrixIf
public PdVector rightMultMatrix(PdVector out, PdVector in)
out = in*this.
.
Matrix need not be square.
Input vector must have same size as number of rows of this matrix.
Method modifies size of output vector to number of columns of this matrix.
If output vector is null then it is created.
Method calls PdVector.rightMultMatrix(PdVector, PdMatrix)
.
rightMultMatrix
in interface PdMatrixIf
public void transpose()
this = transpose(this)
.transpose
in interface PdMatrixIf
public void transpose(PdMatrix m)
this = transpose(m)
.public boolean invert()
this = inverse(this)
.public boolean invert(PdMatrix m)
this = inverse(m)
.false
if error occurred, and if arg is singular call this.setIdentity().public boolean invertTopLeft(PdMatrix m, int aSubSize)
public boolean invert34(PdMatrix m)
public boolean adjoint(PdVector v)
this = v * v^t
unsing adjoint(v, v).public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toShortString()
public static PdMatrix expandComponents(PdMatrix mat, int dim)
public void blend(double a, PdMatrix u, double b, PdMatrix v, double c, PdMatrix w)
this = u*a + v*b + w*c
.
If the matrix 'this' is empty, the size of this is adjusted
equal to the size of the matrix u.
Otherwise interpolation is done up to length of result vector.a
- weight of first matrixu
- first matrixb
- weight of second matrixv
- second matrixc
- weight of third matrixw
- third matrixpublic void blend(PdBary bary, PdMatrix u, PdMatrix v, PdMatrix w)
this = u*bary.getEntry(0) + v*bary.getEntry(1) + w*bary.getEntry(2)
.
If the matrix 'this' is empty, the size of this is adjusted
equal to the size of the matrix u.
Otherwise interpolation is done up to length of result vector.bary
- barycentric weights of three matricesu
- first matrixv
- second matrixw
- third matrixpublic double multQuadratic(PdVector left, PdVector right)
left^T*this*right
. The matrix is interpreted as a quadratic form.multQuadratic
in interface PdMatrixIf
left
- The left argument.right
- The right argument.left^T*this*right
."