#NEWLINE# def solveh_banded( ab , b , overwrite_ab = False , overwrite_b = False , lower = False , check_finite = True ) : #NEWLINE# #INDENT# '\n    Solve equation a x = b. a is Hermitian positive-definite banded matrix.\n\n    The matrix a is stored in `ab` either in lower diagonal or upper\n    diagonal ordered form:\n\n        ab[u + i - j, j] == a[i,j]        (if upper form; i <= j)\n        ab[    i - j, j] == a[i,j]        (if lower form; i >= j)\n\n    Example of `ab` (shape of a is (6, 6), `u` =2)::\n\n        upper form:\n        *   *   a02 a13 a24 a35\n        *   a01 a12 a23 a34 a45\n        a00 a11 a22 a33 a44 a55\n\n        lower form:\n        a00 a11 a22 a33 a44 a55\n        a10 a21 a32 a43 a54 *\n        a20 a31 a42 a53 *   *\n\n    Cells marked with * are not used.\n\n    Parameters\n    ----------\n    ab : (`u` + 1, M) array_like\n        Banded matrix\n    b : (M,) or (M, K) array_like\n        Right-hand side\n    overwrite_ab : bool, optional\n        Discard data in `ab` (may enhance performance)\n    overwrite_b : bool, optional\n        Discard data in `b` (may enhance performance)\n    lower : bool, optional\n        Is the matrix in the lower form. (Default is upper form)\n    check_finite : bool, optional\n        Whether to check that the input matrices contain only finite numbers.\n        Disabling may give a performance gain, but may result in problems\n        (crashes, non-termination) if the inputs do contain infinities or NaNs.\n\n    Returns\n    -------\n    x : (M,) or (M, K) ndarray\n        The solution to the system a x = b.  Shape of return matches shape\n        of `b`.\n\n    ' #NEWLINE# a1 = _asarray_validated ( ab , check_finite = check_finite ) #NEWLINE# b1 = _asarray_validated ( b , check_finite = check_finite ) #NEWLINE# if ( a1 . shape [ ( - 1 ) ] != b1 . shape [ 0 ] ) : #NEWLINE# #INDENT# raise ValueError ( 'shapes of ab and b are not compatible.' ) #NEWLINE# #UNINDENT# overwrite_b = ( overwrite_b or _datacopied ( b1 , b ) ) #NEWLINE# overwrite_ab = ( overwrite_ab or _datacopied ( a1 , ab ) ) #NEWLINE# if ( a1 . shape [ 0 ] == 2 ) : #NEWLINE# #INDENT# ( ptsv , ) = get_lapack_funcs ( ( 'ptsv' , ) , ( a1 , b1 ) ) #NEWLINE# if lower : #NEWLINE# #INDENT# d = a1 [ 0 , : ] . real #NEWLINE# e = a1 [ 1 , : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# d = a1 [ 1 , : ] . real #NEWLINE# e = a1 [ 0 , 1 : ] . conj ( ) #NEWLINE# #UNINDENT# ( d , du , x , info ) = ptsv ( d , e , b1 , overwrite_ab , overwrite_ab , overwrite_b ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( pbsv , ) = get_lapack_funcs ( ( 'pbsv' , ) , ( a1 , b1 ) ) #NEWLINE# ( c , x , info ) = pbsv ( a1 , b1 , lower = lower , overwrite_ab = overwrite_ab , overwrite_b = overwrite_b ) #NEWLINE# #UNINDENT# if ( info > 0 ) : #NEWLINE# #INDENT# raise LinAlgError ( ( '%d-th leading minor not positive definite' % info ) ) #NEWLINE# #UNINDENT# if ( info < 0 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'illegal value in %d-th argument of internal pbsv' % ( - info ) ) ) #NEWLINE# #UNINDENT# return x