- # Now pretend to normalize, building a new ring R that contains
- # all of the necessary square roots.
- norms_squared = [0]*len(v)
-
- for i in xrange(len(v)):
- norms_squared[i] = v[i].inner_product(v[i])
- ns = [norms_squared[i].numerator(), norms_squared[i].denominator()]
-
- # Do the numerator and denominator separately so that we
- # adjoin e.g. sqrt(2) and sqrt(3) instead of sqrt(2/3).
- for j in xrange(len(ns)):
- PR = PolynomialRing(R, 'z')
- z = PR.gen()
- p = z**2 - ns[j]
- if p.is_irreducible():
- R = NumberField(p,
- 'sqrt' + str(ns[j]),
- embedding=RLF(ns[j]).sqrt())
-
- # When we're done, we have to change every element's ring to the
- # extension that we wound up with, and then normalize it (which
- # should work, since "R" contains its norm now).
+ # Just normalize. If the algebra is missing the roots, we can't add
+ # them here because then our subalgebra would have a bigger field
+ # than the superalgebra.