5ce5316a33 2021-03-01 jeff@gridfini: %%%%%%%%%%%%%%%%%%%%%
5ce5316a33 2021-03-01 jeff@gridfini: % LINEAR ALGEBRA
5ce5316a33 2021-03-01 jeff@gridfini: %%%%%%%%%%%%%%%%%%%%%
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: % Enable fancy output for easier viewing of
5ce5316a33 2021-03-01 jeff@gridfini: % matrix output
5ce5316a33 2021-03-01 jeff@gridfini: %fancy_output$
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: % Load linear algebra package
5ce5316a33 2021-03-01 jeff@gridfini: load_package linalg$
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: % Define a complex 3x3 matrix
5ce5316a33 2021-03-01 jeff@gridfini: m1 := mat((1+i*3, 2-i*5, 7-i), (4-i*2, 6+i*9,-8+i*4), (-3-i*7, 3+i*2, -1+i*6));
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: % Determinant of matrix
5ce5316a33 2021-03-01 jeff@gridfini: write "|m1| = ", det(m1)$
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: % Trace of matrix
5ce5316a33 2021-03-01 jeff@gridfini: write "trace(m1) = ", trace(m1)$
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: % Characteristic polynomial
5ce5316a33 2021-03-01 jeff@gridfini: write "characteristic polynomial of m1:";
5ce5316a33 2021-03-01 jeff@gridfini: char_poly(m1,eta);
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: % Enable real arithmetic
5ce5316a33 2021-03-01 jeff@gridfini: on rounded$
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: % Singular value decomposition of a matrix.
5ce5316a33 2021-03-01 jeff@gridfini: a := mat((1,3),(-4,3));
5ce5316a33 2021-03-01 jeff@gridfini: write "Singular Value Decomposition of a:"$
5ce5316a33 2021-03-01 jeff@gridfini: svd(a);
5ce5316a33 2021-03-01 jeff@gridfini:
5ce5316a33 2021-03-01 jeff@gridfini: off rounded;
5ce5316a33 2021-03-01 jeff@gridfini: end;