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 ] =
?mat:(int, 'a, 'b) Matrix.t list

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

Printed by PsiLAB