-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the shirokov inverse #373
Conversation
Thinking about numerical accuracy etc. I knocked up a quick comparison: from clifford import Cl
import numpy as np
def measure_error(layout):
rand_mv = layout.randomMV()
unity = layout.scalar.value
error_shirokov = np.linalg.norm(unity - (rand_mv*rand_mv.shirokov_inverse()).value)
error_hitzer = np.linalg.norm(unity - (rand_mv*rand_mv.hitzer_inverse()).value)
return error_shirokov, error_hitzer
for p in range(1, 6):
layout, blades = Cl(p=p)
error_shirokov, error_hitzer = zip(*[measure_error(layout) for i in range(200)])
print('P: ', p)
print('Shirokov', 'Hitzer')
print(np.mean(error_shirokov), np.mean(error_hitzer))
print(np.std(error_shirokov), np.std(error_hitzer))
print() Which produces
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flake8 is complaining because:
Well the new tests were all fast, but that's mainly because they all failed due to accuracy issues. |
Yes indeed... any smart ideas for attempting to improve the accuracy? I had a brief look but made no headway |
Well, the simple answer is "reduce the expected accuracy of the high-dimensional test". The failing ones are all very high dimensional:
|
Wait actually I think your tests is just bad. The higher dimensional your space, the more multivectors there are which are simply not invertible (and the closer you get to those, the more inaccurate your results are). The failures are all in the algebras with |
Ck = (N / k) * Uk.value[0] | ||
adjU = (Uk - Ck) | ||
Uk = U * adjU | ||
if Uk.value[0] == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think that is a good point, perhaps this just needs to be some reasonable range about 0 then
docs/changelog.rst
Outdated
* The default multivector inverse method is now the arbitrary signature algorithm described | ||
in Theorem 4, page 16 of Dmitry Shirokov's ICCA 2020 paper :cite:`shirokov2020inverse`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The default multivector inverse method is now the arbitrary signature algorithm described | |
in Theorem 4, page 16 of Dmitry Shirokov's ICCA 2020 paper :cite:`shirokov2020inverse`. | |
* A new multivector inverse method is available, :meth:`clifford.MultiVector.shirokov_inverse`, | |
which is the arbitrary signature algorithm described | |
in Theorem 4, page 16 of Dmitry Shirokov's ICCA 2020 paper :cite:`shirokov2020inverse`. |
rtol=1E-5, | ||
atol=1E-6) | ||
|
||
@pytest.mark.parametrize('r', range(2)) | ||
@pytest.mark.parametrize('p, q', [ | ||
(p, total_dims - p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/pygae/clifford/pull/373/files#r549352578 still applies. At a guess:
(p, total_dims - p) | |
pytest.param(p, total_dims - p, marks=[pytest.mark.slow] if total_dims >= 6 else []) |
c72ec32
to
261efe0
Compare
Test failures are real at the moment; perhaps adjust the precision based on the dimension? Since it's all multiplication, I'd perhaps expect the number of digits of error to scale with the dimension of the algebra. |
Build failure is unrelated... @eric-wieser shall we merge this thing finally? |
Does what it says on the tin, see #369