+ degree = 0
+ if n > 0:
+ if is_Matrix(basis[0]):
+ basis_is_matrices = True
+ vector_basis = tuple( map(_mat2vec,basis) )
+ degree = basis[0].nrows()**2
+ else:
+ degree = basis[0].degree()
+
+ V = VectorSpace(field, degree)
+
+ # Compute this from "Q" (obtained from Gram-Schmidt) below as
+ # R = Q.solve_right(A), where the rows of "Q" are the
+ # orthonormalized vector_basis and and the rows of "A" are the
+ # original vector_basis.
+ self._deorthonormalization_matrix = None
+
+ if orthonormalize:
+ from mjo.eja.eja_utils import gram_schmidt
+ A = matrix(field, vector_basis)
+ vector_basis = gram_schmidt(vector_basis, inner_product)
+ W = V.span_of_basis( vector_basis )
+ Q = matrix(field, vector_basis)
+ # A = QR <==> A.T == R.T*Q.T
+ # So, Q.solve_right() is equivalent to the Q.T.solve_left()
+ # that we want.
+ self._deorthonormalization_matrix = Q.solve_right(A)
+
+ if basis_is_matrices:
+ from mjo.eja.eja_utils import _vec2mat
+ basis = tuple( map(_vec2mat,vector_basis) )
+
+ W = V.span_of_basis( vector_basis )
+
+ mult_table = [ [0 for i in range(n)] for j in range(n) ]
+ ip_table = [ [0 for i in range(n)] for j in range(n) ]
+
+ # Note: the Jordan and inner- products are defined in terms
+ # of the ambient basis. It's important that their arguments
+ # are in ambient coordinates as well.
+ for i in range(n):
+ for j in range(i+1):
+ # ortho basis w.r.t. ambient coords
+ q_i = vector_basis[i]
+ q_j = vector_basis[j]