Created
November 12, 2018 04:14
-
-
Save ahmadyan/07b24d0fd3333ce3416f98683a68bd95 to your computer and use it in GitHub Desktop.
Rosenbrock function example for auto-differentiation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rosenbrock function, a = 1.0, b = 100 | |
class Rosenbrock { | |
public: | |
template <typename T> | |
bool operator()(const T *const x, const T *const y, T *cost) const { | |
cost[0] = (T(1.0) - x[0]) * (T(1.0) - x[0]) + | |
T(100.0) * (y[0] - x[0] * x[0]) * (y[0] - x[0] * x[0]); | |
return true; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment