3
* @file t_StandardDistributionPolynomialFactory_std.cxx
4
* @brief The test file of class StandardDistributionPolynomialFactory for standard methods
6
* (C) Copyright 2005-2010 EDF-EADS-Phimeca
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License.
13
* This library is distributed in the hope that it will be useful
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
* @author: $LastChangedBy: dutka $
23
* @date: $LastChangedDate: 2008-05-21 17:44:02 +0200 (mer, 21 mai 2008) $
24
* Id: $Id: t_StandardDistributionPolynomialFactory_std.cxx 818 2008-05-21 15:44:02Z dutka $
29
#include "OTtestcode.hxx"
30
#include "OStream.hxx"
31
#include "Exception.hxx"
32
#include "NumericalPoint.hxx"
33
#include "Collection.hxx"
34
#include "Distribution.hxx"
36
#include "ChiSquare.hxx"
37
#include "Epanechnikov.hxx"
38
#include "Exponential.hxx"
41
#include "Laplace.hxx"
42
#include "Logistic.hxx"
43
#include "LogNormal.hxx"
45
#include "Rayleigh.hxx"
46
#include "Student.hxx"
47
#include "Triangular.hxx"
48
#include "Uniform.hxx"
49
#include "Weibull.hxx"
50
#include "StandardDistributionPolynomialFactory.hxx"
53
using namespace OT::Test;
54
using namespace OT::Base::Common;
55
using namespace OT::Base::Type;
56
using namespace OT::Uncertainty::Distribution;
57
using namespace OT::Uncertainty::Model;
58
using namespace OT::Uncertainty::Algorithm;
60
int main(int argc, char *argv[])
63
OStream fullprint(std::cout);
66
const UnsignedLong iMax(5);
67
Collection<Distribution> distributionCollection;
68
distributionCollection.add(Laplace(1.0, 0.0));
69
distributionCollection.add(Logistic(0.0, 1.0));
70
distributionCollection.add(LogNormal(0.0, 1.0, 0.0));
71
distributionCollection.add(Normal(0.0, 1.0));
72
distributionCollection.add(Rayleigh(1.0));
73
distributionCollection.add(Student(22));
74
distributionCollection.add(Triangular(-1.0, 0.3, 1.0));
75
distributionCollection.add(Uniform(-1.0,1.0));
76
distributionCollection.add(Weibull(1.0, 3.0));
77
for (UnsignedLong n = 0; n < distributionCollection.getSize(); ++n)
79
const Distribution distribution(distributionCollection[n]);
80
const String name(distribution.getImplementation()->getClassName());
81
StandardDistributionPolynomialFactory polynomialFactory(distribution);
82
fullprint << "polynomialFactory(" << name << "=" << polynomialFactory << std::endl;
83
for (UnsignedLong i = 0; i < iMax; ++i)
84
fullprint << name << " polynomial(" << i << ")=" << polynomialFactory.build(i).__str__() << std::endl;
85
NumericalPoint roots(polynomialFactory.getRoots(iMax - 1));
86
fullprint << name << " polynomial(" << iMax - 1 << ") roots=" << roots << std::endl;
87
NumericalPoint weights;
88
NumericalPoint nodes(polynomialFactory.getNodesAndWeights(iMax - 1, weights));
89
fullprint << name << " polynomial(" << iMax - 1 << ") nodes=" << nodes << " and weights=" << weights << std::endl;
92
catch (TestFailed & ex) {
93
std::cerr << ex << std::endl;
94
return ExitCode::Error;
97
return ExitCode::Success;