commit
d5df7ab935
@ -205,6 +205,10 @@ public:
|
|||||||
static Scalar exp(Scalar arg)
|
static Scalar exp(Scalar arg)
|
||||||
{ return std::exp(arg); }
|
{ return std::exp(arg); }
|
||||||
|
|
||||||
|
//! The 10 logarithm of a value
|
||||||
|
static Scalar log10(Scalar arg)
|
||||||
|
{ return std::log10(arg); }
|
||||||
|
|
||||||
//! The natural logarithm of a value
|
//! The natural logarithm of a value
|
||||||
static Scalar log(Scalar arg)
|
static Scalar log(Scalar arg)
|
||||||
{ return std::log(arg); }
|
{ return std::log(arg); }
|
||||||
@ -319,6 +323,10 @@ template <class Evaluation>
|
|||||||
Evaluation log(const Evaluation& value)
|
Evaluation log(const Evaluation& value)
|
||||||
{ return Opm::MathToolbox<Evaluation>::log(value); }
|
{ return Opm::MathToolbox<Evaluation>::log(value); }
|
||||||
|
|
||||||
|
template <class Evaluation>
|
||||||
|
Evaluation log10(const Evaluation& value)
|
||||||
|
{ return Opm::MathToolbox<Evaluation>::log10(value); }
|
||||||
|
|
||||||
template <class Evaluation1, class Evaluation2>
|
template <class Evaluation1, class Evaluation2>
|
||||||
typename ReturnEval_<Evaluation1, Evaluation2>::type
|
typename ReturnEval_<Evaluation1, Evaluation2>::type
|
||||||
pow(const Evaluation1& base, const Evaluation2& exp)
|
pow(const Evaluation1& base, const Evaluation2& exp)
|
||||||
|
@ -399,6 +399,24 @@ Evaluation<ValueType, numVars, staticSize> log(const Evaluation<ValueType, numVa
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class ValueType, int numVars, unsigned staticSize>
|
||||||
|
Evaluation<ValueType, numVars, staticSize> log10(const Evaluation<ValueType, numVars, staticSize>& x)
|
||||||
|
{
|
||||||
|
typedef MathToolbox<ValueType> ValueTypeToolbox;
|
||||||
|
|
||||||
|
Evaluation<ValueType, numVars, staticSize> result(x);
|
||||||
|
|
||||||
|
result.setValue(ValueTypeToolbox::log10(x.value()));
|
||||||
|
|
||||||
|
// derivatives use the chain rule
|
||||||
|
const ValueType& df_dx = 1/x.value() * ValueTypeToolbox::log10(ValueTypeToolbox::exp(1.0));
|
||||||
|
for (int curVarIdx = 0; curVarIdx < result.size(); ++curVarIdx)
|
||||||
|
result.setDerivative(curVarIdx, df_dx*x.derivative(curVarIdx));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace DenseAd
|
} // namespace DenseAd
|
||||||
|
|
||||||
// a kind of traits class for the automatic differentiation case. (The toolbox for the
|
// a kind of traits class for the automatic differentiation case. (The toolbox for the
|
||||||
@ -513,6 +531,9 @@ public:
|
|||||||
static Evaluation log(const Evaluation& arg)
|
static Evaluation log(const Evaluation& arg)
|
||||||
{ return Opm::DenseAd::log(arg); }
|
{ return Opm::DenseAd::log(arg); }
|
||||||
|
|
||||||
|
static Evaluation log10(const Evaluation& arg)
|
||||||
|
{ return Opm::DenseAd::log10(arg); }
|
||||||
|
|
||||||
template <class RhsValueType>
|
template <class RhsValueType>
|
||||||
static Evaluation pow(const Evaluation& arg1, const RhsValueType& arg2)
|
static Evaluation pow(const Evaluation& arg1, const RhsValueType& arg2)
|
||||||
{ return Opm::DenseAd::pow(arg1, arg2); }
|
{ return Opm::DenseAd::pow(arg1, arg2); }
|
||||||
|
@ -572,6 +572,11 @@ struct TestEnvBase
|
|||||||
static_cast<Scalar (*)(Scalar)>(std::log),
|
static_cast<Scalar (*)(Scalar)>(std::log),
|
||||||
1e-6, 1e9);
|
1e-6, 1e9);
|
||||||
|
|
||||||
|
std::cout << " Testing log10()\n";
|
||||||
|
test1DFunction(Opm::DenseAd::log10<Scalar, numVars, staticSize>,
|
||||||
|
static_cast<Scalar (*)(Scalar)>(std::log10),
|
||||||
|
1e-6, 1e9);
|
||||||
|
|
||||||
while (false) {
|
while (false) {
|
||||||
Scalar val1 OPM_UNUSED = 0.0;
|
Scalar val1 OPM_UNUSED = 0.0;
|
||||||
Scalar val2 OPM_UNUSED = 1.0;
|
Scalar val2 OPM_UNUSED = 1.0;
|
||||||
@ -622,6 +627,8 @@ struct TestEnvBase
|
|||||||
resultEval = Opm::sqrt(eval1);
|
resultEval = Opm::sqrt(eval1);
|
||||||
resultEval = Opm::exp(eval1);
|
resultEval = Opm::exp(eval1);
|
||||||
resultEval = Opm::log(eval1);
|
resultEval = Opm::log(eval1);
|
||||||
|
resultEval = Opm::log10(eval1);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user