removing boost_backport directory

This commit is contained in:
heisenbuug
2021-11-09 18:19:44 +05:30
parent 66b0019c8b
commit 793afa2c82
5 changed files with 90 additions and 151 deletions
@@ -1,20 +0,0 @@
# Define the files that we need to compile.
# Anything not in this list will not be compiled into mlpack.
set(SOURCES
bernoulli.hpp
detail/bernoulli_details.hpp
detail/polygamma.hpp
detail/unchecked_bernoulli.hpp
math_fwd.hpp
policy.hpp
)
# add directory name to sources
set(DIR_SRCS)
foreach(file ${SOURCES})
set(DIR_SRCS ${DIR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
endforeach()
# Append sources (with directory name) to list of all mlpack sources (used at
# parent scope).
set(MLPACK_SRCS ${MLPACK_SRCS} ${DIR_SRCS} PARENT_SCOPE)
@@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-17
View File
@@ -1,17 +0,0 @@
The files in this directory are taken from Boost 1.56.0 and Boost 1.61.0 in
order to backport:
* Trigamma and polygamma function calculation for the gamma_distribution.hpp
file (added in Boost 1.58.0, files taken from Boost 1.61.0)
These files are licensed under the Boost Software License, available in
LICENSE.txt in this directory.
If you want a copy of mlpack without a dependence on the Boost Software License,
then you will need to
* remove this entire directory
* remove the line "boost_backport" from src/mlpack/core/CMakeLists.txt
* change the line "find_package(Boost x.yy" in the root CMakeLists.txt so that
x is 1 and yy is at least 58. (That is, make mlpack require Boost 1.58 or
newer).
+35 -36
View File
@@ -19,7 +19,6 @@
namespace mlpack {
namespace math {
/**
* This function evaluates the polynomial based on the
* constants passed to the function.
@@ -63,7 +62,7 @@ EvaluatePolyLarge(const T(&a)[N], const T& x)
*/
template<std::size_t N, typename T>
typename std::enable_if<N == 7, T>::type
EvaluatePoly_1_2(const T(&a)[N], const T& x)
EvaluatePoly12(const T(&a)[N], const T& x)
{
T x2 = x * x;
T t[2];
@@ -94,7 +93,7 @@ EvaluatePoly_1_2(const T(&a)[N], const T& x)
*/
template<std::size_t N, typename T>
typename std::enable_if<N == 6, T>::type
EvaluatePoly_1_2(const T(&a)[N], const T& x)
EvaluatePoly12(const T(&a)[N], const T& x)
{
T x2 = x * x;
T t[2];
@@ -118,38 +117,38 @@ EvaluatePoly_1_2(const T(&a)[N], const T& x)
* @param x Input for which digamma will be calculated.
*/
template<typename T>
T Digamma_1_2(T x)
T Digamma12(T x)
{
T y = 0.99558162689208984F;
const T root_1 = T(1569415565) / 1073741824uL;
const T root_2 = (T(381566830) / 1073741824uL) / 1073741824uL;
const T root_3 = 0.9016312093258695918615325266959189453125e-19;
const T root1 = T(1569415565) / 1073741824uL;
const T root2 = (T(381566830) / 1073741824uL) / 1073741824uL;
const T root3 = 0.9016312093258695918615325266959189453125e-19;
const T P[] = {
0.25479851061131551,
-0.32555031186804491,
-0.65031853770896507,
-0.28919126444774784,
-0.045251321448739056,
-0.0020713321167745952
0.25479851061131551,
-0.32555031186804491,
-0.65031853770896507,
-0.28919126444774784,
-0.045251321448739056,
-0.0020713321167745952
};
const T Q[] = {
1.0,
2.0767117023730469,
1.4606242909763515,
0.43593529692665969,
0.054151797245674225,
0.0021284987017821144,
-0.55789841321675513e-6
1.0,
2.0767117023730469,
1.4606242909763515,
0.43593529692665969,
0.054151797245674225,
0.0021284987017821144,
-0.55789841321675513e-6
};
T g = x - root_1;
g -= root_2;
g -= root_3;
T g = x - root1;
g -= root2;
g -= root3;
T r = EvaluatePoly_1_2(P, T(x-1)) / EvaluatePoly_1_2(Q, T(x-1));
T r = EvaluatePoly12(P, T(x - 1)) / EvaluatePoly12(Q, T(x - 1));
T result = (g * y) + (g * r);
@@ -166,20 +165,20 @@ template<typename T>
T DigammaLarge(T x)
{
const T P[] = {
0.083333333333333333333333333333333333333333333333333,
-0.0083333333333333333333333333333333333333333333333333,
0.003968253968253968253968253968253968253968253968254,
-0.0041666666666666666666666666666666666666666666666667,
0.0075757575757575757575757575757575757575757575757576,
-0.021092796092796092796092796092796092796092796092796,
0.083333333333333333333333333333333333333333333333333,
-0.44325980392156862745098039215686274509803921568627
0.083333333333333333333333333333333333333333333333333,
-0.0083333333333333333333333333333333333333333333333333,
0.003968253968253968253968253968253968253968253968254,
-0.0041666666666666666666666666666666666666666666666667,
0.0075757575757575757575757575757575757575757575757576,
-0.021092796092796092796092796092796092796092796092796,
0.083333333333333333333333333333333333333333333333333,
-0.44325980392156862745098039215686274509803921568627
};
x -= 1;
T result = std::log(x);
result += 1 / (2 * x);
T z = 1 / (x * x);
const T z = 1 / (x * x);
result -= z * EvaluatePolyLarge(P, z);
return result;
@@ -209,7 +208,7 @@ T Digamma(T x)
// Check for evaluation of the function on poles.
T remainder = x - floor(x);
if(remainder > 0.5)
if (remainder > 0.5)
{
remainder -= 1;
}
@@ -237,14 +236,14 @@ T Digamma(T x)
result += 1 / x;
}
// If x < 1, shift to x > 1
// If x < 1, shift to x > 1.
while (x < 1)
{
result -= 1 / x;
x += 1;
}
result += Digamma_1_2(x);
result += Digamma12(x);
}
return result;
+55 -55
View File
@@ -96,75 +96,75 @@ T TrigammaPrec(T x)
{
T offset = 2.1093254089355469;
const T P_1_2[] = {
-1.1093280605946045,
-3.8310674472619321,
-3.3703848401898283,
0.28080574467981213,
1.6638069578676164,
0.64468386819102836
const T P12[] = {
-1.1093280605946045,
-3.8310674472619321,
-3.3703848401898283,
0.28080574467981213,
1.6638069578676164,
0.64468386819102836
};
const T Q12[] = {
1.0,
3.4535389668541151,
4.5208926987851437,
2.7012734178351534,
0.64468798399785611,
-0.20314516859987728e-6
};
const T P24[] = {
-0.13803835004508849e-7,
0.50000049158540261,
1.6077979838469348,
2.5645435828098254,
2.0534873203680393,
0.74566981111565923
};
const T Q24[] = {
1.0,
2.8822787662376169,
4.1681660554090917,
2.7853527819234466,
0.74967671848044792,
-0.00057069112416246805
};
const T P4INF[] = {
0.68947581948701249e-17L,
0.49999999999998975L,
1.0177274392923795L,
2.498208511343429L,
2.1921221359427595L,
1.5897035272532764L,
0.40154388356961734L
};
const T Q_1_2[] = {
1.0,
3.4535389668541151,
4.5208926987851437,
2.7012734178351534,
0.64468798399785611,
-0.20314516859987728e-6
const T Q4INF[] = {
1.0L,
1.7021215452463932L,
4.4290431747556469L,
2.9745631894384922L,
2.3013614809773616L,
0.28360399799075752L,
0.022892987908906897L
};
const T P_2_4[] = {
-0.13803835004508849e-7,
0.50000049158540261,
1.6077979838469348,
2.5645435828098254,
2.0534873203680393,
0.74566981111565923
};
const T Q_2_4[] = {
1.0,
2.8822787662376169,
4.1681660554090917,
2.7853527819234466,
0.74967671848044792,
-0.00057069112416246805
};
const T P_4_INF[] = {
0.68947581948701249e-17L,
0.49999999999998975L,
1.0177274392923795L,
2.498208511343429L,
2.1921221359427595L,
1.5897035272532764L,
0.40154388356961734L
};
const T Q_4_INF[] = {
1.0L,
1.7021215452463932L,
4.4290431747556469L,
2.9745631894384922L,
2.3013614809773616L,
0.28360399799075752L,
0.022892987908906897L
};
// For 1 < x <= 2.
if (x <= 2)
return (offset + EvaluatePolyPrec(P_1_2, x) / EvaluatePolyPrec(Q_1_2, x)) / (x * x);
return (offset + EvaluatePolyPrec(P12, x) / EvaluatePolyPrec(Q12, x)) / (x * x);
// For 2 < x <= 4.
else if (x <= 4)
{
T y = 1 / x;
return (1 + EvaluatePolyPrec(P_2_4, y) / EvaluatePolyPrec(Q_2_4, y)) / x;
return (1 + EvaluatePolyPrec(P24, y) / EvaluatePolyPrec(Q24, y)) / x;
}
// For x > 4.
T y = 1 / x;
return (1 + EvaluatePolyPrec(P_4_INF, y) / EvaluatePolyPrec(Q_4_INF, y)) / x;
return (1 + EvaluatePolyPrec(P4INF, y) / EvaluatePolyPrec(Q4INF, y)) / x;
}
/**