Module Lacaml.Io

Pretty-printing of vector and matrices.

Lacaml.Io: generic matrix printing functions.

module Context : sig ... end
val pp_mat_gen : ?⁠pp_open:(Format.formatter ‑> unit) ‑> ?⁠pp_close:(Format.formatter ‑> unit) ‑> ?⁠pp_head:(Format.formatter ‑> int ‑> unit) ‑> ?⁠pp_foot:(Format.formatter ‑> int ‑> unit) ‑> ?⁠pp_end_row:(Format.formatter ‑> int ‑> unit) ‑> ?⁠pp_end_col:(Format.formatter ‑> row:int ‑> col:int ‑> unit) ‑> ?⁠pp_left:(Format.formatter ‑> int ‑> unit) ‑> ?⁠pp_right:(Format.formatter ‑> int ‑> unit) ‑> ?⁠pad:char option ‑> ?⁠ellipsis:string ‑> ?⁠vertical_context:Context.t option ‑> ?⁠horizontal_context:Context.t option ‑> (Format.formatter ‑> 'el ‑> unit) ‑> Format.formatter ‑> ('el'a, Bigarray.fortran_layout) Bigarray.Array2.t ‑> unit

pp_mat_gen ?pp_open ?pp_close ?pp_head ?pp_foot ?pp_end_row ?pp_end_col ?pp_left ?pp_right ?pad pp_el ppf mat

Generic printing of matrices (two-dimensional bigarrays).

pp_open ppf is called whenever printing of a matrix mat is started, pp_close ppf whenever printing is complete. These functions are not called when the matrix is empty.

pp_head other_ppf col is used to print a header for column col in matrix mat. This header is right-aligned and eventually padded using Some pad-character to match the matrix rows in the column beneath. The passed formatter other_ppf is not identical to ppf!

pp_foot other_ppf col is used to print a footer for column col in matrix mat. It is similar to pp_head col other_ppf otherwise.

pp_end_row ppf row is called on row number row and formatter ppf whenever the end of a row has been reached.

pp_end_col ppf ~row ~col is called on the row number row, column number col and formatter ppf whenever the element at this position has been printed and if it is not the last element in the row.

pp_left ppf row is called on row number row and formatter ppf to print labels to the left of each row. The labels are right-aligned within a virtual column.

pp_right ppf row is called on row number row and formatter ppf to print labels to the right of each row. The labels are left-aligned.

The character pad is used to pad matrix elements for right-aligning them appropriately. If it is set to None, no alignment will be performed.

ellipsis is used as a filler when elements need to be skipped in the case of printing with contexts.

vertical_context determines the number of initial and final rows to be printed. Intermediate row will be skipped, and one row containing ellipsis elements will be printed in their place instead. None chooses no context, Some v sets the vertical context to v.

horizontal_context determines the number of initial and final columns to be printed. Intermediate columns will be skipped, and one columns containing ellipsis elements will be printed in their place instead. None chooses no context, Some h sets the horizontal context to h.

pp_el other_ppf el is called on formatter other_ppf (not ppf!) and each matrix element.

ppf is the formatter to which all output is finally printed.

mat is the matrix to be printed.

Default pretty-printers used by the other pretty-printing functions
type 'el pp_el_default = (Format.formatter ‑> 'el ‑> unit) Pervasives.ref

Type of references for default printers of elements

val pp_float_el_default : float pp_el_default

fprintf ppf "%G" el

val pp_complex_el_default : Complex.t pp_el_default

fprintf ppf "(%G, %Gi)" el.re el.im

val pp_int32_el : Format.formatter ‑> int32 ‑> unit

fprintf ppf "%ld" el

Pretty-printing in standard style
type ('el, 'elt) pp_vec = Format.formatter ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array1.t ‑> unit

Type of standard pretty-printers for column vectors

pp_vec ppf vec prints a vector vec to formatter ppf using the defaults.

