Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-04 09:15:12

0001 // Created on: 2005-12-08
0002 // Created by: Sergey KHROMOV
0003 // Copyright (c) 2005-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _math_KronrodSingleIntegration_HeaderFile
0017 #define _math_KronrodSingleIntegration_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 
0022 #include <Standard_Integer.hxx>
0023 #include <math_Vector.hxx>
0024 class math_Function;
0025 
0026 //! This class implements the Gauss-Kronrod method of
0027 //! integral computation.
0028 class math_KronrodSingleIntegration
0029 {
0030 public:
0031   DEFINE_STANDARD_ALLOC
0032 
0033   //! An empty constructor.
0034   Standard_EXPORT math_KronrodSingleIntegration();
0035 
0036   //! Constructor. Takes the function, the lower and upper bound
0037   //! values, the initial number of Kronrod points
0038   Standard_EXPORT math_KronrodSingleIntegration(math_Function& theFunction,
0039                                                 const double   theLower,
0040                                                 const double   theUpper,
0041                                                 const int      theNbPnts);
0042 
0043   //! Constructor. Takes the function, the lower and upper bound
0044   //! values, the initial number of Kronrod points, the
0045   //! tolerance value and the maximal number of iterations as
0046   //! parameters.
0047   Standard_EXPORT math_KronrodSingleIntegration(math_Function& theFunction,
0048                                                 const double   theLower,
0049                                                 const double   theUpper,
0050                                                 const int      theNbPnts,
0051                                                 const double   theTolerance,
0052                                                 const int      theMaxNbIter);
0053 
0054   //! Computation of the integral. Takes the function,
0055   //! the lower and upper bound values, the initial number
0056   //! of Kronrod points, the relative tolerance value and the
0057   //! maximal number of iterations as parameters.
0058   //! theNbPnts should be odd and greater then or equal to 3.
0059   Standard_EXPORT void Perform(math_Function& theFunction,
0060                                const double   theLower,
0061                                const double   theUpper,
0062                                const int      theNbPnts);
0063 
0064   //! Computation of the integral. Takes the function,
0065   //! the lower and upper bound values, the initial number
0066   //! of Kronrod points, the relative tolerance value and the
0067   //! maximal number of iterations as parameters.
0068   //! theNbPnts should be odd and greater then or equal to 3.
0069   //! Note that theTolerance is relative, i.e. the criterion of
0070   //! solution reaching is:
0071   //! std::abs(Kronrod - Gauss)/std::abs(Kronrod) < theTolerance.
0072   //! theTolerance should be positive.
0073   Standard_EXPORT void Perform(math_Function& theFunction,
0074                                const double   theLower,
0075                                const double   theUpper,
0076                                const int      theNbPnts,
0077                                const double   theTolerance,
0078                                const int      theMaxNbIter);
0079 
0080   //! Returns true if computation is performed
0081   //! successfully.
0082   bool IsDone() const;
0083 
0084   //! Returns the value of the integral.
0085   double Value() const;
0086 
0087   //! Returns the value of the relative error reached.
0088   double ErrorReached() const;
0089 
0090   //! Returns the value of the relative error reached.
0091   double AbsolutError() const;
0092 
0093   //! Returns the number of Kronrod points
0094   //! for which the result is computed.
0095   int OrderReached() const;
0096 
0097   //! Returns the number of iterations
0098   //! that were made to compute result.
0099   int NbIterReached() const;
0100 
0101   Standard_EXPORT static bool GKRule(math_Function&     theFunction,
0102                                      const double       theLower,
0103                                      const double       theUpper,
0104                                      const math_Vector& theGaussP,
0105                                      const math_Vector& theGaussW,
0106                                      const math_Vector& theKronrodP,
0107                                      const math_Vector& theKronrodW,
0108                                      double&            theValue,
0109                                      double&            theError);
0110 
0111 private:
0112   bool   myIsDone;
0113   double myValue;
0114   double myErrorReached;
0115   double myAbsolutError;
0116   int    myNbPntsReached;
0117   int    myNbIterReached;
0118 };
0119 
0120 #include <math_KronrodSingleIntegration.lxx>
0121 
0122 #endif // _math_KronrodSingleIntegration_HeaderFile