Skip to content

Commit

Permalink
implement Clausen functions with long double precision
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Jan 19, 2020
1 parent 857fb23 commit f378b7d
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/Li1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ double Cl1(double x)
return std::real(Li1(std::exp(i*x)));
}

/**
* @brief Clausen function \f$\mathrm{Cl}_1(\theta) = \mathrm{Re}(\mathrm{Li}_1(e^{i\theta}))\f$ with long double precision
* @param x real angle
* @return \f$\mathrm{Cl}_1(\theta)\f$
*/
long double Cl1(long double x)
{
const std::complex<long double> i(0.0L, 1.0L);

return std::real(Li1(std::exp(i*x)));
}

/**
* @brief Real polylogarithm \f$\mathrm{Li}_1(x) = -\log(1-x)\f$
* @param x real argument
Expand Down
3 changes: 3 additions & 0 deletions src/Li1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace polylogarithm {
/// Clausen function with n=1
double Cl1(double);

/// Clausen function with n=1 with long double precision
long double Cl1(long double);

/// real polylogarithm with n=1
double Li1(double);

Expand Down
27 changes: 27 additions & 0 deletions src/Li2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,33 @@ double Cl2(double x)
return std::imag(Li2(std::exp(i*x)));
}

/**
* @brief Clausen function \f$\mathrm{Cl}_2(\theta) = \mathrm{Im}(\mathrm{Li}_2(e^{i\theta}))\f$ with long double precision
* @param x real angle
* @return \f$\mathrm{Cl}_2(\theta)\f$
*/
long double Cl2(long double x)
{
const long double PI = 3.14159265358979323846264338327950288L;
const std::complex<long double> i(0.0L, 1.0L);

while (x >= 2*PI) {
x -= 2*PI;
}

while (x < 0.0L) {
x += 2*PI;
}

if (std::abs(x) < std::numeric_limits<long double>::epsilon() ||
std::abs(x - PI) < std::numeric_limits<long double>::epsilon() ||
std::abs(x - 2*PI) < std::numeric_limits<long double>::epsilon()) {
return 0.0L;
}

return std::imag(Li2(std::exp(i*x)));
}

/**
* @brief Real dilogarithm \f$\mathrm{Li}_2(x)\f$
* @param x real argument
Expand Down
7 changes: 5 additions & 2 deletions src/Li2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ namespace polylogarithm {
/// Clausen function with n=2
double Cl2(double);

/// Clausen function with n=2 with long double precision
long double Cl2(long double);

/// real polylogarithm with n=2 (dilogarithm)
double Li2(double);

/// real polylogarithm with n=2 (dilogarithm)
/// real polylogarithm with n=2 (dilogarithm) with long double precision
long double Li2(long double);

/// complex polylogarithm with n=2 (dilogarithm)
std::complex<double> Li2(const std::complex<double>&);

/// complex polylogarithm with n=2 (dilogarithm)
/// complex polylogarithm with n=2 (dilogarithm) with long double precision
std::complex<long double> Li2(const std::complex<long double>&);

} // namespace polylogarithm
21 changes: 21 additions & 0 deletions src/Li3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ double Cl3(double x)
return std::real(Li3(std::exp(i*x)));
}

/**
* @brief Clausen function \f$\mathrm{Cl}_3(\theta) = \mathrm{Re}(\mathrm{Li}_3(e^{i\theta}))\f$ with long double precision
* @param x real angle
* @return \f$\mathrm{Cl}_3(\theta)\f$
*/
long double Cl3(long double x)
{
const long double PI = 3.14159265358979323846264338327950288L;
const std::complex<long double> i(0.0L, 1.0L);

while (x >= 2*PI) {
x -= 2*PI;
}

while (x < 0.0L) {
x += 2*PI;
}

return std::real(Li3(std::exp(i*x)));
}

