45 template <
typename ScalarT>
46 ScalarT
func(
const ScalarT&
a,
const ScalarT& b,
const ScalarT&
c) {
53 template <
typename ScalarT>
54 void func_deriv(
const ScalarT&
a,
const ScalarT& b,
const ScalarT&
c,
55 ScalarT& drda, ScalarT& drdb)
64 int main(
int argc,
char **argv)
84 std::cout <<
"Flop counts for function evaluation:";
93 std::cout <<
"\nFlop counts for analytic derivative evaluation:";
104 std::cout <<
"\nFlop counts for AD function and derivative evaluation:";
109 double drda = drdas.
val();
110 double drdb = drdbs.
val();
112 double r_ad = rfad.val().val();
113 double drda_ad = rfad.dx(0).val();
114 double drdb_ad = rfad.dx(1).val();
119 std::cout.setf(std::ios::scientific);
120 std::cout.precision(p);
121 std::cout <<
"\nValues/derivatives of computation" << std::endl
122 <<
" r = " << r <<
" (original) == " << std::setw(w) << r_ad
123 <<
" (AD) Error = " << std::setw(w) << r - r_ad << std::endl
124 <<
"dr/da = " << std::setw(w) << drda <<
" (analytic) == "
125 << std::setw(w) << drda_ad <<
" (AD) Error = " << std::setw(w)
126 << drda - drda_ad << std::endl
127 <<
"dr/db = " << std::setw(w) << drdb <<
" (analytic) == "
128 << std::setw(w) << drdb_ad <<
" (AD) Error = " << std::setw(w)
129 << drdb - drdb_ad << std::endl;
131 double tol = 1.0e-14;
140 std::cout <<
"\nExample passed!" << std::endl;
144 std::cout <<
"\nSomething is wrong, example failed!" << std::endl;
double totalFlopCount
Total flop count.
static FlopCounts getCounters()
Get the flop counts after a block of computations.
static void resetCounters()
Reset static flop counters before starting a block of computations.
const T & val() const
Return the current value.
KOKKOS_INLINE_FUNCTION mpl::enable_if_c< ExprLevel< Expr< T1 > >::value==ExprLevel< Expr< T2 > >::value, Expr< PowerOp< Expr< T1 >, Expr< T2 > > > >::type pow(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
static std::ostream & printCounters(std::ostream &out)
Print the current static flop counts to out.
Class storing flop counts and summary flop counts.
TypeTo as(const TypeFrom &t)
void func_deriv(double a, double b, double c, double &drda, double &drdb)
Templated flop counter class.
Sacado::Fad::DFad< SFC > FAD_SFC
const T func(int n, T *x)
static void finalizeCounters()
Finalize total flop count after block of computations.
Sacado::FlopCounterPack::ScalarFlopCounter< double > SFC