From 2090aca15e81df6ec3e2115203c7da8b432291c7 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 6 Sep 2024 15:55:04 +0200 Subject: [PATCH] Pretty printer for vectors --- linear_algebra/lib/vector.ml | 5 +++++ linear_algebra/lib/vector.mli | 2 ++ top/lib/install_printers.ml | 1 + 3 files changed, 8 insertions(+) diff --git a/linear_algebra/lib/vector.ml b/linear_algebra/lib/vector.ml index 09569a4..713f089 100644 --- a/linear_algebra/lib/vector.ml +++ b/linear_algebra/lib/vector.ml @@ -73,3 +73,8 @@ let normalize v = let (%.) t i = t.{i} let set t i v = t.{i} <- v + +let pp ppf m = + let m = to_bigarray_inplace m in + Lacaml.Io.pp_fvec ppf m + diff --git a/linear_algebra/lib/vector.mli b/linear_algebra/lib/vector.mli index 4b733be..be2b279 100644 --- a/linear_algebra/lib/vector.mli +++ b/linear_algebra/lib/vector.mli @@ -142,3 +142,5 @@ val (%.) : 'a t -> int -> float val set : 'a t -> int -> float -> unit (** Modifies the value in-place at the i-th position *) + +val pp : Format.formatter -> 'a t -> unit diff --git a/top/lib/install_printers.ml b/top/lib/install_printers.ml index be8a7bd..0a3ceb4 100644 --- a/top/lib/install_printers.ml +++ b/top/lib/install_printers.ml @@ -22,6 +22,7 @@ let printers = "Gaussian.Contracted_shell.pp" ; "Gaussian.General_basis.pp" ; "Linear_algebra.Matrix.pp" ; + "Linear_algebra.Vector.pp" ; "Mo.Basis.pp" ; "Mo.Class.pp" ; "Mo.Fock.pp" ;