neulab/docprompting-conala huggingface dataset:
numpy.lib.stride_tricks.as_strided   lib.stride_tricks.as_strided(x, shape=None, strides=None, subok=False, writeable=True)[source]
 
Create a view into the array with the given shape and strides.  Warning This function has to be used with extreme care, see notes.   Parameters 
 
xndarray


Array to create a new.  
shapesequence of int, optional


The shape of the new array. Defaults to x.shape.  
stridessequence of int, optional


The strides of the new array. Defaults to x.strides.  
subokbool, optional


 New in version 1.10.  If True, subclasses are preserved.  
writeablebool, optional


 New in version 1.12.  If set to False, the returned array will always be readonly. Otherwise it will be writable if the original array was. It is advisable to set this to False if possible (see Notes).    Returns 
 
viewndarray

    See also  broadcast_to

broadcast an array to a given shape.  reshape

reshape an array.  lib.stride_tricks.sliding_window_view

userfriendly and safe function for the creation of sliding window views.    Notes as_strided creates a view into the array given the exact strides and shape. This means it manipulates the internal data structure of ndarray and, if done incorrectly, the array elements can point to invalid memory and can corrupt results or crash your program. It is advisable to always use the original x.strides when calculating new strides to avoid reliance on a contiguous memory layout. Furthermore, arrays created with this function often contain self overlapping memory, so that two elements are identical. Vectorized write operations on such arrays will typically be unpredictable. They may even give different results for small, large, or transposed arrays. Since writing to these arrays has to be tested and done with great care, you may want to use writeable=False to avoid accidental write operations. For these reasons it is advisable to avoid as_strided when possible.
numpy.linalg.cholesky   linalg.cholesky(a)[source]
 
Cholesky decomposition. Return the Cholesky decomposition, L * L.H, of the square matrix a, where L is lower-triangular and .H is the conjugate transpose operator (which is the ordinary transpose if a is real-valued). a must be Hermitian (symmetric if real-valued) and positive-definite. No checking is performed to verify whether a is Hermitian or not. In addition, only the lower-triangular and diagonal elements of a are used. Only L is actually returned.  Parameters 
 
a(…, M, M) array_like


Hermitian (symmetric if all elements are real), positive-definite input matrix.    Returns 
 
L(…, M, M) array_like


Upper or lower-triangular Cholesky factor of a. Returns a matrix object if a is a matrix object.    Raises 
 LinAlgError

If the decomposition fails, for example, if a is not positive-definite.      See also  scipy.linalg.cholesky

Similar function in SciPy.  scipy.linalg.cholesky_banded

Cholesky decompose a banded Hermitian positive-definite matrix.  scipy.linalg.cho_factor

Cholesky decomposition of a matrix, to use in scipy.linalg.cho_solve.    Notes  New in version 1.8.0.  Broadcasting rules apply, see the numpy.linalg documentation for details. The Cholesky decomposition is often used as a fast way of solving  \[A \mathbf{x} = \mathbf{b}\] (when A is both Hermitian/symmetric and positive-definite). First, we solve for \(\mathbf{y}\) in  \[L \mathbf{y} = \mathbf{b},\] and then for \(\mathbf{x}\) in  \[L.H \mathbf{x} = \mathbf{y}.\] Examples >>> A = np.array([[1,-2j],[2j,5]])
>>> A
array([[ 1.+0.j, -0.-2.j],
       [ 0.+2.j,  5.+0.j]])
>>> L = np.linalg.cholesky(A)
>>> L
array([[1.+0.j, 0.+0.j],
       [0.+2.j, 1.+0.j]])
>>> np.dot(L, L.T.conj()) # verify that L * L.H = A
array([[1.+0.j, 0.-2.j],
       [0.+2.j, 5.+0.j]])
>>> A = [[1,-2j],[2j,5]] # what happens if A is only array_like?
>>> np.linalg.cholesky(A) # an ndarray object is returned
array([[1.+0.j, 0.+0.j],
       [0.+2.j, 1.+0.j]])
>>> # But a matrix object is returned if A is a matrix object
>>> np.linalg.cholesky(np.matrix(A))
matrix([[ 1.+0.j,  0.+0.j],
        [ 0.+2.j,  1.+0.j]])
numpy.linalg.cond   linalg.cond(x, p=None)[source]
 
