Coverage for src/pymor/la/inverse : 58%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
# This file is part of the pyMOR project (http://www.pymor.org). # Copyright Holders: Rene Milk, Stephan Rave, Felix Schindler # License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
'''Efficiently compute the inverses of an array of 2x2-matrices ::
| retval[i1,...,ik,m,n] = numpy.linalg.inv(A[i1,...,ik,:,:]).
'''
assert A.shape[-1] == A.shape[-2] == 2, 'Wrong shape of argument.'
D = A[..., 0, 0] * A[..., 1, 1] - A[..., 1, 0] * A[..., 0, 1] D = 1 / D
INV = np.empty_like(A) INV[..., 0, 0] = A[..., 1, 1] INV[..., 1, 1] = A[..., 0, 0] INV[..., 1, 0] = - A[..., 1, 0] INV[..., 0, 1] = - A[..., 0, 1] INV *= D[..., np.newaxis, np.newaxis]
return INV
'''Efficiently compute the tranposed inverses of an array of 2x2-matrices ::
| retval[i1,...,ik,m,n] = numpy.linalg.inv(A[i1,...,ik,:,:]).
'''
|