Let's say I have an array of arrays of function pointers. In other words, I might want to call a matrix transpose function like so, depending upon what dtype my matrix is:
Transp[dtype][index_dtype](A.ia, A.a, B.ia, B.a);
Functions in Transp might look like this:
void transp_i64_i8(const int64_t* ia, const int8_t* a, int64_t* ib, int8_t* b) {
// transpose here
return;
}
except varying the pointer types.
It seems to me that I should declare my function pointer array like so:
void (**Transp)(const void* ia, const void* a, const void* ib, const void* b)[DTYPES_MAX][INDEX_TYPES_MAX] = {
{transp_i8_i8, transp_i8_i16, transp_i8_i32, /* ... */ },
{transp_i16_i8, transp_i16_i16, /* ... */ },
{transp_i32_i8, transp_i32_i16, /* ... */ },
/* ... */
}
Unfortunately this doesn't seem to work:
error: called object ‘Transp[(int)self_m->storage->dtype][(int)((struct YALE_STORAGE *)self_m->storage)->index_dtype]’ is not a function
../../../../ext/nmatrix/nmatrix.c: In function ‘nm_complex_conjugate_bang’:
../../../../ext/nmatrix/nmatrix.c:1910:32: error: subscripted value is neither array nor pointer nor vector
I found one fairly useful reference, but I really need an example for my exact use-case to understand and apply.
So what, exactly, is the correct way to define an array of arrays of function pointers? Specifically, how is the declaration portion written?
(I realize this can be done with a typedef much more easily, but I'm writing a code generator, and would rather not use a typedef.)