Compute the condition number of a matrix. This function is capable of returning the condition number using one of seven different norms, depending on the value of p (see Parameters below).  Parameters 
 
x(…, M, N) array_like


The matrix whose condition number is sought.  
p{None, 1, -1, 2, -2, inf, -inf, ‘fro’}, optional


Order of the norm used in the condition number computation:   
p norm for matrices   
None 2-norm, computed directly using the SVD  
‘fro’ Frobenius norm  
inf max(sum(abs(x), axis=1))  
-inf min(sum(abs(x), axis=1))  
1 max(sum(abs(x), axis=0))  
-1 min(sum(abs(x), axis=0))  
2 2-norm (largest sing. value)  
-2 smallest singular value   inf means the numpy.inf object, and the Frobenius norm is the root-of-sum-of-squares norm.    Returns 
 
c{float, inf}


The condition number of the matrix. May be infinite.      See also  numpy.linalg.norm
  Notes The condition number of x is defined as the norm of x times the norm of the inverse of x [1]; the norm can be the usual L2-norm (root-of-sum-of-squares) or one of a number of other matrix norms. References  1 
G. Strang, Linear Algebra and Its Applications, Orlando, FL, Academic Press, Inc., 1980, pg. 285.   Examples >>> from numpy import linalg as LA
>>> a = np.array([[1, 0, -1], [0, 1, 0], [1, 0, 1]])
>>> a
array([[ 1,  0, -1],
       [ 0,  1,  0],
       [ 1,  0,  1]])
>>> LA.cond(a)
1.4142135623730951
>>> LA.cond(a, 'fro')
3.1622776601683795
>>> LA.cond(a, np.inf)
2.0
>>> LA.cond(a, -np.inf)
1.0
>>> LA.cond(a, 1)
2.0
>>> LA.cond(a, -1)
1.0
>>> LA.cond(a, 2)
1.4142135623730951
>>> LA.cond(a, -2)
0.70710678118654746 # may vary
>>> min(LA.svd(a, compute_uv=False))*min(LA.svd(LA.inv(a), compute_uv=False))
0.70710678118654746 # may vary
numpy.linalg.det   linalg.det(a)[source]
 
Compute the determinant of an array.  Parameters 
 
a(…, M, M) array_like


Input array to compute determinants for.    Returns 
 
det(…) array_like


Determinant of a.      See also  slogdet

Another way to represent the determinant, more suitable for large matrices where underflow/overflow may occur.  scipy.linalg.det

Similar function in SciPy.    Notes  New in version 1.8.0.  Broadcasting rules apply, see the numpy.linalg documentation for details. The determinant is computed via LU factorization using the LAPACK routine z/dgetrf. Examples The determinant of a 2-D array [[a, b], [c, d]] is ad - bc: >>> a = np.array([[1, 2], [3, 4]])
>>> np.linalg.det(a)
-2.0 # may vary
 Computing determinants for a stack of matrices: >>> a = np.array([ [[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]] ])
>>> a.shape
(3, 2, 2)
>>> np.linalg.det(a)
array([-2., -3., -8.])
numpy.linalg.eigvals   linalg.eigvals(a)[source]
 
Compute the eigenvalues of a general matrix. Main difference between eigvals and eig: the eigenvectors aren’t returned.  Parameters 
 
a(…, M, M) array_like


A complex- or real-valued matrix whose eigenvalues will be computed.    Returns 
 
w(…, M,) ndarray


The eigenvalues, each repeated according to its multiplicity. They are not necessarily ordered, nor are they necessarily real for real matrices.    Raises 
 LinAlgError

If the eigenvalue computation does not converge.      See also  eig

eigenvalues and right eigenvectors of general arrays  eigvalsh

eigenvalues of real symmetric or complex Hermitian (conjugate symmetric) arrays.  eigh

eigenvalues and eigenvectors of real symmetric or complex Hermitian (conjugate symmetric) arrays.  scipy.linalg.eigvals

Similar function in SciPy.    Notes  New in version 1.8.0.  Broadcasting rules apply, see the numpy.linalg documentation for details. This is implemented using the _geev LAPACK routines which compute the eigenvalues and eigenvectors of general square arrays. Examples Illustration, using the fact that the eigenvalues of a diagonal matrix are its diagonal elements, that multiplying a matrix on the left by an orthogonal matrix, Q, and on the right by Q.T (the transpose of Q), preserves the eigenvalues of the “middle” matrix. In other words, if Q is orthogonal, then Q * A * Q.T has the same eigenvalues as A: >>> from numpy import linalg as LA
>>> x = np.random.random()
>>> Q = np.array([[np.cos(x), -np.sin(x)], [np.sin(x), np.cos(x)]])
>>> LA.norm(Q[0, :]), LA.norm(Q[1, :]), np.dot(Q[0, :],Q[1, :])
(1.0, 1.0, 0.0)
 Now multiply a diagonal matrix by Q on one side and by Q.T on the other: >>> D = np.diag((-1,1))
>>> LA.eigvals(D)
array([-1.,  1.])
>>> A = np.dot(Q, D)
>>> A = np.dot(A, Q.T)
>>> LA.eigvals(A)
array([ 1., -1.]) # random
numpy.linalg.eigvalsh   linalg.eigvalsh(a, UPLO='L')[source]
 
Compute the eigenvalues of a complex Hermitian or real symmetric matrix. Main difference from eigh: the eigenvectors are not computed.  Parameters 
 
a(…, M, M) array_like


A complex- or real-valued matrix whose eigenvalues are to be computed.  
UPLO{‘L’, ‘U’}, optional


Specifies whether the calculation is done with the lower triangular part of a (‘L’, default) or the upper triangular part (‘U’). Irrespective of this value only the real parts of the diagonal will be considered in the computation to preserve the notion of a Hermitian matrix. It therefore follows that the imaginary part of the diagonal will always be treated as zero.    Returns 
 
w(…, M,) ndarray


The eigenvalues in ascending order, each repeated according to its multiplicity.    Raises 
 LinAlgError

If the eigenvalue computation does not converge.      See also  eigh

eigenvalues and eigenvectors of real symmetric or complex Hermitian (conjugate symmetric) arrays.  eigvals

eigenvalues of general real or complex arrays.  eig

eigenvalues and right eigenvectors of general real or complex arrays.  scipy.linalg.eigvalsh

Similar function in SciPy.    Notes  New in version 1.8.0.  Broadcasting rules apply, see the numpy.linalg documentation for details. The eigenvalues are computed using LAPACK routines _syevd, _heevd. Examples >>> from numpy import linalg as LA
>>> a = np.array([[1, -2j], [2j, 5]])
>>> LA.eigvalsh(a)
array([ 0.17157288,  5.82842712]) # may vary
 >>> # demonstrate the treatment of the imaginary part of the diagonal
>>> a = np.array([[5+2j, 9-2j], [0+2j, 2-1j]])
>>> a
array([[5.+2.j, 9.-2.j],
       [0.+2.j, 2.-1.j]])
>>> # with UPLO='L' this is numerically equivalent to using LA.eigvals()
>>> # with:
>>> b = np.array([[5.+0.j, 0.-2.j], [0.+2.j, 2.-0.j]])
>>> b
array([[5.+0.j, 0.-2.j],
       [0.+2.j, 2.+0.j]])
>>> wa = LA.eigvalsh(a)
>>> wb = LA.eigvals(b)
>>> wa; wb
array([1., 6.])
array([6.+0.j, 1.+0.j])
numpy.linalg.inv   linalg.inv(a)[source]
 
Compute the (multiplicative) inverse of a matrix. Given a square matrix a, return the matrix ainv satisfying dot(a, ainv) = dot(ainv, a) = eye(a.shape[0]).  Parameters 
 
a(…, M, M) array_like


Matrix to be inverted.    Returns 
 
ainv(…, M, M) ndarray or matrix


(Multiplicative) inverse of the matrix a.    Raises 
 LinAlgError

If a is not square or inversion fails.      See also  scipy.linalg.inv

Similar function in SciPy.    Notes  New in version 1.8.0.  Broadcasting rules apply, see the numpy.linalg documentation for details. Examples >>> from numpy.linalg import inv
>>> a = np.array([[1., 2.], [3., 4.]])
>>> ainv = inv(a)
>>> np.allclose(np.dot(a, ainv), np.eye(2))
True
>>> np.allclose(np.dot(ainv, a), np.eye(2))
True
 If a is a matrix object, then the return value is a matrix as well: >>> ainv = inv(np.matrix(a))
