def eigh(a, b=None, lower=True, eigvals_only=False, overwrite_a=False,<EOL>overwrite_b=False, turbo=True, eigvals=None, type=<NUM_LIT:1>,<EOL>check_finite=True):
if check_finite:<EOL><INDENT>a1 = asarray_chkfinite(a)<EOL><DEDENT>else:<EOL><INDENT>a1 = asarray(a)<EOL><DEDENT>if len(a1.shape) != <NUM_LIT:2> or a1.shape[<NUM_LIT:0>] != a1.shape[<NUM_LIT:1>]:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>overwrite_a = overwrite_a or (_datacopied(a1, a))<EOL>if iscomplexobj(a1):<EOL><INDENT>cplx = True<EOL><DEDENT>else:<EOL><INDENT>cplx = False<EOL><DEDENT>if b is not None:<EOL><INDENT>if check_finite:<EOL><INDENT>b1 = asarray_chkfinite(b)<EOL><DEDENT>else:<EOL><INDENT>b1 = asarray(b)<EOL><DEDENT>overwrite_b = overwrite_b or _datacopied(b1, b)<EOL>if len(b1.shape) != <NUM_LIT:2> or b1.shape[<NUM_LIT:0>] != b1.shape[<NUM_LIT:1>]:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if b1.shape != a1.shape:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % (str(b1.shape), str(a1.shape)))<EOL><DEDENT>if iscomplexobj(b1):<EOL><INDENT>cplx = True<EOL><DEDENT>else:<EOL><INDENT>cplx = cplx or False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>b1 = None<EOL><DEDENT>_job = (eigvals_only and '<STR_LIT:N>') or '<STR_LIT>'<EOL>if eigvals is not None:<EOL><INDENT>lo, hi = eigvals<EOL>if lo < <NUM_LIT:0> or hi >= a1.shape[<NUM_LIT:0>]:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % (<NUM_LIT:0>, a1.shape[<NUM_LIT:0>]-<NUM_LIT:1>))<EOL><DEDENT>lo += <NUM_LIT:1><EOL>hi += <NUM_LIT:1><EOL>eigvals = (lo, hi)<EOL><DEDENT>if lower:<EOL><INDENT>uplo = '<STR_LIT:L>'<EOL><DEDENT>else:<EOL><INDENT>uplo = '<STR_LIT>'<EOL><DEDENT>if cplx:<EOL><INDENT>pfx = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>pfx = '<STR_LIT>'<EOL><DEDENT>if b1 is None:<EOL><INDENT>(evr,) = get_lapack_funcs((pfx+'<STR_LIT>',), (a1,))<EOL>if eigvals is None:<EOL><INDENT>w, v, info = evr(a1, uplo=uplo, jobz=_job, range="<STR_LIT:A>", il=<NUM_LIT:1>,<EOL>iu=a1.shape[<NUM_LIT:0>], overwrite_a=overwrite_a)<EOL><DEDENT>else:<EOL><INDENT>(lo, hi) = eigvals<EOL>w_tot, v, info = evr(a1, uplo=uplo, jobz=_job, range="<STR_LIT:I>",<EOL>il=lo, iu=hi, overwrite_a=overwrite_a)<EOL>w = w_tot[<NUM_LIT:0>:hi-lo+<NUM_LIT:1>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if eigvals is not None:<EOL><INDENT>(gvx,) = get_lapack_funcs((pfx+'<STR_LIT>',), (a1,b1))<EOL>(lo, hi) = eigvals<EOL>w_tot, v, ifail, info = gvx(a1, b1, uplo=uplo, iu=hi,<EOL>itype=type,jobz=_job, il=lo,<EOL>overwrite_a=overwrite_a,<EOL>overwrite_b=overwrite_b)<EOL>w = w_tot[<NUM_LIT:0>:hi-lo+<NUM_LIT:1>]<EOL><DEDENT>elif turbo:<EOL><INDENT>(gvd,) = get_lapack_funcs((pfx+'<STR_LIT>',), (a1,b1))<EOL>v, w, info = gvd(a1, b1, uplo=uplo, itype=type, jobz=_job,<EOL>overwrite_a=overwrite_a,<EOL>overwrite_b=overwrite_b)<EOL><DEDENT>else:<EOL><INDENT>(gv,) = get_lapack_funcs((pfx+'<STR_LIT>',), (a1,b1))<EOL>v, w, info = gv(a1, b1, uplo=uplo, itype=type, jobz=_job,<EOL>overwrite_a=overwrite_a,<EOL>overwrite_b=overwrite_b)<EOL><DEDENT><DEDENT>if info == <NUM_LIT:0>:<EOL><INDENT>if eigvals_only:<EOL><INDENT>return w<EOL><DEDENT>else:<EOL><INDENT>return w, v<EOL><DEDENT><DEDENT>elif info < <NUM_LIT:0>:<EOL><INDENT>raise LinAlgError("<STR_LIT>"<EOL>"<STR_LIT>" % (-info))<EOL><DEDENT>elif info > <NUM_LIT:0> and b1 is None:<EOL><INDENT>raise LinAlgError("<STR_LIT>")<EOL><DEDENT>elif info > <NUM_LIT:0> and info <= b1.shape[<NUM_LIT:0>]:<EOL><INDENT>if eigvals is not None:<EOL><INDENT>raise LinAlgError("<STR_LIT>"<EOL>"<STR_LIT>" % nonzero(ifail)-<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>raise LinAlgError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % info)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise LinAlgError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (info-b1.shape[<NUM_LIT:0>]))<EOL><DEDENT>
Solve an ordinary or generalized eigenvalue problem for a complex
Hermitian or real symmetric matrix.

