SourceXtractorPlusPlus  0.16
Please provide a description of the project.
SigmoidConverter.cpp
Go to the documentation of this file.
1 
23 #include <cmath>
24 #include <iostream>
25 
26 #include <ElementsKernel/Logging.h>
27 
29 
30 namespace ModelFitting {
31 
32 using namespace std;
33 
35 
37 
38 double SigmoidConverter::worldToEngine(const double world_value) const {
39  if (world_value < m_min_value || world_value > m_max_value) {
40  logger.warn() << "WorldToEngine SigmoidConverter: world values outside of possible range";
41  }
42 
43  double num = world_value - m_min_value;
44  double den = m_max_value - world_value;
45  return (num > 1e-50 ? (den > 1e-50 ? log(num/den) : 50.0) : -50.0);
46 }
47 
48 double SigmoidConverter::engineToWorld(const double engine_value) const {
49  auto clamped_value = std::max(-50.0, std::min(50.0, engine_value));
50  return m_min_value + (m_max_value - m_min_value) / (1 + exp(-clamped_value));
51 }
52 
53 double SigmoidConverter::getEngineToWorldDerivative(const double value) const {
54  return (value - m_min_value) * (m_max_value - value) / (m_max_value - m_min_value);
55 }
56 
57 
58 }// namespace ModelFitting
static Logging getLogger(const std::string &name="")
void warn(const std::string &logMessage)
virtual ~SigmoidConverter()
Destructor.
double engineToWorld(const double engine_value) const override
Engine to world coordinate converter.
double worldToEngine(const double world_value) const override
World to engine coordinate converter.
double getEngineToWorldDerivative(const double value) const override
T exp(T... args)
T log(T... args)
T max(T... args)
T min(T... args)
constexpr double e
static Elements::Logging logger
STL namespace.