8 m square matrix with elements of suitable type
10 return zero or value of type determined by types of elements
13 The matrix m has to be square, i.e. of dimension 2 with:
15 matmax(m,1) - matmin(m,1) == matmax(m,2) - matmin(m,2).
17 If the elements of m are numbers (real or complex), det(m)
18 returns the value of the determinant of m.
20 If some or all of the elements of m are not numbers, the algorithm
21 used to evaluate det(m) assumes the definitions of *, unary -, binary -,
22 being zero or nonzero, are consistent with commutative ring structure,
23 and if the m is larger than 2 x 2, division by nonzero elements is
24 consistent with integral-domain structure.
26 If m is a 2 x 2 matrix with elements a, b, c, d, where a tests as
27 nonzero, det(m) is evaluated by
29 det(m) = (a * d) - (c * b).
31 If a tests as zero, det(m) = - ((c * b) - (a * d)) is used.
33 If m is 3 * 3 with elements a, b, c, d, e, f, g, h, i, where a and
34 a * e - d * b test as nonzero, det(m) is evaluated by
36 det(m) = ((a * e - d * b) * (a * i - g * c)
37 - (a * h - g * b) * (a * f - d * c))/a.
40 > mat A[3,3] = {2, 3, 5, 7, 11, 13, 17, 19, 23}
41 > c = config("mode", "frac")
42 > print det(A), det(A^2), det(A^3), det(A^-1)
43 -78 6084 -474552 -1/78
47 > define res_test(a) = !ismult(a.r, md)
48 > define res_sub(a,b) {local obj res v = {(a.r - b.r) % md}; return v;}
49 > define res_mul(a,b) {local obj res v = {(a.r * b.r) % md}; return v;}
50 > define res_neg(a) {local obj res v = {(-a.r) % md}; return v;}
51 > define res(x) {local obj res v = {x % md}; return v;}
53 > mat A[2,2] = {res(2), res(3), res(5), res(7)}
61 Note that if A had been a 3 x 3 or larger matrix, res_div(a,b) for
62 non-zero b would have had to be defined (assuming at least one
63 division is necessary); for consistent results when md is composite,
64 res_div(a,b) should be defined only when b and md are relatively
65 prime; there is no problem when md is prime.
71 VALUE matdet(MATRIX *m)
74 matdim, matmax, matmin, inverse