Reputation: 83
The following code:
#include <codi.hpp>
...
codi::RealForward Gcodi[l];
for (int p = 0; p < l; p++)
{
...
double a = Gcodi[p];
}
gives me the compilation error:
nnBFAD.cpp: In function ‘void OptBF()’:
nnBFAD.cpp:156:25: error: cannot convert ‘codi::RealForward {aka codi::ActiveReal >}’ to ‘double’ in initialization double
a = Gcodi[p];
Hints?
Upvotes: 3
Views: 193
Reputation: 83
I've found a function for that: getValue()
double a = Gcodi[p].getValue();
like stated in: https://www.scicomp.uni-kl.de/codi/d5/dbb/Tutorial1.html
Upvotes: 0
Reputation: 48258
According to the official doc here,
RealForward
is a type with an assignment operator overloaded, so you can assign that with a double..
like doing
codi::RealForward a = 3.0;
the opposite direction is of course not defined,
that is the raeson why you can not convert directly a codi::RealForward into a double just by doing:
double a = Gcodi[p];
but you can call the functions on that, i.e.
double a = Gcodi[p].getGradient();
UPDATE:
then you can assign a RealForward object with a double like doing
double myDouble{3.3};
RealForward a = myDouble;
but is not legal to assign a double directly from the REalForwad:
RealForward a = ...;
double myDouble = a; //not valid!
other examples
RealForward b = a * a; //this is ok because a * a is a double
Upvotes: 1