The code
```
double f(double const* const x, std::size_t const n)
{
double acc{};
for (std::size_t i = 0; i < n; ++i)
acc += x[i] * x[i];
return acc;
}
int main()
{
auto g = clad::gradient(f, "x[0:1]");
std::vector<double> x = { 3, 4 },
dx(x.size());
g.execute(x.data(), x.size(), dx.data());
std::cout << dx[0] << std::endl;
return 0;
}
```
produces the following error:
> member reference base type 'double' is not a structure or union.
When I change the definition of `f` to
```
double f(double const* const x, std::size_t const n)
{
double acc = x[0] * x[0];
for (std::size_t i = 1; i < n; ++i)
acc += x[i] * x[i];
return acc;
}
```
then everything works fine. Can this problem be solved somehow?
The code
produces the following error:
When I change the definition of
f
tothen everything works fine. Can this problem be solved somehow?