Skip to content

Instantly share code, notes, and snippets.

@ryanrhymes
Created January 12, 2017 16:41
Show Gist options
  • Save ryanrhymes/3d8df83c67a574c83c545c578f55e71b to your computer and use it in GitHub Desktop.
Save ryanrhymes/3d8df83c67a574c83c545c578f55e71b to your computer and use it in GitHub Desktop.
Functor of dsmat in Eigen library
(*
* Eigen - an OCaml interface to C++ Eigen library
* Copyright (c) 2016 Liang Wang <liang.wang@cl.cam.ac.uk>
*)
module type MatSig = sig
type elt
type mat
val ml_eigen_new : int64 -> int64 -> mat
val ml_eigen_delete : mat -> unit
val ml_eigen_print : mat -> unit
end
module Make (Mat : MatSig) = struct
open Mat
let create m n =
let x = ml_eigen_new (Int64.of_int m) (Int64.of_int n) in
Gc.finalise ml_eigen_delete x;
x
let delete x = ml_eigen_delete x
let print x = ml_eigen_print x
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment