Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-11 09:18:53

0001 // Created on: 1996-10-08
0002 // Created by: Jeannine PANTIATICI
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _PLib_JacobiPolynomial_HeaderFile
0018 #define _PLib_JacobiPolynomial_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <Standard_Integer.hxx>
0023 #include <GeomAbs_Shape.hxx>
0024 #include <NCollection_Array1.hxx>
0025 #include <NCollection_Array2.hxx>
0026 
0027 //! This class provides method to work with Jacobi Polynomials
0028 //! relatively to an order of constraint
0029 //! q  = myWorkDegree-2*(myNivConstr+1)
0030 //! Jk(t)  for k=0,q compose the Jacobi Polynomial base relatively to the weight W(t)
0031 //! iorder is the integer value for the constraints:
0032 //! iorder = 0 <=> ConstraintOrder  = GeomAbs_C0
0033 //! iorder = 1 <=>  ConstraintOrder = GeomAbs_C1
0034 //! iorder = 2 <=> ConstraintOrder = GeomAbs_C2
0035 //! P(t) = R(t) + W(t) * Q(t) Where W(t) = (1-t**2)**(2*iordre+2)
0036 //! the coefficients JacCoeff represents P(t) JacCoeff are stored as follow:
0037 //!
0038 //! c0(1)      c0(2) ....       c0(Dimension)
0039 //! c1(1)      c1(2) ....       c1(Dimension)
0040 //!
0041 //! cDegree(1) cDegree(2) ....  cDegree(Dimension)
0042 //!
0043 //! The coefficients
0044 //! c0(1)                  c0(2) ....            c0(Dimension)
0045 //! c2*ordre+1(1)                ...          c2*ordre+1(dimension)
0046 //!
0047 //! represents the part of the polynomial in the
0048 //! canonical base: R(t)
0049 //! R(t) = c0 + c1   t + ...+ c2*iordre+1 t**2*iordre+1
0050 //! The following coefficients represents the part of the
0051 //! polynomial in the Jacobi base ie Q(t)
0052 //! Q(t) = c2*iordre+2  J0(t) + ...+ cDegree JDegree-2*iordre-2
0053 class PLib_JacobiPolynomial
0054 {
0055 
0056 public:
0057   //! Initialize the polynomial class
0058   //! Degree has to be <= 30
0059   //! ConstraintOrder has to be GeomAbs_C0
0060   //! GeomAbs_C1
0061   //! GeomAbs_C2
0062   Standard_EXPORT PLib_JacobiPolynomial(const int           theWorkDegree,
0063                                         const GeomAbs_Shape theConstraintOrder);
0064 
0065   //! returns the Jacobi Points for Gauss integration ie
0066   //! the positive values of the Legendre roots by increasing values
0067   //! NbGaussPoints is the number of points chosen for the integral
0068   //! computation.
0069   //! TabPoints (0,NbGaussPoints/2)
0070   //! TabPoints (0) is loaded only for the odd values of NbGaussPoints
0071   //! The possible values for NbGaussPoints are : 8, 10,
0072   //! 15, 20, 25, 30, 35, 40, 50, 61
0073   //! NbGaussPoints must be greater than Degree
0074   Standard_EXPORT void Points(const int                   theNbGaussPoints,
0075                               NCollection_Array1<double>& theTabPoints) const;
0076 
0077   //! returns the Jacobi weights for Gauss integration only for
0078   //! the positive values of the Legendre roots in the order they
0079   //! are given by the method Points
0080   //! NbGaussPoints is the number of points chosen for the integral
0081   //! computation.
0082   //! TabWeights (0,NbGaussPoints/2,0,Degree)
0083   //! TabWeights (0,.) are only loaded for the odd values of NbGaussPoints
0084   //! The possible values for NbGaussPoints are: 8, 10, 15, 20, 25, 30,
0085   //! 35, 40, 50, 61 NbGaussPoints must be greater than Degree
0086   Standard_EXPORT void Weights(const int                   theNbGaussPoints,
0087                                NCollection_Array2<double>& theTabWeights) const;
0088 
0089   //! this method loads for k=0,q the maximum value of
0090   //! abs ( W(t)*Jk(t) ) for t bellonging to [-1,1]
0091   //! This values are loaded is the array TabMax(0,myWorkDegree-2*(myNivConst+1))
0092   //! MaxValue ( me ; TabMaxPointer : in  out  Real );
0093   Standard_EXPORT void MaxValue(NCollection_Array1<double>& theTabMax) const;
0094 
0095   //! This method computes the maximum error on the polynomial
0096   //! W(t) Q(t) obtained by missing the coefficients of JacCoeff from
0097   //! NewDegree +1 to Degree
0098   Standard_EXPORT double MaxError(const int theDimension,
0099                                   double&   theJacCoeff,
0100                                   const int theNewDegree) const;
0101 
0102   //! Compute NewDegree <= MaxDegree so that MaxError is lower
0103   //! than Tol.
0104   //! MaxError can be greater than Tol if it is not possible
0105   //! to find a NewDegree <= MaxDegree.
0106   //! In this case NewDegree = MaxDegree
0107   Standard_EXPORT void ReduceDegree(const int    theDimension,
0108                                     const int    theMaxDegree,
0109                                     const double theTol,
0110                                     double&      theJacCoeff,
0111                                     int&         theNewDegree,
0112                                     double&      theMaxError) const;
0113 
0114   Standard_EXPORT double AverageError(const int theDimension,
0115                                       double&   theJacCoeff,
0116                                       const int theNewDegree) const;
0117 
0118   //! Convert the polynomial P(t) = R(t) + W(t) Q(t) in the canonical base.
0119   Standard_EXPORT void ToCoefficients(const int                         theDimension,
0120                                       const int                         theDegree,
0121                                       const NCollection_Array1<double>& theJacCoeff,
0122                                       NCollection_Array1<double>&       theCoefficients) const;
0123 
0124   //! Compute the values of the basis functions in u
0125   Standard_EXPORT void D0(const double theU, NCollection_Array1<double>& theBasisValue) const;
0126 
0127   //! Compute the values and the derivatives values of
0128   //! the basis functions in u
0129   Standard_EXPORT void D1(const double                theU,
0130                           NCollection_Array1<double>& theBasisValue,
0131                           NCollection_Array1<double>& theBasisD1) const;
0132 
0133   //! Compute the values and the derivatives values of
0134   //! the basis functions in u
0135   Standard_EXPORT void D2(const double                theU,
0136                           NCollection_Array1<double>& theBasisValue,
0137                           NCollection_Array1<double>& theBasisD1,
0138                           NCollection_Array1<double>& theBasisD2) const;
0139 
0140   //! Compute the values and the derivatives values of
0141   //! the basis functions in u
0142   Standard_EXPORT void D3(const double                theU,
0143                           NCollection_Array1<double>& theBasisValue,
0144                           NCollection_Array1<double>& theBasisD1,
0145                           NCollection_Array1<double>& theBasisD2,
0146                           NCollection_Array1<double>& theBasisD3) const;
0147 
0148   //! returns WorkDegree
0149   int WorkDegree() const noexcept { return myWorkDegree; }
0150 
0151   //! returns NivConstr
0152   int NivConstr() const noexcept { return myNivConstr; }
0153 
0154 protected:
0155   //! Compute the values and the derivatives values of
0156   //! the basis functions in u
0157   Standard_EXPORT void D0123(const int                   theNDeriv,
0158                              const double                theU,
0159                              NCollection_Array1<double>& theBasisValue,
0160                              NCollection_Array1<double>& theBasisD1,
0161                              NCollection_Array1<double>& theBasisD2,
0162                              NCollection_Array1<double>& theBasisD3) const;
0163 
0164 private:
0165   const int myWorkDegree;
0166   const int myNivConstr;
0167   const int myDegree;
0168 };
0169 
0170 #endif // _PLib_JacobiPolynomial_HeaderFile