1 // -*- C++ -*- 2 /** 3 * @brief This is the interface class for orthogonal polynomial factories 4 * 5 * Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca 6 * 7 * This library is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this library. If not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 #include "openturns/OrthogonalUniVariatePolynomialFamily.hxx" 22 #include "openturns/OSS.hxx" 23 #include "openturns/PersistentObjectFactory.hxx" 24 #include "openturns/HermiteFactory.hxx" 25 26 BEGIN_NAMESPACE_OPENTURNS 27 28 29 CLASSNAMEINIT(OrthogonalUniVariatePolynomialFamily)30CLASSNAMEINIT(OrthogonalUniVariatePolynomialFamily) 31 32 /* Default constructor */ 33 OrthogonalUniVariatePolynomialFamily::OrthogonalUniVariatePolynomialFamily() 34 : TypedInterfaceObject<OrthogonalUniVariatePolynomialFactory>(new HermiteFactory) 35 { 36 // Nothing to do 37 } 38 39 40 /* Constructor from implementation */ OrthogonalUniVariatePolynomialFamily(const OrthogonalUniVariatePolynomialFactory & implementation)41OrthogonalUniVariatePolynomialFamily::OrthogonalUniVariatePolynomialFamily(const OrthogonalUniVariatePolynomialFactory & implementation) 42 : TypedInterfaceObject<OrthogonalUniVariatePolynomialFactory>(implementation.clone()) 43 { 44 // Nothing to do 45 } 46 47 48 /* The method to get the polynomial of any degree */ build(const UnsignedInteger degree) const49OrthogonalUniVariatePolynomial OrthogonalUniVariatePolynomialFamily::build(const UnsignedInteger degree) const 50 { 51 return getImplementation()->build(degree); 52 } 53 54 55 /* Measure accessor */ getMeasure() const56Distribution OrthogonalUniVariatePolynomialFamily::getMeasure() const 57 { 58 return getImplementation()->getMeasure(); 59 } 60 61 62 /* Calculate the coefficients of recurrence a0, a1, a2 such that 63 Pn+1(x) = (a0 * x + a1) * Pn(x) + a2 * Pn-1(x) */ getRecurrenceCoefficients(const UnsignedInteger n) const64OrthogonalUniVariatePolynomialFamily::Coefficients OrthogonalUniVariatePolynomialFamily::getRecurrenceCoefficients(const UnsignedInteger n) const 65 { 66 return getImplementation()->getRecurrenceCoefficients(n); 67 } 68 69 70 /* String converter */ __repr__() const71String OrthogonalUniVariatePolynomialFamily::__repr__() const 72 { 73 return OSS() << "class=" << getClassName() 74 << " implementation=" << getImplementation()->__repr__(); 75 } 76 77 /* Roots of the polynomial of degree n */ getRoots(const UnsignedInteger n) const78Point OrthogonalUniVariatePolynomialFamily::getRoots(const UnsignedInteger n) const 79 { 80 return getImplementation()->getRoots(n); 81 } 82 83 /* Nodes and weights of the polynomial of degree n as the eigenvalues of the associated Jacobi matrix and the square 84 of the first component of the associated normalized eigenvectors */ getNodesAndWeights(const UnsignedInteger n,Point & weights) const85Point OrthogonalUniVariatePolynomialFamily::getNodesAndWeights(const UnsignedInteger n, 86 Point & weights) const 87 { 88 return getImplementation()->getNodesAndWeights(n, weights); 89 } 90 91 92 END_NAMESPACE_OPENTURNS 93