I see clearer now. Working thru the examlpes and tests helped.
open Owl
let f =
let x = (Mat.of_array [|1.;0.;3.;4.;5.;5.;0.;8.;7.;8.;9.;4.;3.;-2.;1.;9.|] 4 4) in
let y = Mat.inv x in
let dx = Owl.Linalg.D.det x in
let dy = Owl.Linalg.D.det y in
let xy = Mat.(y *@ x) in
Mat.iteri_rows (fun i r ->
Mat.iteri (fun j a -> Printf.printf "(%i,%i) %.1f\n" i j a) r) xy;
Printf.printf "det(x) = %.4f det(y) = %.4f %4f\n" dx dy (dx *. dy)
Thanks for pointing this out. I think some tutorial parts got stale, we should really find a way to integrate them with mdx and run them on PRs. I’ll open a ticket for it.
For some reason the uniform_int function has disappeared for dense matrices (you can still do it for sparse matrices: Sparse.Matrix.D.uniform_int 5 5 works). I don’t know if this was on purpose or happened by mistake. I’ll open a ticket for it.
To see the shape of ndarrays and matrices, owl provides pretty printers but they need to be installed. One way to use them is to install owl-top, open utop and require owl-top. For example, try the following:
# require "owl-top" ;;
# open Owl;;
# Sparse.Matrix.D.uniform_int 5 5;;
# Mat.uniform 5 5;;
# let xy, x, y =
let x = (Mat.of_array [|1.;0.;3.;4.;5.;5.;0.;8.;7.;8.;9.;4.;3.;-2.;1.;9.|] 4 4) in
let y = Mat.inv x in
let xy = Mat.(y *@ x) in
xy, x, y
;;
# Linalg.D.det x ;;
You should see all the matrices pretty printed after each execution.
Please, if you go through the tutorial and find issues, think that there are missing concepts or tricks, or have any other suggestion, do open an issue or send a PR to https://github.com/owlbarn/owlbarn.github.io/