[Lazarus] storing big dynamic matrices in file ?

Etienne Leblois etienne.leblois at free.fr
Sun Aug 27 21:46:23 CEST 2023


Dear all,

I want to manipulate, store, later retrieve, 2-dimensions matrices of 
single or double ;

matrices may turn big and I wanted to turn to dynamic array of array

the basic solution below works, but storing (and retrieval) of big 
matrices is VERY slow.

any hint on the good way to make things quick ?


var

       fsingle : file of single;
       m : array of array of single;
       i,j,n:integer;

begin

n:=10000;

// I like i and j to run in 1..n, so I accept to loose line and column 0
setlength(m,1+n,1+n);

for i:=1 to n do for j:=1 to n do M[i,j]:=random;

assignfile(fsingle,'single_test.bin');
rewrite(fsingle);
for i:=1 to n do for j:=1 to n do   write(fsingle,M[i,j]);
closefile(fsingle);

end;

Thank you in advance,

Etienne (Lyon, France)



More information about the lazarus mailing list