5 ms·
> // set a value at an arbitrary index > // this will expand and zero-fill the vector to fit > vector_set(&vector, 4452, 21312984); Love to see a C article w
by zeteo 14y ago
> // set a value at an arbitrary index
> // this will expand and zero-fill the vector to fit
> vector_set(&vector, 4452, 21312984);
Love to see a C article where we get some insight on how dynamic arrays might work behind the scenes. But sparse arrays are best implemented as linked lists or hash tables.
- Mooby 14y agoNot true. While the "domain of keys" format is implemented through a list of tuples, the compressed row/column/diagonal storage data types, which are the formats used in popular matrix algebra/solver packages, are implemented as three arrays. The data structure scheme you've described is only used in a single application: populating a sparse matrix. Then, in any application where a minimum amount of efficiency is required, that data is converted to one of the formats I've mentioned before, and no format you've described is actually used beyond that corner case.