Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ project(ICATT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED)

add_subdirectory(../lib/dopri ${CMAKE_BINARY_DIR}/dopri)

Expand Down
9 changes: 5 additions & 4 deletions cpp/src/lambert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdexcept>
#include <Eigen/Dense>
#include <cmath>
#include <boost/math/special_functions/factorials.hpp>

using Eigen::Vector3d;
using std::runtime_error;
Expand All @@ -22,12 +23,12 @@ namespace lambert {
res = (cosh(sqrt(-psi)) - 1) / (-psi);
} else {
res = 1.0 / 2.0;
auto delta = (-psi) / tgamma(2 + 2 + 1);
auto delta = (-psi) / boost::math::factorial<double>(2 + 2 + 1);
auto k = 1;
while (res + delta != res) {
res += delta;
k += 1;
delta = pow(-psi, k) / tgamma(2*k + 2 + 1);
delta = pow(-psi, k) / boost::math::factorial<double>(2*k + 2 + 1);
}
}
return res;
Expand All @@ -42,12 +43,12 @@ namespace lambert {
res = (sinh(sqrt(-psi)) - sqrt(-psi)) / (-psi * sqrt(-psi));
} else {
res = 1.0 / 6.0;
auto delta = (-psi) / tgamma(2 + 3 + 1);
auto delta = (-psi) / boost::math::factorial<double>(2 + 3 + 1);
int k = 1;
while (res + delta != res) {
res += delta;
k += 1;
delta = pow(-psi, k) / tgamma(2*k + 3 + 1);
delta = pow(-psi, k) / boost::math::factorial<double>(2*k + 3 + 1);
}
}
return res;
Expand Down