~ubuntu-branches/ubuntu/maverick/openturns/maverick

« back to all changes in this revision

Viewing changes to lib/test/t_StandardDistributionPolynomialFactory_std.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2010-05-10 17:27:55 UTC
  • mfrom: (1.1.4 upstream) (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100510172755-cb5ynskknqqi5rhp
Tags: 0.13.2-2ubuntu1
* Merge with Debian testing. No changes left.
* ubuntu_fix-python-2.6.patch: fix detection of python 2.6 libs, to not use
  LOCALMODLIBS. This pulls a dependency on SSL and makes the package FTBFS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//                                               -*- C++ -*-
 
2
/**
 
3
 *  @file  t_StandardDistributionPolynomialFactory_std.cxx
 
4
 *  @brief The test file of class StandardDistributionPolynomialFactory for standard methods
 
5
 *
 
6
 *  (C) Copyright 2005-2010 EDF-EADS-Phimeca
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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
 
21
 *
 
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 $
 
25
 */
 
26
#include <iostream>
 
27
#include <exception>
 
28
#include "OT.hxx"
 
29
#include "OTtestcode.hxx"
 
30
#include "OStream.hxx"
 
31
#include "Exception.hxx"
 
32
#include "NumericalPoint.hxx"
 
33
#include "Collection.hxx"
 
34
#include "Distribution.hxx"
 
35
#include "Beta.hxx"
 
36
#include "ChiSquare.hxx"
 
37
#include "Epanechnikov.hxx"
 
38
#include "Exponential.hxx"
 
39
#include "Gamma.hxx"
 
40
#include "Gumbel.hxx"
 
41
#include "Laplace.hxx"
 
42
#include "Logistic.hxx"
 
43
#include "LogNormal.hxx"
 
44
#include "Normal.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"
 
51
 
 
52
using namespace OT;
 
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;
 
59
 
 
60
int main(int argc, char *argv[])
 
61
{
 
62
  TESTPREAMBLE;
 
63
  OStream fullprint(std::cout);
 
64
 
 
65
  try {
 
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)
 
78
      {
 
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;
 
90
      }
 
91
  }
 
92
  catch (TestFailed & ex) {
 
93
    std::cerr << ex << std::endl;
 
94
    return ExitCode::Error;
 
95
  }
 
96
 
 
97
  return ExitCode::Success;
 
98
}