-
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
Non-commutative inner product support #437
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -741,6 +741,24 @@ def test_right_multiplication_matrix(self, algebra, rng): # noqa: F811 | |
res2 = layout.MultiVector(value=b_right@a.value) | ||
np.testing.assert_almost_equal(res.value, res2.value) | ||
|
||
@pytest.mark.parametrize('func', [ | ||
operator.add, | ||
operator.sub, | ||
operator.mul, | ||
operator.xor, # outer product | ||
operator.or_, # inner product | ||
]) | ||
def test_swapped_operands(self, algebra, rng, func): # noqa: F811 | ||
layout = algebra | ||
for _ in range(10): | ||
mv = layout.randomMV(rng=rng) | ||
mv2 = layout.randomMV(rng=rng) | ||
Comment on lines
+754
to
+755
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I'd be tempted to just pick two elements here on which all the products are non-commutative. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that ok: trundev@b2418f0
BTW, there is still no test coverage for the second |
||
# Convert first operand to MVArray. This provokes use of operation with | ||
# swapped operands: MultiVector.__rmul__, __ror__, etc. | ||
ma = clifford.MVArray(mv) | ||
np.testing.assert_equal(func(ma, mv2), func(mv, mv2)) | ||
np.testing.assert_equal(func(mv2, ma), func(mv2, mv)) | ||
|
||
|
||
class TestPrettyRepr: | ||
""" Test ipython pretty printing, with tidy line wrapping """ | ||
|
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.
Probably it's sufficient to just test
g3
here, assuming that elements with non-commutative inner products exist there.