本文整理汇总了C++中AD::value方法的典型用法代码示例。如果您正苦于以下问题:C++ AD::value方法的具体用法?C++ AD::value怎么用?C++ AD::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AD
的用法示例。
在下文中一共展示了AD::value方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bug_1261
// check a compilation issue with numext::max
double bug_1261() {
typedef AutoDiffScalar<Matrix2d> AD;
typedef Matrix<AD,2,1> VectorAD;
VectorAD v(0.,0.);
const AD maxVal = v.maxCoeff();
const AD minVal = v.minCoeff();
return maxVal.value() + minVal.value();
}
示例2: bug_1222
double bug_1222() {
typedef Eigen::AutoDiffScalar<Eigen::Vector3d> AD;
const double _cv1_3 = 1.0;
const AD chi_3 = 1.0;
// this line did not work, because operator+ returns ADS<DerType&>, which then cannot be converted to ADS<DerType>
const AD denom = chi_3 + _cv1_3;
return denom.value();
}
示例3: bug_1223
double bug_1223() {
using std::min;
typedef Eigen::AutoDiffScalar<Eigen::Vector3d> AD;
const double _cv1_3 = 1.0;
const AD chi_3 = 1.0;
const AD denom = 1.0;
// failed because implementation of min attempts to construct ADS<DerType&> via constructor AutoDiffScalar(const Real& value)
// without initializing m_derivatives (which is a reference in this case)
#define EIGEN_TEST_SPACE
const AD t = min EIGEN_TEST_SPACE (denom / chi_3, 1.0);
const AD t2 = min EIGEN_TEST_SPACE (denom / (chi_3 * _cv1_3), 1.0);
return t.value() + t2.value();
}
示例4: test_autodiff_scalar
void test_autodiff_scalar()
{
Vector2f p = Vector2f::Random();
typedef AutoDiffScalar<Vector2f> AD;
AD ax(p.x(),Vector2f::UnitX());
AD ay(p.y(),Vector2f::UnitY());
AD res = foo<AD>(ax,ay);
VERIFY_IS_APPROX(res.value(), foo(p.x(),p.y()));
}
示例5: test_autodiff_scalar
void test_autodiff_scalar()
{
std::cerr << foo<float>(1,2) << "\n";
typedef AutoDiffScalar<Vector2f> AD;
AD ax(1,Vector2f::UnitX());
AD ay(2,Vector2f::UnitY());
AD res = foo<AD>(ax,ay);
std::cerr << res.value() << " <> "
<< res.derivatives().transpose() << "\n\n";
}
示例6: x
template<typename Scalar> void check_atan2()
{
typedef Matrix<Scalar, 1, 1> Deriv1;
typedef AutoDiffScalar<Deriv1> AD;
AD x(internal::random<Scalar>(-3.0, 3.0), Deriv1::UnitX());
using std::exp;
Scalar r = exp(internal::random<Scalar>(-10, 10));
AD s = sin(x), c = cos(x);
AD res = atan2(r*s, r*c);
VERIFY_IS_APPROX(res.value(), x.value());
VERIFY_IS_APPROX(res.derivatives(), x.derivatives());
res = atan2(r*s+0, r*c+0);
VERIFY_IS_APPROX(res.value(), x.value());
VERIFY_IS_APPROX(res.derivatives(), x.derivatives());
}
示例7: test_autodiff_vector
void test_autodiff_vector()
{
Vector2f p = Vector2f::Random();
typedef AutoDiffScalar<Vector2f> AD;
typedef Matrix<AD,2,1> VectorAD;
VectorAD ap = p.cast<AD>();
ap.x().derivatives() = Vector2f::UnitX();
ap.y().derivatives() = Vector2f::UnitY();
AD res = foo<VectorAD>(ap);
VERIFY_IS_APPROX(res.value(), foo(p));
}
示例8: test_autodiff_vector
void test_autodiff_vector()
{
std::cerr << foo<Vector2f>(Vector2f(1,2)) << "\n";
typedef AutoDiffScalar<Vector2f> AD;
typedef Matrix<AD,2,1> VectorAD;
VectorAD p(AD(1),AD(-1));
p.x().derivatives() = Vector2f::UnitX();
p.y().derivatives() = Vector2f::UnitY();
AD res = foo<VectorAD>(p);
std::cerr << res.value() << " <> "
<< res.derivatives().transpose() << "\n\n";
}