if not all( len(l) == n for l in inner_product_table ):
raise ValueError(msg)
+ # Check commutativity of the Jordan product (symmetry of
+ # the multiplication table) and the commutativity of the
+ # inner-product (symmetry of the inner-product table)
+ # first if we're going to check them at all.. This has to
+ # be done before we define product_on_basis(), because
+ # that method assumes that self._multiplication_table is
+ # symmetric. And it has to be done before we build
+ # self._inner_product_matrix, because the process used to
+ # construct it assumes symmetry as well.
if not all( multiplication_table[j][i]
== multiplication_table[i][j]
for i in range(n)
for j in range(i+1) ):
raise ValueError("Jordan product is not commutative")
+
if not all( inner_product_table[j][i]
== inner_product_table[i][j]
for i in range(n)
for j in range(i+1) ):
raise ValueError("inner-product is not commutative")
+
self._matrix_basis = matrix_basis
if category is None:
# Pre-cache the fact that these are Hermitian (real symmetric,
# in fact) in case some e.g. matrix multiplication routine can
# take advantage of it.
- self._inner_product_matrix = matrix(field, inner_product_table)
+ ip_matrix_constructor = lambda i,j: inner_product_table[i][j] if j <= i else inner_product_table[j][i]
+ self._inner_product_matrix = matrix(field, n, ip_matrix_constructor)
self._inner_product_matrix._cache = {'hermitian': True}
self._inner_product_matrix.set_immutable()