inverse matrix by m.ukai

open Array
let r,s,a=iteri,iteri,make_matrix 9 18 0.;;r(fun i y->r(fun j z->Scanf.scanf"%f "(fun x->y.(j)<-x))a;y.(i+9)<-1.)a;r(fun i y->let p=y.(0) s(fun k z->y.(k)<-z/.p+.a.(8).(k))y;r(fun j z->let u,c=y.(i),z.(i)/.y.(i)in
s(fun k w->z.(k)<-if i=j then w/.u else w-.y.(k)*.c)z)a)a;r(fun i y->r(fun j z->Printf.printf"%.f%c"(y.(j+9)+.0.1)" 

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


return to the top page