(if necessary slicing the fixed sized matrix into a dynamic array of dynamic arrays).

It's not hard to convert a fixed sized matrix into this run-time value that requires no templating on the sizes and requires no slicing and no heap allocations inside the template function that performs just the compile-time tests:

struct Mat2D(T) {
    T* ptr;
    size_t nrows, ncols;
    // + indexing methods
}

Using something like that the matrix multiplication function I've shown becomes just a shell that calls a function that accepts two Mat2D and is templated only on T.

Bye,
bearophile

Reply via email to