1 // -*- C++ -*- 2 /** 3 * @brief Class for a linear numerical math function implementation 4 * of the form y = constant + <linear, x - c> where c is a 5 * dim(x) numerical point, linear a dim(x) by dim(y) matrix 6 * and <linear, x - c> means Transpose(linear).(x - c) 7 * 8 * Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca 9 * 10 * This library is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License as published by 12 * the Free Software Foundation, either version 3 of the License, or 13 * (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public License 21 * along with this library. If not, see <http://www.gnu.org/licenses/>. 22 * 23 */ 24 25 #ifndef OPENTURNS_LINEARNUMERICALMATHFUNCTIONIMPLEMENTATION_HXX 26 #define OPENTURNS_LINEARNUMERICALMATHFUNCTIONIMPLEMENTATION_HXX 27 28 #include "openturns/EvaluationImplementation.hxx" 29 #include "openturns/Point.hxx" 30 #include "openturns/Sample.hxx" 31 #include "openturns/Matrix.hxx" 32 33 BEGIN_NAMESPACE_OPENTURNS 34 35 /** 36 * @class LinearEvaluation 37 */ 38 class OT_API LinearEvaluation 39 : public EvaluationImplementation 40 { 41 CLASSNAME 42 public: 43 44 45 /** Default constructor */ 46 LinearEvaluation(); 47 48 /** Parameter constructor */ 49 LinearEvaluation(const Point & center, 50 const Point & constant, 51 const Matrix & linear); 52 53 /** Virtual constructor */ 54 LinearEvaluation * clone() const override; 55 56 /** Comparison operator */ 57 Bool operator ==(const LinearEvaluation & other) const; 58 59 /** String converter */ 60 String __repr__() const override; 61 String __str__(const String & offset = "") const override; 62 63 /* Here is the interface that all derived class must implement */ 64 65 /** Operator () */ 66 Point operator() (const Point & inP) const override; 67 68 /** Operator () */ 69 Sample operator() (const Sample & inS) const override; 70 71 /** Accessor for input point dimension */ 72 UnsignedInteger getInputDimension() const override; 73 74 /** Accessor for output point dimension */ 75 UnsignedInteger getOutputDimension() const override; 76 77 /** Accessor for the center */ 78 Point getCenter() const; 79 80 /** Accessor for the constant term */ 81 Point getConstant() const; 82 83 /** Accessor for the linear term */ 84 Matrix getLinear() const; 85 86 /** Linearity accessors */ 87 Bool isLinear() const override; 88 Bool isLinearlyDependent(const UnsignedInteger index) const override; 89 90 /** Method save() stores the object through the StorageManager */ 91 void save(Advocate & adv) const override; 92 93 /** Method load() reloads the object from the StorageManager */ 94 void load(Advocate & adv) override; 95 96 protected: 97 98 99 private: 100 Point center_; 101 Point constant_; 102 Matrix linear_; 103 }; /* class LinearEvaluation */ 104 105 106 END_NAMESPACE_OPENTURNS 107 108 #endif /* OPENTURNS_LINEARNUMERICALMATHFUNCTIONIMPLEMENTATION_HXX */ 109