val pp_fvec : (float, 'eltpp_vec
val pp_cvec : (Complex.t, 'eltpp_vec
val pp_ivec : (int32, 'eltpp_vec
val pp_rfvec : (float, 'eltpp_vec
val pp_rcvec : (Complex.t, 'eltpp_vec
val pp_rivec : (int32, 'eltpp_vec
type ('el, 'elt) pp_mat = Format.formatter ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array2.t ‑> unit

Type of standard pretty-printers for matrices

pp_mat ppf mat prints a matrix mat to formatter ppf using the defaults.

val pp_fmat : (float, 'eltpp_mat
val pp_cmat : (Complex.t, 'eltpp_mat
val pp_imat : (int32, 'eltpp_mat
Labeled pretty-printing
Vectors
type ('el, 'elt) pp_labeled_vec = ?⁠pp_head:(Format.formatter ‑> int ‑> unit) ‑> ?⁠pp_foot:(Format.formatter ‑> int ‑> unit) ‑> ?⁠pp_left:(Format.formatter ‑> int ‑> unit) option ‑> ?⁠pp_right:(Format.formatter ‑> int ‑> unit) ‑> ?⁠pad:char option ‑> ?⁠ellipsis:string ‑> ?⁠vertical_context:Context.t option ‑> ?⁠horizontal_context:Context.t option ‑> unit ‑> Format.formatter ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array1.t ‑> unit

Type of pretty-printers for labeled vectors

pp_labeled_vec ?pp_head ?pp_foot ?pp_left ?pp_right ?pad ?ellipsis ?vertical_context ?horizontal_context () ppf vec prints vector vec to formatter ppf labeling the header using function pp_head, the footer using pp_foot, the left side (of rows for column vectors; of columns for row vectors) using pp_left, and the right side using pp_right. A pad-option and context options can be passed.

For column vectors the labels on the left side are right-aligned while those on the right side are left-aligned.

val pp_labeled_fvec : (float, 'eltpp_labeled_vec
val pp_labeled_cvec : (Complex.t, 'eltpp_labeled_vec
val pp_labeled_ivec : (int32, 'eltpp_labeled_vec
val pp_labeled_rfvec : (float, 'eltpp_labeled_vec
val pp_labeled_rcvec : (Complex.t, 'eltpp_labeled_vec
val pp_labeled_rivec : (int32, 'eltpp_labeled_vec
type ('el, 'elt) pp_lvec = ?⁠print_head:bool ‑> ?⁠print_foot:bool ‑> ?⁠print_left:bool ‑> ?⁠print_right:bool ‑> ?⁠labels:string array ‑> ?⁠name:string ‑> ?⁠pad:char option ‑> ?⁠ellipsis:string ‑> ?⁠vertical_context:Context.t option ‑> ?⁠horizontal_context:Context.t option ‑> unit ‑> Format.formatter ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array1.t ‑> unit

Type of pretty-printers for string labeled vectors

pp_lvec ?print_head ?print_foot ?print_left ?print_right ?labels ?name ?pad ?ellipsis ?vertical_context ?horizontal_context () ppf vec prints vector vec to formatter ppf labeling the header with name if provided and if print_head is true, and labeling the footer with name if print_foot is true. The left side (of rows for column vectors; of columns for row vectors) is labeled with labels if provided and if print_left is true, and the right side is labeled with labels if print_right is true. A pad-option and context options can be passed.

For columns vectors the labels on the left side are right-aligned while those on the right side are left-aligned.

It is the duty of the user to make sure that the array containing the labels is sufficiently large for the given vector.

val pp_lfvec : (float, 'eltpp_lvec
val pp_lcvec : (Complex.t, 'eltpp_lvec
val pp_livec : (int32, 'eltpp_lvec
val pp_rlfvec : (float, 'eltpp_lvec
val pp_rlcvec : (Complex.t, 'eltpp_lvec
val pp_rlivec : (int32, 'eltpp_lvec
Matrices
type ('el, 'elt) pp_labeled_mat = ?⁠pp_head:(Format.formatter ‑> int ‑> unit) option ‑> ?⁠pp_foot:(Format.formatter ‑> int ‑> unit) option ‑> ?⁠pp_left:(Format.formatter ‑> int ‑> unit) option ‑> ?⁠pp_right:(Format.formatter ‑> int ‑> unit) option ‑> ?⁠pad:char option ‑> ?⁠ellipsis:string ‑> ?⁠vertical_context:Context.t option ‑> ?⁠horizontal_context:Context.t option ‑> unit ‑> Format.formatter ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array2.t ‑> unit

Type of pretty-printers for labeled matrices

pp_labeled_mat ?pp_head ?pp_foot ?pp_left ?pp_right ?pad ?ellipsis ?vertical_context ?horizontal_context () ppf mat prints a matrix mat to formatter ppf labeling the header using function pp_head, the footer using pp_foot, the left side of rows using pp_left, and the right one using pp_right. A pad-option and context options can be passed.

If None is passed as argument for the default printers, the corresponding labels will not be printed.

val pp_labeled_fmat : (float, 'eltpp_labeled_mat
val pp_labeled_cmat : (Complex.t, 'eltpp_labeled_mat
val pp_labeled_imat : (int32, 'eltpp_labeled_mat
type ('el, 'elt) pp_lmat = ?⁠print_head:bool ‑> ?⁠print_foot:bool ‑> ?⁠print_left:bool ‑> ?⁠print_right:bool ‑> ?⁠row_labels:string array ‑> ?⁠col_labels:string array ‑> ?⁠pad:char option ‑> ?⁠ellipsis:string ‑> ?⁠vertical_context:Context.t option ‑> ?⁠horizontal_context:Context.t option ‑> unit ‑> Format.formatter ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array2.t ‑> unit

Type of pretty-printers for string labeled matrices

pp_lmat ?print_head ?print_foot ?print_left ?print_right ?row_labels ?col_labels ?pad ?ellipsis ?vertical_context ?horizontal_context () ppf mat prints a matrix mat to formatter ppf labeling the header with the column labels in col_labels if provided and if print_head is true, and labeling the footer with the column labels if print_foot is true. The left side of rows is labeled with the row labels row_labels if provided and if print_left is true, and the right side of rows is labeled with the row labels if print_right is true. A pad-option and context options can be passed.

It is the duty of the user to make sure that the arrays containing the row- and column labels are sufficiently large for the given matrix.

val pp_lfmat : (float, 'eltpp_lmat
val pp_lcmat : (Complex.t, 'eltpp_lmat
val pp_limat : (int32, 'eltpp_lmat
Pretty-printing in OCaml-style
type ('el, 'elt) pp_el_ovec = Format.formatter ‑> (Format.formatter ‑> 'el ‑> unit) ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array1.t ‑> unit

Type of pretty-printers for OCaml-vectors

pp_el_ovec ppf pp_el vec prints the vector vec to formatter ppf in OCaml-style using the element printer pp_el.

val pp_ovec : ('el'eltpp_el_ovec

pp_ovec ppf pp_el vec prints the column vector vec to formatter ppf in OCaml-style using the element printer pp_el.

val pp_rovec : ('el'eltpp_el_ovec

pp_rovec ppf pp_el vec prints the row vector vec to formatter ppf in OCaml-style using the element printer pp_el.

type ('el, 'elt) pp_ovec = Format.formatter ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array1.t ‑> unit

Type of pretty-printers for OCaml-vectors of a given element type

pp_ovec ppf vec prints the vector vec to formatter ppf in OCaml-style.

val pp_ofvec : (float, 'eltpp_ovec
val pp_ocvec : (Complex.t, 'eltpp_ovec
val pp_oivec : (int32, 'eltpp_ovec
val pp_rofvec : (float, 'eltpp_ovec
val pp_rocvec : (Complex.t, 'eltpp_ovec
val pp_roivec : (int32, 'eltpp_ovec
val pp_omat : Format.formatter ‑> (Format.formatter ‑> 'el ‑> unit) ‑> ('el'c, Bigarray.fortran_layout) Bigarray.Array2.t ‑> unit

pp_omat ppf pp_el mat prints matrix mat to formatter ppf in OCaml-style using the element printer pp_el.

type ('el, 'elt) pp_omat = Format.formatter ‑> ('el'elt, Bigarray.fortran_layout) Bigarray.Array2.t ‑> unit

Type of pretty-printers for OCaml-matrices of a given element type

pp_omat ppf mat prints the matrix mat to formatter ppf in OCaml-style.

val pp_ofmat : (float, 'eltpp_omat
val pp_ocmat : (Complex.t, 'eltpp_omat
val pp_oimat : (int32, 'eltpp_omat
Good pretty-printers for toplevels

These pretty-printers will use index labels for easier identification of rows and columns.

module Toplevel : sig ... end