>>> ainv
matrix([[-2. ,  1. ],
        [ 1.5, -0.5]])
 Inverses of several matrices can be computed at once: >>> a = np.array([[[1., 2.], [3., 4.]], [[1, 3], [3, 5]]])
>>> inv(a)
array([[[-2.  ,  1.  ],
        [ 1.5 , -0.5 ]],
       [[-1.25,  0.75],
        [ 0.75, -0.25]]])
numpy.linalg.LinAlgError   exception linalg.LinAlgError[source]
 
Generic Python-exception-derived object raised by linalg functions. General purpose exception class, derived from Python’s exception.Exception class, programmatically raised in linalg functions when a Linear Algebra-related condition would prevent further correct execution of the function.  Parameters 
 None
   Examples >>> from numpy import linalg as LA
>>> LA.inv(np.zeros((2,2)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "...linalg.py", line 350,
    in inv return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))
  File "...linalg.py", line 249,
    in solve
    raise LinAlgError('Singular matrix')
numpy.linalg.LinAlgError: Singular matrix
numpy.linalg.lstsq   linalg.lstsq(a, b, rcond='warn')[source]
 
Return the least-squares solution to a linear matrix equation. Computes the vector x that approximately solves the equation a @ x = b. The equation may be under-, well-, or over-determined (i.e., the number of linearly independent rows of a can be less than, equal to, or greater than its number of linearly independent columns). If a is square and of full rank, then x (but for round-off error) is the “exact” solution of the equation. Else, x minimizes the Euclidean 2-norm \(||b - ax||\). If there are multiple minimizing solutions, the one with the smallest 2-norm \(||x||\) is returned.  Parameters 
 
a(M, N) array_like


“Coefficient” matrix.  
b{(M,), (M, K)} array_like


Ordinate or “dependent variable” values. If b is two-dimensional, the least-squares solution is calculated for each of the K columns of b.  
rcondfloat, optional


Cut-off ratio for small singular values of a. For the purposes of rank determination, singular values are treated as zero if they are smaller than rcond times the largest singular value of a.  Changed in version 1.14.0: If not set, a FutureWarning is given. The previous default of -1 will use the machine precision as rcond parameter, the new default will use the machine precision times max(M, N). To silence the warning and use the new default, use rcond=None, to keep using the old behavior, use rcond=-1.     Returns 
 
x{(N,), (N, K)} ndarray


Least-squares solution. If b is two-dimensional, the solutions are in the K columns of x.  
residuals{(1,), (K,), (0,)} ndarray


Sums of squared residuals: Squared Euclidean 2-norm for each column in b - a @ x. If the rank of a is < N or M <= N, this is an empty array. If b is 1-dimensional, this is a (1,) shape array. Otherwise the shape is (K,).  
rankint


Rank of matrix a.  
s(min(M, N),) ndarray


Singular values of a.    Raises 
 LinAlgError

If computation does not converge.      See also  scipy.linalg.lstsq

Similar function in SciPy.    Notes If b is a matrix, then all array results are returned as matrices. Examples Fit a line, y = mx + c, through some noisy data-points: >>> x = np.array([0, 1, 2, 3])
>>> y = np.array([-1, 0.2, 0.9, 2.1])
 By examining the coefficients, we see that the line should have a gradient of roughly 1 and cut the y-axis at, more or less, -1. We can rewrite the line equation as y = Ap, where A = [[x 1]] and p = [[m], [c]]. Now use lstsq to solve for p: >>> A = np.vstack([x, np.ones(len(x))]).T
>>> A
array([[ 0.,  1.],
       [ 1.,  1.],
       [ 2.,  1.],
       [ 3.,  1.]])
 >>> m, c = np.linalg.lstsq(A, y, rcond=None)[0]
>>> m, c
(1.0 -0.95) # may vary
 Plot the data along with the fitted line: >>> import matplotlib.pyplot as plt
>>> _ = plt.plot(x, y, 'o', label='Original data', markersize=10)
>>> _ = plt.plot(x, m*x + c, 'r', label='Fitted line')
>>> _ = plt.legend()
>>> plt.show()
numpy.linalg.matrix_power   linalg.matrix_power(a, n)[source]
 
