25 using namespace gtsam;
33 static std::vector<double> x_vec{-3.0, 0.0, 1.0, 2.0, 3.0};
34 static std::vector<double> expected_r_vec{0.0, 0.0, 1.0, 2.0, 3.0};
36 for (
size_t i = 0;
i < x_vec.size();
i++) {
37 double x = x_vec.at(
i);
46 Matrix expected_H = gtsam::numericalDerivative11<double, double, 1>(ramp_helper,
x, 1
e-6);
53 TEST(RampFunctionPoly2, error_and_jacobian) {
56 auto ramp_helper = [&](
const double&
x) {
return p_ramp(
x); };
59 static std::vector<double> x_vec{-3.0, 0.0, 1.0, 2.0, 3.0};
60 static std::vector<double> expected_r_vec{0.0, 0.0, 0.25, 1.0, 2.0};
62 for (
size_t i = 0;
i < x_vec.size();
i++) {
63 double x = x_vec.at(
i);
65 double r = p_ramp(
x,
H);
71 Matrix expected_H = gtsam::numericalDerivative11<double, double, 1>(ramp_helper,
x, 1
e-6);
77 TEST(RampFunctionPoly3, error_and_jacobian) {
80 auto ramp_helper = [&](
const double&
x) {
return p_ramp(
x); };
83 static std::vector<double> x_vec{-3.0, 0.0, 1.0, 2.0, 3.0};
84 static std::vector<double> expected_r_vec{0.0, 0.0, 0.75, 2.0, 3.0};
86 for (
size_t i = 0;
i < x_vec.size();
i++) {
87 double x = x_vec.at(
i);
89 double r = p_ramp(
x,
H);
95 Matrix expected_H = gtsam::numericalDerivative11<double, double, 1>(ramp_helper,
x, 1
e-6);
104 auto soft_plus_helper = [&](
const double&
x) {
return soft_plus(
x); };
107 static std::vector<double> x_vec{-3.0, 0.0, 1.0, 2.0, 3.0};
108 static std::vector<double> expected_r_vec{
109 0.40282656, 1.38629436, 1.94815397, 2.62652338, 3.40282656};
111 for (
size_t i = 0;
i < x_vec.size();
i++) {
112 double x = x_vec.at(
i);
114 double r = soft_plus(
x,
H);
120 Matrix expected_H = gtsam::numericalDerivative11<double, double, 1>(soft_plus_helper,
x, 1
e-6);