mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -15,36 +15,36 @@
|
||||
* TODO add more tests!
|
||||
*/
|
||||
|
||||
template<typename Scalar> void check_atan2()
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
res = atan2(r * s + 0, r * c + 0);
|
||||
VERIFY_IS_APPROX(res.value(), x.value());
|
||||
VERIFY_IS_APPROX(res.derivatives(), x.derivatives());
|
||||
}
|
||||
|
||||
template<typename Scalar> void check_hyperbolic_functions()
|
||||
{
|
||||
using std::sinh;
|
||||
template <typename Scalar>
|
||||
void check_hyperbolic_functions() {
|
||||
using std::cosh;
|
||||
using std::sinh;
|
||||
using std::tanh;
|
||||
typedef Matrix<Scalar, 1, 1> Deriv1;
|
||||
typedef AutoDiffScalar<Deriv1> AD;
|
||||
Deriv1 p = Deriv1::Random();
|
||||
AD val(p.x(),Deriv1::UnitX());
|
||||
AD val(p.x(), Deriv1::UnitX());
|
||||
|
||||
Scalar cosh_px = std::cosh(p.x());
|
||||
AD res1 = tanh(val);
|
||||
@@ -60,8 +60,8 @@ template<typename Scalar> void check_hyperbolic_functions()
|
||||
VERIFY_IS_APPROX(res3.derivatives().x(), std::sinh(p.x()));
|
||||
|
||||
// Check constant values.
|
||||
const Scalar sample_point = Scalar(1) / Scalar(3);
|
||||
val = AD(sample_point,Deriv1::UnitX());
|
||||
const Scalar sample_point = Scalar(1) / Scalar(3);
|
||||
val = AD(sample_point, Deriv1::UnitX());
|
||||
res1 = tanh(val);
|
||||
VERIFY_IS_APPROX(res1.derivatives().x(), Scalar(0.896629559604914));
|
||||
|
||||
@@ -73,8 +73,7 @@ template<typename Scalar> void check_hyperbolic_functions()
|
||||
}
|
||||
|
||||
template <typename Scalar>
|
||||
void check_limits_specialization()
|
||||
{
|
||||
void check_limits_specialization() {
|
||||
typedef Eigen::Matrix<Scalar, 1, 1> Deriv;
|
||||
typedef Eigen::AutoDiffScalar<Deriv> AD;
|
||||
|
||||
@@ -87,13 +86,12 @@ void check_limits_specialization()
|
||||
VERIFY(bool(std::is_base_of<B, A>::value));
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(autodiff_scalar)
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1( check_atan2<float>() );
|
||||
CALL_SUBTEST_2( check_atan2<double>() );
|
||||
CALL_SUBTEST_3( check_hyperbolic_functions<float>() );
|
||||
CALL_SUBTEST_4( check_hyperbolic_functions<double>() );
|
||||
CALL_SUBTEST_5( check_limits_specialization<double>());
|
||||
EIGEN_DECLARE_TEST(autodiff_scalar) {
|
||||
for (int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1(check_atan2<float>());
|
||||
CALL_SUBTEST_2(check_atan2<double>());
|
||||
CALL_SUBTEST_3(check_hyperbolic_functions<float>());
|
||||
CALL_SUBTEST_4(check_hyperbolic_functions<double>());
|
||||
CALL_SUBTEST_5(check_limits_specialization<double>());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user