Raise a square matrix to the (integer) power n. For positive integers n, the power is computed by repeated matrix squarings and matrix multiplications. If n == 0, the identity matrix of the same shape as M is returned. If n < 0, the inverse is computed and then raised to the abs(n).  Note Stacks of object matrices are not currently supported.   Parameters 
 
a(…, M, M) array_like


Matrix to be “powered”.  
nint


The exponent can be any integer or long integer, positive, negative, or zero.    Returns 
 
a**n(…, M, M) ndarray or matrix object


The return value is the same shape and type as M; if the exponent is positive or zero then the type of the elements is the same as those of M. If the exponent is negative the elements are floating-point.    Raises 
 LinAlgError

For matrices that are not square or that (for negative powers) cannot be inverted numerically.     Examples >>> from numpy.linalg import matrix_power
>>> i = np.array([[0, 1], [-1, 0]]) # matrix equiv. of the imaginary unit
>>> matrix_power(i, 3) # should = -i
array([[ 0, -1],
       [ 1,  0]])
>>> matrix_power(i, 0)
array([[1, 0],
       [0, 1]])
>>> matrix_power(i, -3) # should = 1/(-i) = i, but w/ f.p. elements
array([[ 0.,  1.],
       [-1.,  0.]])
 Somewhat more sophisticated example >>> q = np.zeros((4, 4))
>>> q[0:2, 0:2] = -i
>>> q[2:4, 2:4] = i
>>> q # one of the three quaternion units not equal to 1
array([[ 0., -1.,  0.,  0.],
       [ 1.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  1.],
       [ 0.,  0., -1.,  0.]])
>>> matrix_power(q, 2) # = -np.eye(4)
array([[-1.,  0.,  0.,  0.],
       [ 0., -1.,  0.,  0.],
       [ 0.,  0., -1.,  0.],
       [ 0.,  0.,  0., -1.]])
numpy.linalg.multi_dot   linalg.multi_dot(arrays, *, out=None)[source]
 
Compute the dot product of two or more arrays in a single function call, while automatically selecting the fastest evaluation order. multi_dot chains numpy.dot and uses optimal parenthesization of the matrices [1] [2]. Depending on the shapes of the matrices, this can speed up the multiplication a lot. If the first argument is 1-D it is treated as a row vector. If the last argument is 1-D it is treated as a column vector. The other arguments must be 2-D. Think of multi_dot as: def multi_dot(arrays): return functools.reduce(np.dot, arrays)
  Parameters 
 
arrayssequence of array_like


If the first argument is 1-D it is treated as row vector. If the last argument is 1-D it is treated as column vector. The other arguments must be 2-D.  
outndarray, optional


Output argument. This must have the exact kind that would be returned if it was not used. In particular, it must have the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a, b). This is a performance feature. Therefore, if these conditions are not met, an exception is raised, instead of attempting to be flexible.  New in version 1.19.0.     Returns 
 
outputndarray


Returns the dot product of the supplied arrays.      See also  numpy.dot

dot multiplication with two arguments.    Notes The cost for a matrix multiplication can be calculated with the following function: def cost(A, B):
    return A.shape[0] * A.shape[1] * B.shape[1]
 Assume we have three matrices \(A_{10x100}, B_{100x5}, C_{5x50}\). The costs for the two different parenthesizations are as follows: cost((AB)C) = 10*100*5 + 10*5*50   = 5000 + 2500   = 7500
cost(A(BC)) = 10*100*50 + 100*5*50 = 50000 + 25000 = 75000
 References  1 
Cormen, “Introduction to Algorithms”, Chapter 15.2, p. 370-378  2 
https://en.wikipedia.org/wiki/Matrix_chain_multiplication   Examples multi_dot allows you to write: >>> from numpy.linalg import multi_dot
>>> # Prepare some data
>>> A = np.random.random((10000, 100))
>>> B = np.random.random((100, 1000))
>>> C = np.random.random((1000, 5))
>>> D = np.random.random((5, 333))
>>> # the actual dot multiplication
>>> _ = multi_dot([A, B, C, D])
 instead of: >>> _ = np.dot(np.dot(np.dot(A, B), C), D)
>>> # or
>>> _ = A.dot(B).dot(C).dot(D)
numpy.linalg.pinv   linalg.pinv(a, rcond=1e-15, hermitian=False)[source]
 
