-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d61ef7
commit aa9b2b9
Showing
5 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// ============================================================================ | ||
#ifndef OSTAP_LAPLACE_H | ||
#define OSTAP_LAPLACE_H 1 | ||
// ============================================================================ | ||
// Include files | ||
// ============================================================================ | ||
// STD&STL | ||
// ============================================================================ | ||
#include <functional> | ||
// ============================================================================ | ||
// Ostap | ||
// ============================================================================ | ||
#include "Ostap/Integrator.h" | ||
// ============================================================================ | ||
namespace Ostap | ||
{ | ||
// ========================================================================== | ||
namespace Math | ||
{ | ||
// ======================================================================== | ||
/** @class Laplace Ostap/Laplace.h | ||
* Simple class to implement Hilbert transform | ||
* https://en.wikipedia.org/wiki/Hilbert_transform | ||
*/ | ||
class Laplace | ||
{ | ||
// ====================================================================== | ||
/** templated constructor from the function | ||
* @param func the function | ||
* @param tag unique tag/label for cache | ||
* @param size size of integration workspace | ||
*/ | ||
template <class FUNCTION> | ||
Laplace | ||
( FUNCTION func , | ||
const std::size_t tag = 0 , | ||
const double aprecision = 0 , | ||
const double rprecision = 0 , | ||
const std::size_t size = 0 ) | ||
: m_func ( func ) | ||
, m_tag ( tag ) | ||
, m_aprecision ( aprecision ) | ||
, m_rprecision ( rprecision ) | ||
, m_integrator ( size ) | ||
{} ; | ||
// ====================================================================== | ||
public: | ||
// ====================================================================== | ||
/** templated creator from the function | ||
* @param func the function | ||
* @param tag unique tag/label for cache | ||
* @param size size of integration workspace | ||
*/ | ||
template <class FUNCTION> | ||
inline static Laplace | ||
create | ||
( FUNCTION func , | ||
const std::size_t tag = 0 , | ||
const double aprecision = 0 , | ||
const double rprecision = 0 , | ||
const std::size_t size = 0 ) | ||
{ return Laplace ( func , tag , aprecision , rprecision , size ) ; } | ||
// ====================================================================== | ||
public: | ||
// ====================================================================== | ||
/// Get the value of Laplace transform | ||
double operator() ( const double x ) const ; | ||
// ====================================================================== | ||
public: | ||
// ====================================================================== | ||
/// get the value of the unction | ||
inline double func ( const double x ) const { return m_func ( x ) ; } | ||
// ====================================================================== | ||
private: | ||
// ====================================================================== | ||
/// the function | ||
std::function<double(double)> m_func ; // the function | ||
/// unique tag/label | ||
std::size_t m_tag ; // unique tag/label | ||
/// absolte precison | ||
double m_aprecision ; // absoluet preciison | ||
/// relative precison | ||
double m_rprecision ; // relative precision | ||
/// Integrator | ||
Ostap::Math::Integrator m_integrator ; // integrator | ||
// ====================================================================== | ||
}; // The end of class Ostap::Math::Laplace | ||
// ======================================================================== | ||
} // The end of namespace Ostap::Math | ||
// ========================================================================== | ||
} // The end of namepsace Ostap | ||
// ============================================================================ | ||
// The END | ||
// ============================================================================ | ||
#endif // OSTAP_LAPLACE_H | ||
// ============================================================================ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// ============================================================================ | ||
// Include files | ||
// ============================================================================= | ||
// Incldue files | ||
// ============================================================================= | ||
// STD& STL | ||
// ============================================================================= | ||
#include <cmath> | ||
// ============================================================================= | ||
// Ostap | ||
// ============================================================================= | ||
#include "Ostap/Hash.h" | ||
#include "Ostap/Laplace.h" | ||
// ============================================================================= | ||
/** @file | ||
* Implementation file for class Ostap::Math::Laplace | ||
* @date 2024-10-27 | ||
* @author Vanya Belyaev [email protected] | ||
*/ | ||
// ============================================================================= | ||
double Ostap::Math::Laplace::operator() ( const double x ) const | ||
{ | ||
auto the_fun = [x,this] ( const double z ) -> double | ||
{ return this->m_func ( z ) * std::exp ( - x * z ) ; }; | ||
// | ||
const std::size_t ntag = | ||
( 0 == m_tag ) ? m_tag : Ostap::Utils::hash_combiner ( m_tag , x ) ; | ||
return m_integrator.integrate_to_infinity | ||
( std::cref ( the_fun ) , | ||
0.0 , // xmin | ||
ntag , // tag | ||
m_aprecision , | ||
m_rprecision ) ; | ||
} | ||
// ============================================================================= | ||
// The END | ||
// ============================================================================= | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters