Tamalero
Tamalero

Reputation: 471

Saving memory, huge array alternative c programming

I'm using an two arrays (unsigned int) with dimensions: 20000x20000.

I have a lot of empty spacing inside the arrays, many zeros or nulls.

There is something I can do to save memory?, because I'm running out of it.

I tried reading from a list in a file, but it's extremely slow.

I have heard that in other languages they have vectors.

Upvotes: 0

Views: 206

Answers (1)

merlin2011
merlin2011

Reputation: 75545

You are looking for a sparse matrix, which basically works by storing entries as a list of (index1, index2, value), and only has entries for nonzero elements.

Upvotes: 3

Related Questions