Compute the (Moore-Penrose) pseudo-inverse of a matrix. Calculate the generalized inverse of a matrix using its singular-value decomposition (SVD) and including all large singular values.  Changed in version 1.14: Can now operate on stacks of matrices   Parameters 
 
a(…, M, N) array_like


Matrix or stack of matrices to be pseudo-inverted.  
rcond(…) array_like of float


Cutoff for small singular values. Singular values less than or equal to rcond * largest_singular_value are set to zero. Broadcasts against the stack of matrices.  
hermitianbool, optional


If True, a is assumed to be Hermitian (symmetric if real-valued), enabling a more efficient method for finding singular values. Defaults to False.  New in version 1.17.0.     Returns 
 
B(…, N, M) ndarray


The pseudo-inverse of a. If a is a matrix instance, then so is B.    Raises 
 LinAlgError

If the SVD computation does not converge.      See also  scipy.linalg.pinv

Similar function in SciPy.  scipy.linalg.pinv2

Similar function in SciPy (SVD-based).  scipy.linalg.pinvh

Compute the (Moore-Penrose) pseudo-inverse of a Hermitian matrix.    Notes The pseudo-inverse of a matrix A, denoted \(A^+\), is defined as: “the matrix that ‘solves’ [the least-squares problem] \(Ax = b\),” i.e., if \(\bar{x}\) is said solution, then \(A^+\) is that matrix such that \(\bar{x} = A^+b\). It can be shown that if \(Q_1 \Sigma Q_2^T = A\) is the singular value decomposition of A, then \(A^+ = Q_2 \Sigma^+ Q_1^T\), where \(Q_{1,2}\) are orthogonal matrices, \(\Sigma\) is a diagonal matrix consisting of A’s so-called singular values, (followed, typically, by zeros), and then \(\Sigma^+\) is simply the diagonal matrix consisting of the reciprocals of A’s singular values (again, followed by zeros). [1] References  1 
G. Strang, Linear Algebra and Its Applications, 2nd Ed., Orlando, FL, Academic Press, Inc., 1980, pp. 139-142.   Examples The following example checks that a * a+ * a == a and a+ * a * a+ == a+: >>> a = np.random.randn(9, 6)
>>> B = np.linalg.pinv(a)
>>> np.allclose(a, np.dot(a, np.dot(B, a)))
True
>>> np.allclose(B, np.dot(B, np.dot(a, B)))
True
numpy.linalg.slogdet   linalg.slogdet(a)[source]
 
Compute the sign and (natural) logarithm of the determinant of an array. If an array has a very small or very large determinant, then a call to det may overflow or underflow. This routine is more robust against such issues, because it computes the logarithm of the determinant rather than the determinant itself.  Parameters 
 
a(…, M, M) array_like


Input array, has to be a square 2-D array.    Returns 
 
sign(…) array_like


A number representing the sign of the determinant. For a real matrix, this is 1, 0, or -1. For a complex matrix, this is a complex number with absolute value 1 (i.e., it is on the unit circle), or else 0.  
logdet(…) array_like


The natural log of the absolute value of the determinant.  If the determinant is zero, then sign will be 0 and logdet will be
-Inf. In all cases, the determinant is equal to sign * np.exp(logdet).
    See also  det
  Notes  New in version 1.8.0.  Broadcasting rules apply, see the numpy.linalg documentation for details.  New in version 1.6.0.  The determinant is computed via LU factorization using the LAPACK routine z/dgetrf. Examples The determinant of a 2-D array [[a, b], [c, d]] is ad - bc: >>> a = np.array([[1, 2], [3, 4]])
>>> (sign, logdet) = np.linalg.slogdet(a)
>>> (sign, logdet)
(-1, 0.69314718055994529) # may vary
>>> sign * np.exp(logdet)
-2.0
 Computing log-determinants for a stack of matrices: >>> a = np.array([ [[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]] ])
>>> a.shape
(3, 2, 2)
>>> sign, logdet = np.linalg.slogdet(a)
>>> (sign, logdet)
(array([-1., -1., -1.]), array([ 0.69314718,  1.09861229,  2.07944154]))
>>> sign * np.exp(logdet)
array([-2., -3., -8.])
 This routine succeeds where ordinary det does not: >>> np.linalg.det(np.eye(500) * 0.1)
0.0
>>> np.linalg.slogdet(np.eye(500) * 0.1)
(1, -1151.2925464970228)