|
|
|
|
|
by silentvoice
4355 days ago
|
|
I actually believe this is the preferable approach for performance portability reasons. It's easier to reason about cache /vectorization performance across architectures and compilers when dealing with a single pointer and calculated indices. If you absolutely have to have a pointer to say the first element of a row (resp. column if using column major) you can always do this: double* dmatrix_get_row(struct dmatrix* m, size_t r){
return &m->data[r*m->cols];
}
A pointer-to-pointer approach I think is most suitable for an actual array-of-arrays, where the length of each subarray can be different. Then you store an array of pointers to the first element of each subarray, and if the data is contiguous you can use that to calculate lengths as well. |
|