#include "ATOOLS/Math/Scaling.H" #include "ATOOLS/Org/Message.H" #include "ATOOLS/Org/Data_Reader.H" #include "ATOOLS/Org/MyStrStream.H" #include "ATOOLS/Math/MathTools.H" using namespace ATOOLS; template Scaling_Base::~Scaling_Base() {} template ValueType Scaling_Base::operator()(const Value_Type &x) { msg_Error()<<"Scaling_Base::operator(): " <<"Virtual method called!"< ValueType Scaling_Base::operator[](const Value_Type &y) { msg_Error()<<"Scaling_Base::operator[]: " <<"Virtual method called!"< const std::string Scaling_Base::Name() const { return m_name; } template void Scaling_Base::ShowScalings(const int mode) { if (!msg_LevelIsInfo() || mode==0) return; msg_Out()<<"Scaling_Base::ShowScalings(): {\n\n"; Scaling_Getter::PrintGetterInfo(msg->Out(),20); msg_Out()<<"\n}"< class Id_Scaling: public Scaling_Base { public: Id_Scaling(const std::string ¶meter); virtual Value_Type operator()(const Value_Type &x) { return x; } virtual Value_Type operator[](const Value_Type &y) { return y; } };// end of class Id_Scaling template Id_Scaling::Id_Scaling(const std::string ¶meter) { this->m_name="Id"; } template class Log_Scaling: public Scaling_Base { public: Log_Scaling(const std::string ¶meter); virtual Value_Type operator()(const Value_Type &x) { return log(x); } virtual Value_Type operator[](const Value_Type &y) { return exp(y); } };// end of class Log_Scaling template Log_Scaling::Log_Scaling(const std::string ¶meter) { this->m_name="Log"; } template class Exp_Scaling: public Scaling_Base { public: Exp_Scaling(const std::string ¶meter); virtual Value_Type operator()(const Value_Type &x) { return exp(x); } virtual Value_Type operator[](const Value_Type &y) { return log(y); } };// end of class Exp_Scaling template Exp_Scaling::Exp_Scaling(const std::string ¶meter) { this->m_name="Exp"; } template class Sqr_Scaling: public Scaling_Base { public: Sqr_Scaling(const std::string ¶meter); virtual Value_Type operator()(const Value_Type &x) { return x*x; } virtual Value_Type operator[](const Value_Type &y) { return sqrt(y); } };// end of class Sqr_Scaling template Sqr_Scaling::Sqr_Scaling(const std::string ¶meter) { this->m_name="Sqr"; } template class Sqrt_Scaling: public Scaling_Base { public: Sqrt_Scaling(const std::string ¶meter); virtual Value_Type operator()(const Value_Type &x) { return sqrt(x); } virtual Value_Type operator[](const Value_Type &y) { return y*y; } };// end of class Sqr_Scaling template Sqrt_Scaling::Sqrt_Scaling(const std::string ¶meter) { this->m_name="Sqrt"; } template class Log_B_Scaling: public Scaling_Base { private: Value_Type m_b, m_logb; public: Log_B_Scaling(const std::string ¶meter); virtual Value_Type operator()(const Value_Type &x) { return log(x)/m_logb; } virtual Value_Type operator[](const Value_Type &y) { return pow(m_b,y); } };// end of class Log_B_Scaling template Log_B_Scaling::Log_B_Scaling(const std::string ¶meter) { Data_Reader reader; reader.SetExactMatch(false); reader.SetString(parameter); reader.ReadFromString(m_b,"Log_B_"); m_logb=log(m_b); this->m_name="Log_B_"+ToString(m_b); } template class B_To_X_Scaling: public Scaling_Base { private: Value_Type m_b; public: B_To_X_Scaling(const std::string ¶meter); virtual Value_Type operator()(const Value_Type &x) { return pow(m_b,x); } virtual Value_Type operator[](const Value_Type &y) { return log(y)/log(m_b); } };// end of class B_To_X_Scaling template B_To_X_Scaling::B_To_X_Scaling(const std::string ¶meter) { Data_Reader reader; reader.SetExactMatch(false); reader.SetString(parameter); reader.ReadFromString(m_b,"B_To_X_"); this->m_name="B_To_X_"+ToString(m_b); } template class X_To_P_Scaling: public Scaling_Base { private: Value_Type m_p; public: X_To_P_Scaling(const std::string ¶meter); virtual Value_Type operator()(const Value_Type &x) { return pow(x,m_p); } virtual Value_Type operator[](const Value_Type &y) { return pow(y,(Value_Type)1.0/m_p); } };// end of class X_To_P_Scaling template X_To_P_Scaling::X_To_P_Scaling(const std::string ¶meter) { Data_Reader reader; reader.SetExactMatch(false); reader.SetString(parameter); reader.ReadFromString(m_p,"X_To_P_"); this->m_name="X_To_P_"+ToString(m_p); } template class ATOOLS::Scaling_Base; #define COMPILE__Getter_Function #define OBJECT_TYPE Scaling_Base #define PARAMETER_TYPE std::string #define EXACTMATCH false #include "ATOOLS/Org/Getter_Function.C" template Scaling_Base *GetVariable(const std::string ¶meter) { return new Class(parameter); } #define DEFINE_GETTER_METHOD(CLASS) \ Scaling_Base * \ ATOOLS::Getter,std::string,CLASS>:: \ operator()(const std::string ¶meter) const \ { return GetVariable(parameter); } #define DEFINE_PRINT_METHOD(CLASS,PRINT) \ void ATOOLS::Getter,std::string,CLASS>:: \ PrintInfo(std::ostream &str,const size_t width) const \ { str<,std::string); \ DEFINE_GETTER_METHOD(CLASS) \ DEFINE_PRINT_METHOD(CLASS,PRINT) DEFINE_SCALING_GETTER(Id_Scaling, "Id","identical") DEFINE_SCALING_GETTER(Log_Scaling, "Log","logarithmical") DEFINE_SCALING_GETTER(Exp_Scaling, "Exp","exponential") DEFINE_SCALING_GETTER(Sqr_Scaling, "Sqr","square") DEFINE_SCALING_GETTER(Sqrt_Scaling, "Sqrt","square root") DEFINE_SCALING_GETTER(Log_B_Scaling, "Log_B_","logarithmical") DEFINE_SCALING_GETTER(B_To_X_Scaling, "B_To_X_","exponential") DEFINE_SCALING_GETTER(X_To_P_Scaling, "X_To_P_","power")