finesse.densematrix module
- class finesse.densematrix.DenseMatrix(name)[source]
Bases:
objectExamples
Create a matrix with memory views of different submatrices for giving to components:
> DM = DenseMatrix(“abc”) > > DM.declare_equations(5, 0, ‘a’) > DM.declare_equations(5, 1, ‘b’) > DM.declare_equations(5, 2, ‘c’) > DM.declare_equations(2, 3, ‘d’) > > v1 = DM.declare_submatrix_view(0, 1, ‘b’) > v2 = DM.declare_subdiagonal_view(0, 2, ‘b’) > v3 = DM.declare_submatrix_view(3, 1, ‘b’) > > DM.construct() > > v1[:] = 1 > v2[:] = 0.5 > v3[:] = 0.75
- class SubMatrixView(Matrix, _from, _to, name, mtype)[source]
Bases:
objectThis class represents a sub-matrix view of a CCS sparse matrix. This allows code to access and set values without worrying about the underlying sparse compression being used. Although so far this is just for CCS formats.
This object will get a view of a n-by-m sub-matrix starting at index (i,j). The values of his matrix will be set initially to the coordinates.
- add_block(Neqs, index, name)[source]
Parameters
- NeqsPy_ssize_t
Number of equations this submatrix represents
- _indexlong
Subcolumn index
- nameunicode
Name used to indentify this coupling in the matrix for debugging
- construct()[source]
Constructing the matrix involves taking the metadata submatrix positions throughout the matrix and allocating the memory and building the various CCS matrix structures.
After this the matrix can be populated and sovled.
- declare_equations(Neqs, index, name)[source]
Adds a submatrix to the matrix along its diagonal. This defines what equations exist in the matrix, the submatrix values cannot be changed after this, they are always 1 Before other submatrices can be added to the matrix the diagonal must be specfied and how many equations it represents.
Parameters
- NeqsPy_ssize_t
Number of equations this submatrix represents
- _indexlong
Subcolumn index
- nameunicode
Name used to indentify this coupling in the matrix for debugging
- solve(transpose=False, conjugate=False)[source]
Solve the matrix with options for transposing and conjugating.
If transpose is False, solves the linear system \(Ax = b\) using the
SymbolicandNumericobjects stored by this class.Otherwise, solves the linear system \(A^T x = b\) or \(A^H x = b\). The conjugate option is zero for \(A^T x = b\) or non-zero for \(A^H x = b\).
Parameters
- transposebool
Flag determining whether to solve the transpose of the matrix.
- conjugatebool
Flag determining whether to solve \(A^T x =b\) or \(A^H x = b\) for the transposed linear system.
Returns
- outnp.ndarray
The (negative) solution vector.