Find eigenvalues w and optionally eigenvectors v of matrix `a`, where
`b` is positive definite::

                  a v[:,i] = w[i] b v[:,i]
    v[i,:].conj() a v[:,i] = w[i]
    v[i,:].conj() b v[:,i] = 1

Parameters
----------
a : (M, M) array_like
    A complex Hermitian or real symmetric matrix whose eigenvalues and
    eigenvectors will be computed.
b : (M, M) array_like, optional
    A complex Hermitian or real symmetric definite positive matrix in.
    If omitted, identity matrix is assumed.
lower : bool, optional
    Whether the pertinent array data is taken from the lower or upper
    triangle of `a`. (Default: lower)
eigvals_only : bool, optional
    Whether to calculate only eigenvalues and no eigenvectors.
    (Default: both are calculated)
turbo : bool, optional
    Use divide and conquer algorithm (faster but expensive in memory,
    only for generalized eigenvalue problem and if eigvals=None)
eigvals : tuple (lo, hi), optional
    Indexes of the smallest and largest (in ascending order) eigenvalues
    and corresponding eigenvectors to be returned: 0 <= lo <= hi <= M-1.
    If omitted, all eigenvalues and eigenvectors are returned.
type : int, optional
    Specifies the problem type to be solved:

       type = 1: a   v[:,i] = w[i] b v[:,i]

       type = 2: a b v[:,i] = w[i]   v[:,i]

       type = 3: b a v[:,i] = w[i]   v[:,i]
overwrite_a : bool, optional
    Whether to overwrite data in `a` (may improve performance)
overwrite_b : bool, optional
    Whether to overwrite data in `b` (may improve performance)
check_finite : boolean, optional
    Whether to check that the input matrices contain only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
w : (N,) float ndarray
    The N (1<=N<=M) selected eigenvalues, in ascending order, each
    repeated according to its multiplicity.
v : (M, N) complex ndarray
    (if eigvals_only == False)

    The normalized selected eigenvector corresponding to the
    eigenvalue w[i] is the column v[:,i].

    Normalization:

        type 1 and 3: v.conj() a      v  = w

        type 2: inv(v).conj() a  inv(v) = w

        type = 1 or 2: v.conj() b      v  = I

        type = 3: v.conj() inv(b) v  = I

Raises
------
LinAlgError :
    If eigenvalue computation does not converge,
    an error occurred, or b matrix is not definite positive. Note that
    if input matrices are not symmetric or hermitian, no error is reported
    but results will be wrong.

See Also
--------
eig : eigenvalues and right eigenvectors for non-symmetric arrays