I am new to C and I have problems with array types when embedding in structures. Below is an example of my problem:
typedef struct {
double J[151][151];
} *UserData;
static int PSolve(void *user_data, N_Vector solution)
{
UserData data;
data = (UserData) user_data;
double J[151][151];
J = data->J;
return(0);
}
When I try to compile this, I get an error: incompatible types when assigned to type 'double [151] [151] from type' double (*) [151]
My current workaround for this is to replace “J [x] [y]” with “data-> J [x] [y]” in the code to solve the matrix equation, but profiling has shown that this is less efficient.,
Changing the arguments to PSolve is not an option, because I use the sundials-cvode solver, which prescribes the type and order of the arguments.
source
share