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

« back to all changes in this revision

Viewing changes to lib/src/Uncertainty/Algorithm/IsoProbabilisticTransformation/NatafEllipticalCopula/InverseNatafEllipticalCopulaFunction.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2008-11-18 06:32:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20081118063222-pa0qncclrerrqkg2
Tags: 0.12.2-1
* New upstream release
* Bug fix: "New upstream release available (0.12.2)", thanks to Jerome
  Robert (Closes: #506005).
* Applied patch by J. Robert.
* debian/control: build-depends on libxml2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//                                               -*- C++ -*-
2
 
/**
3
 
 *  @file  InverseNatafEllipticalCopulaFunction.cxx
4
 
 *  @brief Class for the InverseNataf transformation evaluation for elliptical
5
 
 *
6
 
 *  (C) Copyright 2005-2007 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-06-26 13:50:17 +0200 (jeu, 26 jun 2008) $
24
 
 *  Id:      $Id: InverseNatafEllipticalCopulaFunction.cxx 862 2008-06-26 11:50:17Z dutka $
25
 
 */
26
 
#include "InverseNatafEllipticalCopulaFunction.hxx"
27
 
 
28
 
namespace OpenTURNS {
29
 
 
30
 
  namespace Uncertainty {
31
 
 
32
 
    namespace Algorithm {
33
 
 
34
 
      /*
35
 
       * @class InverseNatafEllipticalCopulaFunction
36
 
       *
37
 
       * This class offers an interface for the InverseNataf function for elliptical copula
38
 
       */
39
 
 
40
 
      CLASSNAMEINIT(InverseNatafEllipticalCopulaFunction);
41
 
 
42
 
      /* Parameter constructor */
43
 
      InverseNatafEllipticalCopulaFunction::InverseNatafEllipticalCopulaFunction(const Distribution & standardDistribution,
44
 
                                                                                 const SquareMatrix & cholesky,
45
 
                                                                                 const String & name):
46
 
        NumericalMathEvaluationImplementation(name),
47
 
        standardDistribution_(standardDistribution),
48
 
        cholesky_(cholesky)
49
 
      {
50
 
        Description description;
51
 
        for (UnsignedLong i = 0; i < cholesky_.getNbColumns(); ++i)
52
 
          {
53
 
            OSS oss;
54
 
            oss << "x" << i;
55
 
            description.add(oss);
56
 
          }
57
 
        for (UnsignedLong i = 0; i < cholesky_.getNbRows(); ++i)
58
 
          {
59
 
            OSS oss;
60
 
            oss << "y" << i;
61
 
            description.add(oss);
62
 
          }
63
 
        setDescription(description);
64
 
      }
65
 
 
66
 
      /* Virtual constructor */
67
 
      InverseNatafEllipticalCopulaFunction * InverseNatafEllipticalCopulaFunction::clone() const
68
 
      {
69
 
        return new InverseNatafEllipticalCopulaFunction(*this);
70
 
      }
71
 
 
72
 
      /* String converter */
73
 
      String InverseNatafEllipticalCopulaFunction::str() const
74
 
      {
75
 
        OSS oss;
76
 
        oss << "class=" << InverseNatafEllipticalCopulaFunction::GetClassName()
77
 
            << " description=" << getDescription()
78
 
            << " standardDistribution=" << standardDistribution_
79
 
            << " cholesky=" << cholesky_;
80
 
                   
81
 
        return oss;
82
 
      }
83
 
 
84
 
      /*
85
 
       * Evaluation
86
 
       * This function transforms a standard elliptical distribution into an elliptical copula of the same kind with a correlation matrix R:
87
 
       * Z(u) = L.u, where L is the Cholesky factor of R: L.L^t = R, L is lower triangular
88
 
       * Si(u) = F(Zi), where F is the CDF of the standard elliptical distribution
89
 
       */
90
 
      InverseNatafEllipticalCopulaFunction::NumericalPoint InverseNatafEllipticalCopulaFunction::operator () (const NumericalPoint & in) const
91
 
        throw (InvalidArgumentException, InternalException)
92
 
      {
93
 
        UnsignedLong dimension(getInputNumericalPointDimension());
94
 
        // First, correlate the components
95
 
        NumericalPoint result(cholesky_ * in);
96
 
        Distribution standardMarginal(standardDistribution_.getMarginal(0));
97
 
        // Second, apply the commmon marginal distribution
98
 
        for (UnsignedLong i = 0; i < dimension; ++i)
99
 
          {
100
 
            result[i] = standardMarginal.computeCDF(NumericalPoint(1, result[i]));
101
 
          }
102
 
        return result;
103
 
      }
104
 
 
105
 
      /* Gradient according to the marginal parameters. Currently, the dependence parameter are not taken into account. */
106
 
 
107
 
      InverseNatafEllipticalCopulaFunction::Matrix InverseNatafEllipticalCopulaFunction::parametersGradient(const NumericalPoint & in) const
108
 
      {
109
 
        return Matrix(0, getInputNumericalPointDimension());
110
 
      }
111
 
          
112
 
      /* Accessor for input point dimension */
113
 
      UnsignedLong InverseNatafEllipticalCopulaFunction::getInputNumericalPointDimension() const
114
 
        throw(InternalException)
115
 
      {
116
 
        return cholesky_.getNbColumns();
117
 
      }
118
 
 
119
 
      /* Accessor for output point dimension */
120
 
      UnsignedLong InverseNatafEllipticalCopulaFunction::getOutputNumericalPointDimension() const
121
 
        throw(InternalException)
122
 
      {
123
 
        return cholesky_.getNbRows();
124
 
      }
125
 
 
126
 
    } /* namespace Algorithm */
127
 
  } /* namespace Uncertainty */
128
 
} /* namespace OpenTURNS */