- """
- if inner_product is None:
- inner_product = lambda x,y: x.inner_product(y)
- def norm(x):
- ip = inner_product(x,x)
- # Don't expand the given field; the inner-product's codomain
- # is already correct. For example QQ(2).sqrt() returns sqrt(2)
- # in SR, and that will give you weird errors about symbolics
- # when what's really going wrong is that you're trying to
- # orthonormalize in QQ.
- return ip.parent()(ip.sqrt())
-
- v = list(v) # make a copy, don't clobber the input
-
- # Drop all zero vectors before we start.
- v = [ v_i for v_i in v if not v_i.is_zero() ]