本文整理汇总了C++中SymEngine::max方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::max方法的具体用法?C++ SymEngine::max怎么用?C++ SymEngine::max使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymEngine
的用法示例。
在下文中一共展示了SymEngine::max方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: REQUIRE
eval_mpfr(a, *r, MPFR_RNDN);
// Check that value of `r` (`a`) starts with 0.00000000490153
REQUIRE(mpfr_cmp_d(a, 0.00000000490153) == 1);
REQUIRE(mpfr_cmp_d(a, 0.00000000490154) == -1);
s = mul(E, integer(100000));
t = integer(271828);
r = div(sub(s, t), integer(100000000));
eval_mpfr(a, *r, MPFR_RNDN);
// Check that value of `r` (`a`) starts with 0.00000000182845
REQUIRE(mpfr_cmp_d(a, 0.00000000182845) == 1);
REQUIRE(mpfr_cmp_d(a, 0.00000000182846) == -1);
r = max({integer(3), integer(2)});
eval_mpfr(a, *r, MPFR_RNDN);
REQUIRE(mpfr_cmp_d(a, 3.00000000000001) == -1);
REQUIRE(mpfr_cmp_d(a, 2.99999999999999) == 1);
r = min({sqrt(integer(3)), sqrt(integer(2))});
eval_mpfr(a, *r, MPFR_RNDN);
REQUIRE(mpfr_cmp_d(a, 1.41421356238) == -1);
REQUIRE(mpfr_cmp_d(a, 1.41421356236) == 1);
r = loggamma(E);
eval_mpfr(a, *r, MPFR_RNDN);
REQUIRE(mpfr_cmp_d(a, 0.44946174183) == -1);
REQUIRE(mpfr_cmp_d(a, 0.44946174181) == 1);
示例2: csch
csch(r4)),
acsch(r3)),
7.336249966045},
{add(add(sinh(one), add(cosh(one), add(tanh(one), coth(one)))),
sech(r3)),
5.773239267559},
{sub(add(add(asinh(r4), add(acosh(r4), add(atanh(r3), acoth(r4)))),
sech(r4)),
acsch(r4)),
4.825120290814},
{SymEngine::abs(log(div(pi, mul(E, integer(2))))), 0.548417294710},
{SymEngine::atan2(r1, neg(r2)), 2.08867384922582},
{mul(pi, mul(E, EulerGamma)), 4.92926836742289},
{pow(mul(EulerGamma, r4), integer(8)), 4813.54354505117582},
{mul(EulerGamma, integer(10)), 5.7721566490153286},
{max({r2, r1}), 0.841470984808},
{min({add(r1, r4), r2}), 0.479425538604},
{gamma(div(integer(4), integer(3))), 0.892979511569249211},
{loggamma(div(integer(7), integer(2))), 1.200973602347074224},
{loggamma(pi), 0.82769459232343710152},
{add(asech(div(one, integer(2))), real_double(0.1)), 1.41695789692482},
{r5, 0.841470984807897},
};
for (unsigned i = 0; i < vec.size(); i++) {
double val = eval_double(*vec[i].first);
std::cout.precision(12);
std::cout << vec[i].first->__str__() << " ~ " << val << std::endl;
REQUIRE(::fabs(val - vec[i].second) < 1e-12);
}
示例3: symbol
x = symbol("x");
y = symbol("y");
z = symbol("z");
r = add(x, add(mul(y, z), pow(x, integer(2))));
LambdaRealDoubleVisitor v;
v.init({x, y, z}, *r);
d = v.call({1.5, 2.0, 3.0});
REQUIRE(::fabs(d - 9.75) < 1e-12);
d = v.call({1.5, -1.0, 2.0});
REQUIRE(::fabs(d - 1.75) < 1e-12);
r = max({x, add(mul(y, z), integer(3))});
v.init({x, y, z}, *r);
d = v.call({4.0, 1.0, 2.5});
REQUIRE(::fabs(d - 5.5) < 1e-12);
r = min({pow(x, y), add(mul(y, z), integer(3))});
v.init({x, y, z}, *r);
d = v.call({4.0, 2.0, 2.5});
REQUIRE(::fabs(d - 8.0) < 1e-12);
// Evaluating to double when there are complex doubles raise an exception
CHECK_THROWS_AS(
v.init({x}, *add(complex_double(std::complex<double>(1, 2)), x)),
std::runtime_error);