I have few days to complete my awk homework. But I'm stucked. i hope some1 will help me out.
I have to inverse n x n matrix, but I have problems with finding the determinant of the matrix.
I found the algoritm, how to find a determinant of n x n matrix:
http://www.es.ucsc.edu/~eart111/lecture12.pdf
same text here:
a11 a12 a13
a21 a22 a23
a31 a32 a33
= a11(a22a33 − a23a32) − a12(a21a33 − a23a31) + a13(a21a32 − a22a31)
Note the pattern of + and − signs.
The general formula is compact, but tedious to compute. Here it is for an n by n matrix A:
detA = ai1Ci1 + ai2Ci2 + · · · + ainCin
where Cij are referred to as the cofactors and are computed from
Cij = (−1)i+j detMij
The term Mij is known as the ”minor matrix” and is the matrix you get if you eliminate row
i and column j from matrix A. So to find the determinant of e.g. a 4×4 matrix, you end up
calculating a bunch of 3 × 3 matrix determinants (much easier). Obviously you can apply this
technique recursively (probably using a computer).
****************************
Can some1 please write this matrix determinant algoritm into my code or if you have time, complete the full inverse?
I'm reading the matrix from a text file into an array "row"
--------------------
#!/usr/bin/awk -f
BEGIN{}
{
m=1
while (m <= NF){
row[NR,m] = $m
m++
}
}
END{}
-------------------
thank you