pentapy.tools.shift_banded

pentapy.tools.shift_banded(mat, up=2, low=2, col_to_row=True, copy=True)[source]

Shift rows of a banded matrix.

Either from column-wise to row-wise storage or vice versa.

The Matrix has to be given as a flattend matrix. Either in 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       ]]

Then use:

col_to_row=True

Or 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]]]

Then use:

col_to_row=False

Dup1 and Dup2 are the first and second upper minor-diagonals and Dlow1 resp. Dlow2 are the lower ones. The number of upper and lower minor-diagonals can be altered.

Parameters:
  • mat (numpy.ndarray) – The Matrix or the flattened Version of the pentadiagonal matrix.

  • up (int) – The number of upper minor-diagonals. Default: 2

  • low (int) – The number of lower minor-diagonals. Default: 2

  • col_to_row (bool, optional) – Shift from column-wise to row-wise storage or vice versa. Default: True

  • copy (bool, optional) – Copy the input matrix or overwrite it. Default: True

Returns:

Shifted bandend matrix

Return type:

numpy.ndarray