PsiLAB Help Manual Page

Section: High level matrix functions

Name: read_imat

Read an integer matrix in fortran format from a file.
This function reads an integer vector or matrix (2 dim) from a file in fortran format. Either the target matrix is allocated automatically with sizes determined by the file header (first line), or an already allocated matrix can be provided with the mat argument. The header in the file is necessary in the first case, optional in the second case.
[ ?mat:(int, 'a, 'b) Matrix.t ] =
read_imat
file:string
?mat:(int, 'a, 'b) Matrix.t list
?header:bool
()

The header can be discarded if the header argument is set to false.
Example:
[] let i = imatrix ~dim:[5;3] ~rand:[100] () ;; 
[] write_imat "test.dat" i () ;; 
[] let ir = read_imat "test.dat" () ;; 

Printed by PsiLAB