diff options
author | Anton Khirnov <anton@khirnov.net> | 2019-12-01 17:13:11 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2019-12-01 17:13:11 +0100 |
commit | 251e218bb2d780964e001d8c0eeee993f9bc9dd1 (patch) | |
tree | 70427794a71363e8d84dd93b731380a45cbc93be /utils.py | |
parent | 408906eca3f0d7f6c9c1a7179d57a87278f15445 (diff) |
horizon: add apparent horizon equations
Diffstat (limited to 'utils.py')
-rw-r--r-- | utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -19,6 +19,24 @@ def matrix_invert(mat): inv = np.linalg.inv(mat) return inv.transpose((1, 2, 0)).reshape(oldshape) +def matrix_det(mat): + """ + Pointwise matrix determinant. + + Given an array that stores many square matrices (e.g. the values of the + metric tensor at spacetime points), compute the array of corresponding + determinants. + + :param array_like mat: N-D array with N>2 and each mat[i0, ..., :, :] a + square matrix. + :return: Array of determinants. + """ + oldshape = mat.shape + newshape = oldshape[:2] + (np.product(mat.shape[2:]),) + + mat = mat.reshape(newshape).transpose((2, 0, 1)) + return np.linalg.det(mat).reshape(oldshape[2:]) + def array_reflect(data, parity = 1.0, axis = -1): """ Reflect an N-D array with respect to the specified axis. E.g. input |