(kill (all), load (eigen), 0);
0;

(x : matrix ([1, 2, 3], [9, 18, 30], [12, 48, 60]),
 y : gramschmidt (x),
 expand (y, 0, 0));
''([[1,2,3],[-3^2/(2*7),-3^2/7,3*5/(2*7)],[-2^4*3/5,2^3*3/5,0]]);

map (innerproduct, [y[1], y[2], y[3]], [y[2], y[3], y[1]]);
[0, 0, 0];

(kill (x),
 ip (f, g) := integrate (f * g, 'x, a, b),
 ev (y : gramschmidt ([1, sin(x), cos(x)], ip), a= -%pi/2, b=%pi/2));
[1, sin(x), (%pi*cos(x) - 2)/%pi];

map (ip, [y[1], y[2], y[3]], [y[2], y[3], y[1]]), a= -%pi/2, b=%pi/2;
[0, 0, 0];

(load("nchrpl"),0);
0$

mattrace(matrix());
0$

mattrace(matrix([]));
0$

mattrace(matrix([a,b],[c,d]));
a + d$

mattrace(matrix([a,b],[c,d],[p,q]));
a + d$

/* Regression test for SF bug 2721670 */
(a[1,1] : 42, mattrace(matrix([1,2],[5,6])));
7$

(remarray(a),0);
0$

/* from mailing list 2009-08-17 "bugs on wxMaxima 5.19.1" */

block ([D1, uv], local (dmatrix),
 /* diag_matrix and diag involve loading big blobs of stuff, and diagmatrix isn't suitable ... sigh. */
 dmatrix (L) := block ([M, n : length (L)], M : zeromatrix (n, n), for i thru n do M[i, i] : L[i], M),
 D1 : matrix ([3, 2, 1, -5], [-1, 2, 1, -3], [5, -1, 2, 4], [3, 1, -1, 5]),
 uv : block([ratmx : true], similaritytransform (D1)),
 /* ratsimp or radcan could help here, but ratsimp simplifies leftmatrix . D1 . rightmatrix
  * incorrectly ... sigh. Also mat_norm could help but it's embedded in a big blob ... sigh.
  */
 float (dmatrix (uv[1][1]) - leftmatrix . D1 . rightmatrix),
 expand (%%),
 matrixmap (cabs, %%),
 maplist (lmax, %%),
 lmax (%%),
 is (%% < 1e-10));
true;

/* from mailing list 2019-05-11: "Problems with gramschmidt" */

(kill(x),
 basis: makelist (x^k, k, 0, 5),
 ip(u,v) := integrate (u*v, x, -1, 1),
 foo: ratsimp (gramschmidt (basis, ip)));
[1,x,(3*x^2-1)/3,(5*x^3-3*x)/5,(35*x^4-30*x^2+3)/35,(63*x^5-70*x^3+15*x)/63]$

bar: map (lambda ([e], ip(e, e)), foo);
[2,2/3,8/45,8/175,128/11025,128/43659]$

(baz: map (lambda ([a, b], a/sqrt(b)), foo, bar),
 genmatrix (lambda ([i, j], ip (baz[i], baz[j])), 5, 5));
matrix ([1, 0, 0, 0, 0],
        [0, 1, 0, 0, 0],
        [0, 0, 1, 0, 0],
        [0, 0, 0, 1, 0],
        [0, 0, 0, 0, 1]);
