B Seven
B Seven

Reputation: 45943

Fastest file format to save and load matrices in Octave?

I have a matrix that is about 11,000 x 1,000, saved as a csv. It takes forever to load.

What is the fastest (or recommended) format to save matrices in?

Upvotes: 2

Views: 1527

Answers (2)

gregS
gregS

Reputation: 2580

Don't forget the -binary option. For example,

save -binary myfile.mat X Y Z;  % save X, Y, and Z matrices to myfile.mat
load myfile.mat;                % load X, Y, and Z matrices from myfile.mat

When I forgot to use the -binary option, my 80,000 x 402 matrix of doubles took more than 22 minutes to load. With the -binary option, it took less than 2.5 seconds.

Upvotes: 3

Dirk is no longer here
Dirk is no longer here

Reputation: 368261

Where does the data come from?

Way back when I was in graduate school, I generated simulation data and results in a C++ program. As I owned the data, I wrote a routine to write the matrix data in the binary format expected by Octave --- and which point reading is pretty fast as it becomes a single fread call.

Upvotes: 3

Related Questions