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

« back to all changes in this revision

Viewing changes to lib/src/Base/Func/AnalyticalNumericalMathEvaluationImplementation.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:
13
13
 *
14
14
 *
15
15
 * \author $LastChangedBy: dutka $
16
 
 * \date   $LastChangedDate: 2008-07-15 11:40:00 +0200 (mar, 15 jui 2008) $
 
16
 * \date   $LastChangedDate: 2008-10-31 11:52:04 +0100 (ven 31 oct 2008) $
17
17
 */
18
18
 
19
19
#include "AnalyticalNumericalMathEvaluationImplementation.hxx"
30
30
      static Common::Factory<AnalyticalNumericalMathEvaluationImplementation> RegisteredFactory("AnalyticalNumericalMathEvaluationImplementation");
31
31
 
32
32
      /* Default constructor */
33
 
      AnalyticalNumericalMathEvaluationImplementation::AnalyticalNumericalMathEvaluationImplementation(const String & name)
34
 
        : NumericalMathEvaluationImplementation(name),
 
33
      AnalyticalNumericalMathEvaluationImplementation::AnalyticalNumericalMathEvaluationImplementation()
 
34
        : NumericalMathEvaluationImplementation(),
35
35
          inputVariables_(0),
36
36
          isInitialized_(false),
37
37
          inputVariablesNames_(),
45
45
      /* Default constructor */
46
46
      AnalyticalNumericalMathEvaluationImplementation::AnalyticalNumericalMathEvaluationImplementation(const Description & inputVariablesNames,
47
47
                                                                                                       const Description & outputVariablesNames,
48
 
                                                                                                       const Description & formulas,
49
 
                                                                                                       const String & name)
 
48
                                                                                                       const Description & formulas)
50
49
        throw(InvalidArgumentException)
51
 
        : NumericalMathEvaluationImplementation(name),
 
50
        : NumericalMathEvaluationImplementation(),
52
51
          inputVariables_(NumericalPoint(inputVariablesNames.getSize()).getCollection()),
53
52
          isInitialized_(false),
54
53
          inputVariablesNames_(inputVariablesNames),
59
58
        Description description(inputVariablesNames_);
60
59
        try
61
60
          {
62
 
            UnsignedLong outputSize(outputVariablesNames_.getSize());
63
 
            UnsignedLong inputSize(inputVariablesNames_.getSize());
 
61
            const UnsignedLong outputSize(outputVariablesNames_.getSize());
 
62
            const UnsignedLong inputSize(inputVariablesNames_.getSize());
64
63
            // For each parser of a formula, do
65
 
            for (UnsignedLong outputVariableIndex = 0; outputVariableIndex < outputSize; outputVariableIndex++)
 
64
            for (UnsignedLong outputVariableIndex = 0; outputVariableIndex < outputSize; ++outputVariableIndex)
66
65
              {
67
66
                // First, define all the variable names and associate them
68
67
                // to the corresponding component of the input vector
69
 
                for(UnsignedLong inputVariableIndex = 0; inputVariableIndex < inputSize; inputVariableIndex++)
 
68
                for(UnsignedLong inputVariableIndex = 0; inputVariableIndex < inputSize; ++inputVariableIndex)
70
69
                  {
71
70
                    parsers_[outputVariableIndex].DefineVar(inputVariablesNames_[inputVariableIndex].c_str(), &inputVariables_[inputVariableIndex]);
72
71
                  }
114
113
      void AnalyticalNumericalMathEvaluationImplementation::checkInitialization() const
115
114
      {
116
115
        if (isInitialized_) return;
117
 
        UnsignedLong outputSize(outputVariablesNames_.getSize());
118
 
        UnsignedLong inputSize(inputVariablesNames_.getSize());
 
116
        const UnsignedLong outputSize(outputVariablesNames_.getSize());
 
117
        const UnsignedLong inputSize(inputVariablesNames_.getSize());
119
118
        // For each parser of a formula, do
120
 
        for (UnsignedLong outputVariableIndex = 0; outputVariableIndex < outputSize; outputVariableIndex++)
 
119
        for (UnsignedLong outputVariableIndex = 0; outputVariableIndex < outputSize; ++outputVariableIndex)
121
120
          {
122
121
            // First, define all the variable names and associate them
123
122
            // to the corresponding component of the input vector
124
 
            for(UnsignedLong inputVariableIndex = 0; inputVariableIndex < inputSize; inputVariableIndex++)
 
123
            for(UnsignedLong inputVariableIndex = 0; inputVariableIndex < inputSize; ++inputVariableIndex)
125
124
              {
126
125
                parsers_[outputVariableIndex].DefineVar(inputVariablesNames_[inputVariableIndex].c_str(), &inputVariables_[inputVariableIndex]);
127
126
              }
138
137
        if (in.getDimension() != getInputNumericalPointDimension()) throw InvalidArgumentException(HERE) << "Error: trying to evaluate a NumericalMathFunction with an argument of invalid dimension";
139
138
        NumericalPoint out(getOutputNumericalPointDimension());
140
139
        checkInitialization();
141
 
        callsNumber_++;
142
 
        for (UnsignedLong i = 0; i < in.getDimension(); i++)
 
140
        ++callsNumber_;
 
141
        for (UnsignedLong i = 0; i < in.getDimension(); ++i)
143
142
          {
144
143
            inputVariables_[i] = in[i];
145
144
          }
146
145
        try
147
146
          {
148
 
            for (UnsignedLong index = 0; index < out.getDimension(); index++)
 
147
            for (UnsignedLong index = 0; index < out.getDimension(); ++index)
149
148
              {
150
149
                out[index] = parsers_[index].Eval();
151
150
              }