c1ddb4c814 2021-03-01 1: %%%%%%%%%%%%%%%%%%%%%
c1ddb4c814 2021-03-01 2: % LINEAR ALGEBRA
c1ddb4c814 2021-03-01 3: %%%%%%%%%%%%%%%%%%%%%
c1ddb4c814 2021-03-01 4:
c1ddb4c814 2021-03-01 5: % Enable fancy output for easier viewing of
c1ddb4c814 2021-03-01 6: % matrix output
c1ddb4c814 2021-03-01 7: %fancy_output$
c1ddb4c814 2021-03-01 8:
c1ddb4c814 2021-03-01 9: % Load linear algebra package
c1ddb4c814 2021-03-01 10: load_package linalg$
c1ddb4c814 2021-03-01 11:
c1ddb4c814 2021-03-01 12: % Define a complex 3x3 matrix
c1ddb4c814 2021-03-01 13: 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 14:
c1ddb4c814 2021-03-01 15: % Determinant of matrix
c1ddb4c814 2021-03-01 16: write "|m1| = ", det(m1)$
c1ddb4c814 2021-03-01 17:
c1ddb4c814 2021-03-01 18: % Trace of matrix
c1ddb4c814 2021-03-01 19: write "trace(m1) = ", trace(m1)$
c1ddb4c814 2021-03-01 20:
c1ddb4c814 2021-03-01 21: % Characteristic polynomial
c1ddb4c814 2021-03-01 22: write "characteristic polynomial of m1:";
c1ddb4c814 2021-03-01 23: char_poly(m1,eta);
c1ddb4c814 2021-03-01 24:
c1ddb4c814 2021-03-01 25: % Enable real arithmetic
c1ddb4c814 2021-03-01 26: on rounded$
c1ddb4c814 2021-03-01 27:
c1ddb4c814 2021-03-01 28: % Singular value decomposition of a matrix.
c1ddb4c814 2021-03-01 29: a := mat((1,3),(-4,3));
c1ddb4c814 2021-03-01 30: write "Singular Value Decomposition of a:"$
c1ddb4c814 2021-03-01 31: svd(a);
c1ddb4c814 2021-03-01 32:
c1ddb4c814 2021-03-01 33: off rounded;
c1ddb4c814 2021-03-01 34: end;