44 #ifndef ROL_TRIANGLE_HPP 45 #define ROL_TRIANGLE_HPP 48 #include "Teuchos_ParameterList.hpp" 60 Triangle(
const Real a = 0.,
const Real b = 0.5,
const Real c = 1.)
61 : a_(std::min(a,std::min(b,c))),
62 b_(std::max(std::min(a,b),std::min(std::max(a,b),c))),
63 c_(std::max(a,std::max(b,c))) {}
66 Real a = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Triangle").get(
"Lower Bound",0.);
67 Real b = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Triangle").get(
"Peak Location",0.5);
68 Real c = parlist.sublist(
"SOL").sublist(
"Distribution").sublist(
"Triangle").get(
"Upper Bound",1.);
69 a_ = std::min(a,std::min(b,c));
70 b_ = std::max(std::min(a,b),std::min(std::max(a,b),c));
71 c_ = std::max(a,std::max(b,c));
75 Real d1 = b_-
a_, d2 = c_-
b_, d = c_-
a_;
76 return ((input >= a_ && input < b_) ? 2.0*(input-a_)/(d*d1) :
77 ((input >= b_ && input < c_) ? 2.0*(c_-input)/(d*d2) :
82 Real d1 = b_-
a_, d2 = c_-
b_, d = c_-
a_;
83 return ((input < a_) ? 0.0 :
84 ((input >= a_ && input < b_) ?
85 std::pow(input-a_,2.0)/(d*d1) :
86 ((input >= b_ && input < c_) ?
87 1.0-std::pow(c_-input,2.0)/(d*d2) :
92 Real d1 = b_-
a_, d2 = c_-
b_, d = c_-
a_;
93 return ((input < a_) ? 0.0 :
94 ((input >= a_ && input < b_) ?
95 std::pow(input-a_,3.0)/(3.0*d*d1) :
96 ((input >= b_ && input < c_) ?
97 d1*d1/(3.0*d)+(input-b_)+(std::pow(c_-input,3.0)-d2*d2*d2)/(3.0*d*d2) :
98 d1*d1/(3.0*d)+(input-b_)-d2*d2/(3.0*d))));
102 Real d1 = b_-
a_, d2 = c_-
b_, d = c_-
a_;
103 return ((input <= d1/d) ? a_ + std::sqrt(input*d1*d) :
104 c_ - std::sqrt((1.0-input)*d2*d));
108 Real d1 = b_-
a_, d2 = c_-
b_, d = c_-
a_;
109 Real am1 = std::pow(a_,m+1), am2 = a_*am1;
110 Real bm1 = std::pow(b_,m+1), bm2 = b_*bm1;
111 Real cm1 = std::pow(c_,m+1), cm2 = c_*cm1;
112 return (2./d)*(((bm2-am2)/((Real)m+2)-a_*(bm1-am1)/((Real)m+1))/d1
113 +(c_*(cm1-bm1)/((Real)m+1)-(cm2-bm2)/((Real)m+2))/d2);
124 void test(std::ostream &outStream = std::cout )
const {
126 std::vector<Real> X(size,0.);
127 std::vector<int> T(size,0);
128 X[0] = a_-4.*(Real)rand()/(Real)RAND_MAX;
132 X[2] = (b_-
a_)*(Real)rand()/(Real)RAND_MAX + a_;
136 X[4] = (c_-
b_)*(Real)rand()/(Real)RAND_MAX + b_;
140 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
Triangle(Teuchos::ParameterList &parlist)
Real evaluatePDF(const Real input) const
Real evaluateCDF(const Real input) const