10 #ifndef ROL_RAISEDCOSINE_HPP
11 #define ROL_RAISEDCOSINE_HPP
14 #include "ROL_ParameterList.hpp"
30 :
mean_(mean),
var_(((var>0.) ? var : 0.5)) {}
33 mean_ = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Raised Cosine").get(
"Mean",0.5);
34 var_ = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Raised Cosine").get(
"Scale",0.5);
40 return ((input >= a && input <= b) ?
46 return ((input < a) ? 0. : ((input > b) ? 1. :
52 return ((input < a) ? 0. : ((input > b) ? input - var_ :
60 Real sa = ((fa < 0.) ? -1. : ((fa > 0.) ? 1. : 0.));
62 for (
size_t i = 0; i < 100; i++) {
65 sc = ((fc < 0.) ? -1. : ((fc > 0.) ? 1. : 0.));
66 if ( fc == 0. || (b-a)*0.5 < ROL_EPSILON<Real>() ) {
69 if ( sc == sa ) { a = c; fa = fc; sa = sc; }
77 Real am = std::pow(a,m+1), bm = std::pow(b,m+1);
79 Real val_cos = 0., val_sin = 0.;
80 for (
size_t k = 0; k < (m-1)/2; k++) {
81 val_cos += ((k%2==0) ? 1. : -1.)*
factorial(m)/(
factorial(m-2*k-1)*std::pow(omega,2+2*k))
82 *(std::pow(b,m-2*k-1)*std::cos(omega*b+phi)-std::pow(a,m-2*k-1)*std::cos(omega*a+phi));
84 for (
size_t k = 0; k < m/2; k++) {
86 *(std::pow(b,m-2*k)*std::sin(omega*b+phi)-std::pow(a,m-2*k)*std::sin(omega*a+phi));
88 return 0.5*((bm-am)/((Real)m+1) + val_cos + val_sin)/
var_;
99 void test(std::ostream &outStream = std::cout )
const {
101 std::vector<Real> X(size,0.);
102 std::vector<int> T(size,0);
103 X[0] =
mean_-
var_-4.*(Real)rand()/(Real)RAND_MAX;
107 X[2] = (2.*
var_)*(Real)rand()/(Real)RAND_MAX + (
mean_-var_);
111 X[4] =
mean_+var_+4.*(Real)rand()/(Real)RAND_MAX;
Real upperBound(void) const
Real invertCDF(const Real input) const
void test(std::ostream &outStream=std::cout) const
Real moment(const size_t m) const
Real lowerBound(void) const
Real evaluateCDF(const Real input) const
static constexpr Real pi() noexcept
RaisedCosine(const Real mean=0.5, const Real var=0.5)
size_t factorial(const size_t m) const
virtual void test(std::ostream &outStream=std::cout) const
Real evaluatePDF(const Real input) const
RaisedCosine(ROL::ParameterList &parlist)
Real integrateCDF(const Real input) const