44 #ifndef ROL_RAISEDCOSINE_HPP
45 #define ROL_RAISEDCOSINE_HPP
48 #include "ROL_ParameterList.hpp"
64 :
mean_(mean),
var_(((var>0.) ? var : 0.5)) {}
67 mean_ = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Raised Cosine").get(
"Mean",0.5);
68 var_ = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Raised Cosine").get(
"Scale",0.5);
74 return ((input >= a && input <= b) ?
80 return ((input < a) ? 0. : ((input > b) ? 1. :
86 return ((input < a) ? 0. : ((input > b) ? input - var_ :
94 Real sa = ((fa < 0.) ? -1. : ((fa > 0.) ? 1. : 0.));
96 for (
size_t i = 0; i < 100; i++) {
99 sc = ((fc < 0.) ? -1. : ((fc > 0.) ? 1. : 0.));
100 if ( fc == 0. || (b-a)*0.5 < ROL_EPSILON<Real>() ) {
103 if ( sc == sa ) { a = c; fa = fc; sa = sc; }
111 Real am = std::pow(a,m+1), bm = std::pow(b,m+1);
113 Real val_cos = 0., val_sin = 0.;
114 for (
size_t k = 0; k < (m-1)/2; k++) {
115 val_cos += ((k%2==0) ? 1. : -1.)*
factorial(m)/(
factorial(m-2*k-1)*std::pow(omega,2+2*k))
116 *(std::pow(b,m-2*k-1)*std::cos(omega*b+phi)-std::pow(a,m-2*k-1)*std::cos(omega*a+phi));
118 for (
size_t k = 0; k < m/2; k++) {
119 val_sin += ((k%2==0) ? 1. : -1.)*
factorial(m)/(
factorial(m-2*k)*std::pow(omega,1+2*k))
120 *(std::pow(b,m-2*k)*std::sin(omega*b+phi)-std::pow(a,m-2*k)*std::sin(omega*a+phi));
122 return 0.5*((bm-am)/((Real)m+1) + val_cos + val_sin)/
var_;
133 void test(std::ostream &outStream = std::cout )
const {
135 std::vector<Real> X(size,0.);
136 std::vector<int> T(size,0);
137 X[0] =
mean_-
var_-4.*(Real)rand()/(Real)RAND_MAX;
141 X[2] = (2.*
var_)*(Real)rand()/(Real)RAND_MAX + (
mean_-var_);
145 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