18 std::string description()
const override {
return "Inverse transform"; }
19 std::string repr(
bool name_keywords =
false,
20 const std::string_view& namespace_separator
21 = parameters::Object::CC_NAMESPACE_SEPARATOR)
const override {
22 return parameters::type_name_str<InverseTransform>(
false, namespace_separator) +
"()";
24 std::string str()
const override {
return parameters::type_name_str<InverseTransform>(
true) +
"()"; }
26 inline double derivative(
double x)
const override {
return 1 / (x * x); }
27 inline double forward(
double x)
const override {
return 1 / x; }
28 inline double reverse(
double x)
const override {
return 1 / x; }
32 static inline const double f_nu_0 = 3630.780547701002879554236770479;
34 std::string description()
const override {
return "jansky to AB magnitude transform"; }
35 std::string repr(
bool name_keywords =
false,
36 const std::string_view& namespace_separator
37 = parameters::Object::CC_NAMESPACE_SEPARATOR)
const override {
38 return parameters::type_name_str<JanskyToABMagTransform>(
false, namespace_separator) +
"()";
40 std::string str()
const override {
41 return parameters::type_name_str<JanskyToABMagTransform>(
true) +
"()";
44 inline double derivative(
double x)
const override {
45 return -1.08573620475812959718098227313021197915 / x;
47 inline double forward(
double x)
const override {
return -2.5 * log10(x / f_nu_0); }
48 inline double reverse(
double x)
const override {
return f_nu_0 * pow(10.0, -0.4 * x); }
52 std::string description()
const override {
return "nanojansky to AB magnitude transform"; }
53 std::string repr(
bool name_keywords =
false,
54 const std::string_view& namespace_separator
55 = parameters::Object::CC_NAMESPACE_SEPARATOR)
const override {
56 return parameters::type_name_str<NanojanskyToABMagTransform>(
false, namespace_separator) +
"()";
58 std::string str()
const override {
59 return parameters::type_name_str<NanojanskyToABMagTransform>(
true) +
"()";
62 inline double derivative(
double x)
const override {
return JanskyToABMagTransform::derivative(x); }
63 inline double forward(
double x)
const override {
return JanskyToABMagTransform::forward(x * 1e-9); }
64 inline double reverse(
double x)
const override {
return 1e9 * JanskyToABMagTransform::reverse(x); }
68 std::string description()
const override {
return "Natural (base e) logarithmic transform"; }
69 std::string repr(
bool name_keywords =
false,
70 const std::string_view& namespace_separator
71 = parameters::Object::CC_NAMESPACE_SEPARATOR)
const override {
72 return parameters::type_name_str<LogTransform>(
false, namespace_separator) +
"()";
74 std::string str()
const override {
return parameters::type_name_str<LogTransform>(
true) +
"()"; }
76 inline double derivative(
double x)
const override {
return 1 / x; }
77 inline double forward(
double x)
const override {
return log(x); }
78 inline double reverse(
double x)
const override {
return exp(x); }
82 std::string description()
const override {
return "Base 10 logarithmic transform"; }
83 std::string repr(
bool name_keywords =
false,
84 const std::string_view& namespace_separator
85 = parameters::Object::CC_NAMESPACE_SEPARATOR)
const override {
86 return parameters::type_name_str<Log10Transform>(
false, namespace_separator) +
"()";
88 std::string str()
const override {
return parameters::type_name_str<Log10Transform>(
true) +
"()"; }
90 inline double derivative(
double x)
const override {
91 return 0.434294481903251827651128918916605082294397 / x;
93 inline double forward(
double x)
const override {
return log10(x); }
94 inline double reverse(
double x)
const override {
return pow(10., x); }
98 std::string description()
const override {
return "Logit transform"; }
99 std::string repr(
bool name_keywords =
false,
100 const std::string_view& namespace_separator
101 = parameters::Object::CC_NAMESPACE_SEPARATOR)
const override {
102 return parameters::type_name_str<LogitTransform>(
false, namespace_separator) +
"()";
104 std::string str()
const override {
return parameters::type_name_str<LogitTransform>(
true) +
"()"; }
106 inline double derivative(
double x)
const override {
return 1 / x + 1 / (1 - x); }
107 inline double forward(
double x)
const override {
return log(x / (1 - x)); }
108 inline double reverse(
double x)
const override {
return 1 / (1 + exp(-x)); }
111class LogitLimitedTransform :
public Transform {
113 explicit LogitLimitedTransform(std::shared_ptr<parameters::Limits<double>> limits,
double factor = 1) {
114 set_limits(std::move(limits));
119 std::string description()
const override {
return "Logit limited (to finite range) transform"; }
120 std::string repr(
bool name_keywords =
false,
121 const std::string_view& namespace_separator
122 = parameters::Object::CC_NAMESPACE_SEPARATOR)
const override {
123 return parameters::type_name_str<LogitLimitedTransform>(
false, namespace_separator) +
"("
124 + (name_keywords ?
"limits=" :
"") + _limits->repr(name_keywords, namespace_separator) +
", "
125 + (name_keywords ?
"factor=" :
"") + std::to_string(_factor) +
")";
127 std::string str()
const override {
128 return parameters::type_name_str<LogitLimitedTransform>(
true) +
"(limits=" + _limits->str()
129 +
", factor=" + std::to_string(_factor) +
")";
132 double get_factor()
const {
return _factor; }
133 parameters::Limits<double>& get_limits()
const {
return *_limits; }
135 double derivative(
double x)
const override;
136 double forward(
double x)
const override;
137 double reverse(
double x)
const override;
139 void set_factor(
double factor) {
141 throw std::invalid_argument(
"LogitLimitedTransform factor=" + std::to_string(factor) +
" !>0");
145 void set_limits(std::shared_ptr<parameters::Limits<double>> limits) {
146 _limits = (limits ==
nullptr) ? std::make_shared<parameters::Limits<double>>() : std::move(limits);
151 std::shared_ptr<parameters::Limits<double>> _limits;
155 inline void _set_range() { _range = _limits->get_max() - _limits->get_min(); }