10 #ifndef ROL_TRIANGLE_HPP
11 #define ROL_TRIANGLE_HPP
14 #include "ROL_ParameterList.hpp"
26 Triangle(
const Real a = 0.,
const Real b = 0.5,
const Real c = 1.)
27 :
a_(std::min(a,std::min(b,c))),
28 b_(std::max(std::min(a,b),std::min(std::max(a,b),c))),
29 c_(std::max(a,std::max(b,c))) {}
32 Real a = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Triangle").get(
"Lower Bound",0.);
33 Real b = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Triangle").get(
"Peak Location",0.5);
34 Real c = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Triangle").get(
"Upper Bound",1.);
35 a_ = std::min(a,std::min(b,c));
36 b_ = std::max(std::min(a,b),std::min(std::max(a,b),c));
37 c_ = std::max(a,std::max(b,c));
42 return ((input >= a_ && input < b_) ? 2.0*(input-a_)/(d*d1) :
43 ((input >= b_ && input <
c_) ? 2.0*(
c_-input)/(d*d2) :
49 return ((input < a_) ? 0.0 :
50 ((input >= a_ && input < b_) ?
51 std::pow(input-a_,2.0)/(d*d1) :
52 ((input >= b_ && input <
c_) ?
53 1.0-std::pow(
c_-input,2.0)/(d*d2) :
59 return ((input < a_) ? 0.0 :
60 ((input >= a_ && input < b_) ?
61 std::pow(input-a_,3.0)/(3.0*d*d1) :
62 ((input >= b_ && input <
c_) ?
63 d1*d1/(3.0*d)+(input-b_)+(std::pow(
c_-input,3.0)-d2*d2*d2)/(3.0*d*d2) :
64 d1*d1/(3.0*d)+(input-b_)-d2*d2/(3.0*d))));
69 return ((input <= d1/d) ? a_ + std::sqrt(input*d1*d) :
70 c_ - std::sqrt((1.0-input)*d2*d));
75 Real am1 = std::pow(a_,m+1), am2 = a_*am1;
76 Real bm1 = std::pow(b_,m+1), bm2 = b_*bm1;
77 Real cm1 = std::pow(
c_,m+1), cm2 =
c_*cm1;
78 return (2./d)*(((bm2-am2)/((Real)m+2)-a_*(bm1-am1)/((Real)m+1))/d1
79 +(
c_*(cm1-bm1)/((Real)m+1)-(cm2-bm2)/((Real)m+2))/d2);
90 void test(std::ostream &outStream = std::cout )
const {
92 std::vector<Real> X(size,0.);
93 std::vector<int> T(size,0);
94 X[0] =
a_-4.*(Real)rand()/(Real)RAND_MAX;
98 X[2] = (
b_-
a_)*(Real)rand()/(Real)RAND_MAX +
a_;
102 X[4] = (
c_-
b_)*(Real)rand()/(Real)RAND_MAX +
b_;
106 X[6] =
c_+4.*(Real)rand()/(Real)RAND_MAX;
void test(std::ostream &outStream=std::cout) const
Triangle(const Real a=0., const Real b=0.5, const Real c=1.)
Real moment(const size_t m) const
Real upperBound(void) const
Real integrateCDF(const Real input) const
Real lowerBound(void) const
Real invertCDF(const Real input) const
virtual void test(std::ostream &outStream=std::cout) const
Real evaluatePDF(const Real input) const
Triangle(ROL::ParameterList &parlist)
Real evaluateCDF(const Real input) const