pentapy.core¶
The core module of pentapy.
The following functions are provided
solve (mat, rhs[, is_flat, index_row_wise, …]) |
Solver for a pentadiagonal system. |
-
pentapy.core.
solve
(mat, rhs, is_flat=False, index_row_wise=True, solver=1)[source]¶ Solver for a pentadiagonal system.
The matrix can be given as a full n x n matrix or as a flattend one. The flattend matrix can be given in a row-wise flattend form:
[[Dup2[0] Dup2[1] Dup2[2] ... Dup2[N-2] 0 0 ] [Dup1[0] Dup1[1] Dup1[2] ... Dup1[N-2] Dup1[N-1] 0 ] [Diag[0] Diag[1] Diag[2] ... Diag[N-2] Diag[N-1] Diag[N] ] [0 Dlow1[1] Dlow1[2] ... Dlow1[N-2] Dlow1[N-1] Dlow1[N]] [0 0 Dlow2[2] ... Dlow2[N-2] Dlow2[N-2] Dlow2[N]]]
Or a column-wise flattend form:
[[0 0 Dup2[2] ... Dup2[N-2] Dup2[N-1] Dup2[N] ] [0 Dup1[1] Dup1[2] ... Dup1[N-2] Dup1[N-1] Dup1[N] ] [Diag[0] Diag[1] Diag[2] ... Diag[N-2] Diag[N-1] Diag[N] ] [Dlow1[0] Dlow1[1] Dlow1[2] ... Dlow1[N-2] Dlow1[N-1] 0 ] [Dlow2[0] Dlow2[1] Dlow2[2] ... Dlow2[N-2] 0 0 ]]
Dup1 and Dup2 are the first and second upper minor-diagonals and Dlow1 resp. Dlow2 are the lower ones. If you provide a column-wise flattend matrix, you have to set:
index_row_wise=False
Parameters: - mat (
numpy.ndarray
) – The Matrix or the flattened Version of the pentadiagonal matrix. - rhs (
numpy.ndarray
) – The right hand side of the equation system. - is_flat (
bool
, optional) – State if the matrix is already flattend. Default:False
- index_row_wise (
bool
, optional) – State if the flattend matrix is row-wise flattend. Default:True
- solver (
int
orstr
, optional) –Which solver should be used. The following are provided:
[1, "1", "PTRANS-I"]
: The PTRANS-I algorithm[2, "2", "PTRANS-II"]
: The PTRANS-II algorithm[3, "3", "lapack", "solve_banded"]
: scipy.linalg.solve_banded[4, "4", "spsolve"]
: The scipy sparse solver without umf_pack[5, "5", "spsolve_umf", "umf", "umf_pack"]
: The scipy sparse solver with umf_pack
Default:
1
Returns: result – Solution of the equation system
Return type: - mat (