inverse matrix by ksk

open Array
let m=make 81 0.let n=copy m
let(%)x(!)=iter!x[|0;1;3;4;2;5;6;7;8|]let($)x y=x*9+y;;iteri(fun i _->n.(i/9*10)<-1.;m.(i)<-Scanf.scanf"%f "(/.)0.1)m%(fun()k->m.(k$k)%(fun a j->m.(k$j)<-m.(k$j)/.a;n.(k$j)<-n.(k$j)/.a)%fun()i->(fun b x j->x.(i$j)<-x.(i$j)-.b*.x.(k$j))m.(i$k)%(fun(@)j->i=k||m@j=n@j;()));iteri(fun i x->Printf.printf"%.f%c"(x/.0.1+.0.1)" 
".[i mod 9/8])n

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page