Page
Library
Module
Module type
Parameter
Class
Class type
Source
Lacaml.Io
SourcePretty-printing of vectors and matrices.
Lacaml.Io
: generic matrix printing functions.
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.
Type of references for default printers of elements
fprintf ppf "%G" el
fprintf ppf "(%G, %Gi)" el.re el.im
fprintf ppf "%ld" el
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.
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.
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.
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.
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.
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.
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
.
pp_ovec ppf pp_el vec
prints the column vector vec
to formatter ppf
in OCaml-style using the element printer pp_el
.
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_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.
These pretty-printers will use index labels for easier identification of rows and columns.