bundles / scipy 1.17.1 / scipy / linalg / _decomp_ldl / _ldl_sanitize_ipiv
function
scipy.linalg._decomp_ldl:_ldl_sanitize_ipiv
Signature
def _ldl_sanitize_ipiv ( a , lower = True ) Summary
This helper function takes the rather strangely encoded permutation array returned by the LAPACK routines ?(HE/SY)TRF and converts it into regularized permutation and diagonal pivot size format.
Extended Summary
Since FORTRAN uses 1-indexing and LAPACK uses different start points for upper and lower formats there are certain offsets in the indices used below.
Let's assume a result where the matrix is 6x6 and there are two 2x2 and two 1x1 blocks reported by the routine. To ease the coding efforts, we still populate a 6-sized array and fill zeros as the following
pivots = [2, 0, 2, 0, 1, 1]This denotes a diagonal matrix of the form
[x x ] [x x ] [ x x ] [ x x ] [ x ] [ x]
In other words, we write 2 when the 2x2 block is first encountered and automatically write 0 to the next entry and skip the next spin of the loop. Thus, a separate counter or array appends to keep track of block sizes are avoided. If needed, zeros can be filtered out later without losing the block structure.
Parameters
a: ndarrayThe permutation array ipiv returned by LAPACK
lower: bool, optionalThe switch to select whether upper or lower triangle is chosen in the LAPACK call.
Returns
swap_: ndarrayThe array that defines the row/column swap operations. For example, if row two is swapped with row four, the result is [0, 3, 2, 3].
pivots: ndarrayThe array that defines the block diagonal structure as given above.
Aliases
-
scipy.linalg._decomp_ldl._ldl_sanitize_ipiv