pentapy Tutorials¶
In the following you will find Tutorials on how to use pentapy.
Introduction: Solving a pentadiagonal system¶
Pentadiagonal systems arise in many areas of science and engineering, for example in solving differential equations with a finite difference sceme.
Theoretical Background¶
A pentadiagonal system is given by the equation: , where is a quadratic matrix given by:
The aim is now, to solve this equation for .
Memory efficient storage¶
To store a pentadiagonal matrix memory efficient, there are two options:
row-wise storage:
Here we see, that the numbering in the above given matrix was aiming at the row-wise storage. That means, the indices were taken from the row-indices of the entries.
column-wise storage:
The numbering here is a bit confusing, but in the column-wise storage, all entries written in one column were in the same column in the original matrix.
Solving the system using pentapy¶
To solve the system you can either provide as a full matrix or as a flattened matrix in row-wise resp. col-wise flattened form.
If M is a full matrix, you call the following:
import pentapy as pp
M = ... # your matrix
Y = ... # your right hand side
X = pp.solve(M, Y)
If M is flattend in row-wise order you have to set the keyword argument is_flat=True
:
import pentapy as pp
M = ... # your flattened matrix
Y = ... # your right hand side
X = pp.solve(M, Y, is_flat=True)
If you got a col-wise flattend matrix you have to set index_row_wise=False
:
X = pp.solve(M, Y, is_flat=True, index_row_wise=False)
Tools¶
pentapy provides some tools to convert a pentadiagonal matrix.
|
Get indices for the main or minor diagonals of a matrix. |
|
Shift rows of a banded matrix. |
|
Create a banded matrix from a given quadratic Matrix. |
|
Create a (n x n) Matrix from a given banded matrix. |