feat: linalg.det added, test added

This commit is contained in:
Fabian Joswig 2021-12-10 14:39:14 +00:00
parent 67ca53681a
commit a2a799b591
2 changed files with 9 additions and 1 deletions

View file

@ -203,7 +203,12 @@ def cholesky(x):
return _mat_mat_op(anp.linalg.cholesky, x)
def scalar_mat_op(op, obs, **kwargs):
def det(x):
"""Determinant of Obs valued matrices."""
return _scalar_mat_op(anp.linalg.det, x)
def _scalar_mat_op(op, obs, **kwargs):
"""Computes the matrix to scalar operation op to a given matrix of Obs."""
def _mat(x, **kwargs):
dim = int(np.sqrt(len(x)))

View file

@ -311,6 +311,9 @@ def test_matrix_functions():
for (i, j), entry in np.ndenumerate(diff):
assert entry.is_zero()
# Check determinant
assert pe.linalg.det(np.diag(np.diag(matrix))) == np.prod(np.diag(matrix))
def test_complex_matrix_operations():
dimension = 4