From: Michael Orlitzky Date: Thu, 4 Mar 2021 22:43:59 +0000 (-0500) Subject: eja: improve a gram_schmidt() error message. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=sage.d.git;a=commitdiff_plain;h=8f3ba1d9473195c1cbafe967a127800d90fde3ee;hp=77f0119f043a9ceac891dc82229e550574a2a03f eja: improve a gram_schmidt() error message. --- diff --git a/mjo/eja/eja_utils.py b/mjo/eja/eja_utils.py index 2402d9f..d4e9990 100644 --- a/mjo/eja/eja_utils.py +++ b/mjo/eja/eja_utils.py @@ -230,7 +230,14 @@ def gram_schmidt(v, inner_product=None): """ if inner_product is None: inner_product = lambda x,y: x.inner_product(y) - norm = lambda x: inner_product(x,x).sqrt() + 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