9 #include <generators/utilities/beamHelpers.h>
10 #include <gtest/gtest.h>
19 class DualNumbersTests :
public ::testing::Test {
23 virtual void SetUp() { }
26 virtual void TearDown() { }
31 TEST_F(DualNumbersTests, TestDerivatives)
35 EXPECT_NEAR(
tan(x0).x, 0, 1e-15);
36 EXPECT_NEAR(
tan(x0).dx, 1, 1e-15);
38 EXPECT_NEAR(
atan(x0).x, 0, 1e-15);
39 EXPECT_NEAR(
atan(x0).dx, 1., 1e-15);
43 EXPECT_NEAR(
sqrt(x4).x, 2, 1e-15);
44 EXPECT_NEAR(
sqrt(x4).dx, 1. / 4, 1e-15);
48 EXPECT_NEAR((
tan(x0) * x0).x, 0, 1e-15);
49 EXPECT_NEAR((
tan(x0) * x0).dx, 0, 1e-15);
54 EXPECT_NEAR((
tan(xPi) / xPi).x, 0, 1e-15);
55 EXPECT_NEAR((
tan(xPi) / xPi).dx, 1. / M_PI, 1e-15);
60 TEST_F(DualNumbersTests, TestVectorDerivatives)
64 EXPECT_NEAR((-1.0 /
sqrt(r.norm2())).x, -1. /
sqrt(3), 1e-15);
65 EXPECT_NEAR((-1.0 /
sqrt(r.norm2())).dx, 1. / (3 *
sqrt(3)), 1e-15);
67 EXPECT_NEAR(
dot(r, r).x, r.norm2().x, 1e-15);
68 EXPECT_NEAR(
dot(r, r).dx, 2., 1e-15);
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
double sqrt(double a)
sqrt for double
double atan(double a)
atan for double
T dot(GeneralVector< T > a, GeneralVector< T > b)
dot product of two general vectors
double tan(double a)
tan for double
Abstract base class for different kinds of events.
Simple structure implementing dual numbers which are used for exact evaluation of the derivatives,...
3-vector with members of arbitrary type, especially members can be dual numbers