Skip to content

Commit

Permalink
Merge pull request #400 from hugohadfield/fix_complex_inv
Browse files Browse the repository at this point in the history
Added an inversion test for N = 7 and fixed leftLaInv complex number behaviour
  • Loading branch information
hugohadfield committed Jun 8, 2021
2 parents 8ad4913 + f49ffbb commit 350c693
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion clifford/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ def grades_present(objin: 'MultiVector', threshold=0.0000001) -> Set[int]:
# todo: work out how to let numba use the COO objects directly
@_numba_utils.njit
def _numba_val_get_left_gmt_matrix(x, k_list, l_list, m_list, mult_table_vals, ndims):
intermed = np.zeros((ndims, ndims))
# TODO: consider `dtype=result_type(x.dtype, mult_table_vals.dtype)`
intermed = np.zeros((ndims, ndims), dtype=x.dtype)
test_ind = 0
for k in k_list:
j = l_list[test_ind]
Expand Down
2 changes: 1 addition & 1 deletion clifford/_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def leftLaInvJIT(value):
intermed = _numba_val_get_left_gmt_matrix(value, k_list, l_list, m_list, mult_table_vals, n_dims)
if abs(np.linalg.det(intermed)) < _settings._eps:
raise ValueError("multivector has no left-inverse")
sol = np.linalg.solve(intermed, identity)
sol = np.linalg.solve(intermed, identity.astype(intermed.dtype))
return sol

return leftLaInvJIT
Expand Down
11 changes: 8 additions & 3 deletions clifford/test/test_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def g5():
return Cl(5)[0]


@pytest.fixture(scope='module')
def g7():
return Cl(7)[0]


@pytest.fixture(scope='module')
def g3c():
return conformalize(Cl(3)[0])[0]
Expand All @@ -47,9 +52,9 @@ def pga():


class TestCliffordComplex:
@pytest.fixture(params=[3, 4, 5, 'g3c', (3, 0, 1)], ids='Cl({})'.format)
def algebra(self, request, g3, g4, g5, g3c, pga):
return {3: g3, 4: g4, 5: g5, 'g3c': g3c, (3, 0, 1): pga}[request.param]
@pytest.fixture(params=[3, 4, 5, 7, 'g3c', (3, 0, 1)], ids='Cl({})'.format)
def algebra(self, request, g3, g4, g5, g7, g3c, pga):
return {3: g3, 4: g4, 5: g5, 7: g7, 'g3c': g3c, (3, 0, 1): pga}[request.param]

def test_addition(self, algebra, rng): # noqa: F811
A = algebra.randomMV(rng=rng)
Expand Down

0 comments on commit 350c693

Please sign in to comment.