public class PnSparseMatrix extends PsObject implements PdMatrixIf
Modifier and Type | Field and Description |
---|---|
static boolean |
USE_LARGER_BUFFER
Flag, whether the buffer should enlarged dynamically.
|
HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
Constructor and Description |
---|
PnSparseMatrix()
Constructor.
|
PnSparseMatrix(int iSize,
int jSize)
Constructor with initial matrix sizes.
|
PnSparseMatrix(int iSize,
int jSize,
int bufferSize)
Constructor with initial matrix sizes and buffer size.
|
PnSparseMatrix(PdMatrix m)
Create a sparse Matrix from a PdMatrix.
|
Modifier and Type | Method and Description |
---|---|
void |
add(PnSparseMatrix m)
Add another sparse matrix to this matrix.
|
void |
add(PnSparseMatrix m1,
PnSparseMatrix m2)
Set this = m1+m2.
|
void |
addDiagonal(double d)
Add the given value to every diagonal element of the matrix.
|
void |
addDiagonal(PdVector diag)
Add a given diagonal matrix to this.
|
void |
addEntry(int i,
int j,
double value)
Add value to the entry (i, j) of this matrix.
|
void |
appendEntry(int i,
int j,
double value)
Appends an entry to row i.
|
void |
clear()
Set all elements of the matrix to 0.
|
void |
clearRow(int rowInd)
Set all entries in specified row to 0.
|
void |
compress()
Compress this stiff matrix that only values not equal zero remain.
|
void |
concatMatrices(PnSparseMatrix ma,
PnSparseMatrix mb,
PnSparseMatrix mc,
PnSparseMatrix md)
Concatenates 4 matrices to a bigger one of the form
this = ((ma, mb), (mc, md)).
|
void |
copy(PnSparseMatrix A)
Copy the sparse matrix A into this.
|
void |
deleteColumn(int col)
Delete the col-th row from the sparse matrix.
|
void |
deleteRow(int i)
Delete the i-th row from the sparse matrix.
|
int |
getColIndex(int i,
int j)
Get the index of the column for the j.th entry in the i.th row.
|
PiVector[] |
getColIndices()
Get an array with the column indices of the entries in the matrix.
|
PiVector |
getColIndices(int i)
Get the column indices of the i.th row of the matrix.
|
int |
getDiagIndex(int n)
Get the index of the n-th diagonal element.
|
PdVector[] |
getEntries()
Get the array with all non-zero entries of the matrix.
|
PdVector |
getEntries(int i)
Get the i.th row of the matrix.
|
double |
getEntry(int i,
int j)
Get the (i,j) entry of the matrix.
|
double |
getEntrySparse(int i,
int jInd)
Get the entry in row i at position jInd in the stiffness array.
|
int |
getIndex(int aLine,
int anIndex)
For given component s[aLine][aColumn] of the full matrix s this method finds
the position in the index vector m_sindx[aLine] of the row aLine which
refers to the full matrix component.
|
int |
getNumCols()
Get number of columns of full matrix.
|
PiVector |
getNumEntries()
Get the number of non-zero entries for all rows.
|
int |
getNumEntries(int i)
Get the number of non-zero entries in the i.th row.
|
int |
getNumRows()
Get number of rows of full matrix.
|
boolean |
isSquare()
Whether numRows == numColumns.
|
PdVector |
leftMultMatrix(PdVector out,
PdVector in)
Multiply this matrix with vector and fill output vector,
out = this*in. |
PdVector |
leftMultVector(PdVector in,
PdVector out)
Deprecated.
|
PdVector |
leftMultVector(PdVector in,
PdVector out,
int dim)
Compute out=in*smat.
|
static PdVector |
leftMultVector(PnSparseMatrix smat,
PdVector in,
PdVector out)
Compute out=in*smat.
|
static PdVector |
leftMultVector(PnSparseMatrix smat,
PdVector in,
PdVector out,
int dim)
Compute out=in*smat.
|
static PnSparseMatrix |
multMatrices(PnSparseMatrix left,
PnSparseMatrix right,
PnSparseMatrix out)
Multiply two sparse matrices, out = left.right.
|
double |
multQuadratic(PdVector left,
PdVector right)
Compute left^T*this*right.
|
void |
multScalar(double scalar)
Multiply the matrix by a scalar value.
|
static PnSparseMatrix |
multScalar(PnSparseMatrix smat,
double scalar)
Multiply each entry of the matrix by a scalar value.
|
void |
removeZeros(double eps)
Remove entries which are 0 up to a given tolerance.
|
PdVector |
rightMultMatrix(PdVector out,
PdVector in)
Multiply this matrix with vector and fill output vector,
out = in*this. |
PdVector |
rightMultVector(PdVector in,
PdVector out)
Deprecated.
|
PdVector |
rightMultVector(PdVector in,
PdVector out,
int dim)
Compute out=smat*in.
|
static PdVector |
rightMultVector(PnSparseMatrix smat,
PdVector in,
PdVector out)
Compute out=smat*in.
|
static PdVector |
rightMultVector(PnSparseMatrix smat,
PdVector in,
PdVector out,
int dim)
Compute out=smat*in.
|
void |
setEntry(int i,
int j,
double value)
Set the entry (i, j) to a specific value.
|
void |
setEntrySparse(int i,
int jInd,
double value)
Set the entry in row i at position jInd in the stiffness array.
|
void |
setNumEntries(int i,
int numEntries)
Set number of non-zero entries in row i.
|
void |
setRow(int rowInd,
int numEntries,
PiVector colIndex,
PdVector stiff)
Set a row of the matrix.
|
void |
setSize(int size)
Set number of rows and number of columns to size.
|
void |
setSize(int iSize,
int jSize)
Set size of the matrix.
|
void |
setSize(int numRows,
int numCols,
int bufferSize)
Set size and buffer of the matrix.
|
void |
sortEntries()
Sort the sparse arrays (representing the rows) by their column indices.
|
PdMatrix |
toPdMatrix()
Convert the sparse matrix into a dense PdMatrix.
|
java.lang.String |
toShortString()
Create a full matrix and print all components in a short multi-line string representation.
|
java.lang.String |
toString()
Create a full matrix and print all components in a multi-line string representation.
|
void |
transpose()
Transpose this sparse matrix.
|
void |
transpose(PnSparseMatrix transpose)
Transpose a sparse matrix.
|
PnSparseMatrix |
transposeNew()
Transpose a sparse matrix.
|
static PnSparseMatrix |
transposeNew(PnSparseMatrix pm)
Transpose the sparse matrix.
|
void |
validate()
Ensures, that the matrix is in a valid state.
|
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, init, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, update, updatePanels
public static final boolean USE_LARGER_BUFFER
public PnSparseMatrix()
public PnSparseMatrix(int iSize, int jSize)
public PnSparseMatrix(int iSize, int jSize, int bufferSize)
public PnSparseMatrix(PdMatrix m)
public int getNumRows()
getNumRows
in interface PdMatrixIf
public int getNumCols()
getNumCols
in interface PdMatrixIf
public void setSize(int iSize, int jSize)
public void setSize(int numRows, int numCols, int bufferSize)
public void setSize(int size)
public void setNumEntries(int i, int numEntries)
public PdVector[] getEntries()
public PdVector getEntries(int i)
public double getEntrySparse(int i, int jInd)
public double getEntry(int i, int j)
getEntry
in interface PdMatrixIf
public PiVector getNumEntries()
public int getNumEntries(int i)
public PiVector[] getColIndices()
public PiVector getColIndices(int i)
public int getColIndex(int i, int j)
public void setRow(int rowInd, int numEntries, PiVector colIndex, PdVector stiff)
public boolean isSquare()
isSquare
in interface PdMatrixIf
public void setEntry(int i, int j, double value)
setEntry
in interface PdMatrixIf
public void setEntrySparse(int i, int jInd, double value)
public void addEntry(int i, int j, double value)
addEntry
in interface PdMatrixIf
public void copy(PnSparseMatrix A)
A
- public void compress()
public PdMatrix toPdMatrix()
public int getIndex(int aLine, int anIndex)
public void appendEntry(int i, int j, double value)
public java.lang.String toString()
public java.lang.String toShortString()
public PdVector rightMultVector(PdVector in, PdVector out, int dim)
public PdVector rightMultVector(PdVector in, PdVector out)
public PdVector leftMultMatrix(PdVector out, PdVector in)
PdMatrixIf
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.leftMultMatrix
in interface PdMatrixIf
public static PdVector rightMultVector(PnSparseMatrix smat, PdVector in, PdVector out, int dim)
public static PdVector rightMultVector(PnSparseMatrix smat, PdVector in, PdVector out)
public static PdVector leftMultVector(PnSparseMatrix smat, PdVector in, PdVector out, int dim)
public PdVector leftMultVector(PdVector in, PdVector out, int dim)
public PdVector leftMultVector(PdVector in, PdVector out)
public PdVector rightMultMatrix(PdVector out, PdVector in)
PdMatrixIf
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.rightMultMatrix
in interface PdMatrixIf
public static PdVector leftMultVector(PnSparseMatrix smat, PdVector in, PdVector out)
public int getDiagIndex(int n)
n
- public PnSparseMatrix transposeNew()
public void transpose(PnSparseMatrix transpose)
transpose
- Matrix to be transposed.public void transpose()
transpose
in interface PdMatrixIf
public static PnSparseMatrix multMatrices(PnSparseMatrix left, PnSparseMatrix right, PnSparseMatrix out)
public void validate()
public void removeZeros(double eps)
public static PnSparseMatrix transposeNew(PnSparseMatrix pm)
pm
- the sparse matrix to transposepublic void add(PnSparseMatrix m)
public void add(PnSparseMatrix m1, PnSparseMatrix m2)
public void addDiagonal(double d)
public void addDiagonal(PdVector diag)
diag
- Diagonal entries of the matrix.public void multScalar(double scalar)
multScalar
in interface PdMatrixIf
public void clear()
clear
in interface PdMatrixIf
public void concatMatrices(PnSparseMatrix ma, PnSparseMatrix mb, PnSparseMatrix mc, PnSparseMatrix md)
public void deleteRow(int i)
i
- Row index.public void deleteColumn(int col)
col
- Row index.public double multQuadratic(PdVector left, PdVector right)
multQuadratic
in interface PdMatrixIf
left
- The left argument.right
- The right argument.public static PnSparseMatrix multScalar(PnSparseMatrix smat, double scalar)
public void sortEntries()
public void clearRow(int rowInd)
"