/**
* @brief Complex trilogarithm \f$\mathrm{Li}_3(z)\f$
* @param z complex argument
Expand Down
5 changes: 4 additions & 1 deletion src/Li3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ namespace polylogarithm {
/// Clausen function with n=3
double Cl3(double);

/// Clausen function with n=3 with long double precision
long double Cl3(long double);

/// complex polylogarithm with n=3 (trilogarithm)
std::complex<double> Li3(const std::complex<double>&);

/// complex polylogarithm with n=3 (trilogarithm)
/// complex polylogarithm with n=3 (trilogarithm) with long double precision
std::complex<long double> Li3(const std::complex<long double>&);

} // namespace polylogarithm
27 changes: 27 additions & 0 deletions src/Li4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,33 @@ double Cl4(double x)
return std::imag(Li4(std::exp(i*x)));
}

/**
* @brief Clausen function \f$\mathrm{Cl}_4(\theta) = \mathrm{Im}(\mathrm{Li}_4(e^{i\theta}))\f$ with long double precision
* @param x real angle
* @return \f$\mathrm{Cl}_4(\theta)\f$
*/
long double Cl4(long double x)
{
const long double PI = 3.14159265358979323846264338327950288L;
const std::complex<long double> i(0.0L, 1.0L);

while (x >= 2*PI) {
x -= 2*PI;
}

while (x < 0.0L) {
x += 2*PI;
}

if (std::abs(x) < std::numeric_limits<long double>::epsilon() ||
std::abs(x - PI) < std::numeric_limits<long double>::epsilon() ||
std::abs(x - 2*PI) < std::numeric_limits<long double>::epsilon()) {
return 0.0L;
}

return std::imag(Li4(std::exp(i*x)));
}

/**
* @brief Complex polylogarithm \f$\mathrm{Li}_4(z)\f$
* @param z complex argument
Expand Down
3 changes: 3 additions & 0 deletions src/Li4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace polylogarithm {
/// Clausen function with n=4
double Cl4(double);

/// Clausen function with n=4 with long double precision
long double Cl4(long double);

/// complex polylogarithm with n=4
std::complex<double> Li4(const std::complex<double>&);

Expand Down
21 changes: 21 additions & 0 deletions src/Li5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@ double Cl5(double x)
return std::real(Li5(std::exp(i*x)));
}

/**
* @brief Clausen function \f$\mathrm{Cl}_5(\theta) = \mathrm{Re}(\mathrm{Li}_5(e^{i\theta}))\f$ with long double precision
* @param x real angle
* @return \f$\mathrm{Cl}_5(\theta)\f$
*/
long double Cl5(long double x)
{
const long double PI = 3.14159265358979323846264338327950288L;
const std::complex<long double> i(0.0L, 1.0L);

while (x >= 2*PI) {
x -= 2*PI;
}

while (x < 0.0L) {
x += 2*PI;
}

return std::real(Li5(std::exp(i*x)));
}

/**
* @brief Complex polylogarithm \f$\mathrm{Li}_5(z)\f$
* @param z complex argument
Expand Down
3 changes: 3 additions & 0 deletions src/Li5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace polylogarithm {
/// Clausen function with n=5
double Cl5(double);

/// Clausen function with n=5 with long double precision
long double Cl5(long double);

/// complex polylogarithm with n=5
std::complex<double> Li5(const std::complex<double>&);

Expand Down
27 changes: 27 additions & 0 deletions src/Li6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,33 @@ double Cl6(double x)
return std::imag(Li6(std::exp(i*x)));
}

/**
* @brief Clausen function \f$\mathrm{Cl}_6(\theta) = \mathrm{Im}(\mathrm{Li}_6(e^{i\theta}))\f$ with long double precision
* @param x real angle
* @return \f$\mathrm{Cl}_6(\theta)\f$
*/
long double Cl6(long double x)
{
const long double PI = 3.14159265358979323846264338327950288L;
const std::complex<long double> i(0.0L, 1.0L);

while (x >= 2*PI) {
x -= 2*PI;
}

while (x < 0.0L) {
x += 2*PI;
}

if (std::abs(x) < std::numeric_limits<long double>::epsilon() ||
std::abs(x - PI) < std::numeric_limits<long double>::epsilon() ||
std::abs(x - 2*PI) < std::numeric_limits<long double>::epsilon()) {
return 0.0L;
}

return std::imag(Li6(std::exp(i*x)));
}

/**
* @brief Complex polylogarithm \f$\mathrm{Li}_6(z)\f$
* @param z complex argument
Expand Down
3 changes: 3 additions & 0 deletions src/Li6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace polylogarithm {
/// Clausen function with n=6
double Cl6(double);

/// Clausen function with n=6 with long double precision
long double Cl6(long double);

/// complex polylogarithm with n=5
std::complex<double> Li6(const std::complex<double>&);

Expand Down

0 comments on commit f378b7d

Please sign in to comment.