Commit db1a0447 authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Removed boost::math::sign

parent 882bb8d5
......@@ -4,7 +4,7 @@
#include <Eigen/Core>
#include <limbo/tools/macros.hpp>
#include <limbo/tools/rand.hpp>
#include <limbo/tools/math.hpp>
namespace limbo {
namespace defaults {
......@@ -21,7 +21,7 @@ namespace limbo {
for (int i = 0; i < Params::init_randomsampling::samples(); i++) {
Eigen::VectorXd new_sample(StateFunction::dim_in);
for (int i = 0; i < StateFunction::dim_in; i++)
new_sample[i] = tools::rand<double>(0, 1);
new_sample[i] = tools::rand<double>(0, 1);
opt.add_new_sample(new_sample, seval(new_sample));
}
}
......
......@@ -3,8 +3,6 @@
#include <algorithm>
#include <boost/math/special_functions/sign.hpp>
#include <Eigen/Core>
#include <limbo/tools/macros.hpp>
......
......@@ -8,9 +8,10 @@
#include <Eigen/Core>
#include <limbo/tools/macros.hpp>
#include <limbo/tools/math.hpp>
namespace limbo {
namespace defaults {
namespace defaults {
struct opt_rprop {
BO_PARAM(int, iterations, 300);
};
......@@ -70,7 +71,7 @@ namespace limbo {
delta(j) = std::max(delta(j) * etaminus, deltamin);
grad(j) = 0;
}
params(j) += -boost::math::sign(grad(j)) * delta(j);
params(j) += -tools::signum(grad(j)) * delta(j);
if (bounded && params(j) < 0)
params(j) = 0;
......
......@@ -3,7 +3,7 @@
#include <limbo/tools/macros.hpp>
#include <limbo/tools/parallel.hpp>
#include <limbo/tools/rand.hpp>
#include <limbo/tools/math.hpp>
#include <limbo/tools/sys.hpp>
#endif
......@@ -34,8 +34,8 @@
//| The fact that you are presently reading this means that you have
//| had knowledge of the CeCILL license and that you accept its terms.
#ifndef LIMBO_TOOLS_RAND_HPP
#define LIMBO_TOOLS_RAND_HPP
#ifndef LIMBO_TOOLS_MATH_HPP
#define LIMBO_TOOLS_MATH_HPP
#include <cstdlib>
#include <cmath>
......@@ -113,6 +113,25 @@ namespace limbo {
++it;
return it;
}
// get sign of number
template <typename T>
inline constexpr int signum(T x, std::false_type is_signed)
{
return T(0) < x;
}
template <typename T>
inline constexpr int signum(T x, std::true_type is_signed)
{
return (T(0) < x) - (x < T(0));
}
template <typename T>
inline constexpr int signum(T x)
{
return signum(x, std::is_signed<T>());
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment