I needed a Gram-Schmidt orthogonalization that took an arbitrary
inner-product:
gschmidt(lind, inprod) := block([iter, n],
n: length(lind),
iter(v, m) :=
if m > n
then v
else
iter(append(v, [lreduce(lambda([a, b], a - b),
append([lind[m]], makelist(inprod(lind[m], v[i])
/ abs(inprod(v[i], v[i])) * v[i],
i, 1, m - 1)))]),
m + 1),
iter([], 1));
For instance:
(%i8) gschmidt([1, sin(x), cos(x)],
lambda([f, g], integrate(f * g, x, a, b))),
a = -%pi/2, b = %pi/2;
2
(%o8) [1, sin(x), cos(x) - ---]
%pi
It works; but I'd rather employ the builtin `gramschmidt', if only I
could break the assumption that inner product = dot-product.
Eigen.mac seemed to imply that redefining `innerproduct' might work;
but no avail.
Any suggestions?