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