30#ifndef UTILS_FUNCTION_UTILS_HPP
31#define UTILS_FUNCTION_UTILS_HPP
43 {15, 1307674368000.0},
44 {20, 2432902008176640000.0},
45 {25, 15511210043330985984000000.0},
46 {30, 265252859812191058636308480000000.0},
57 int satlin(T input, T &output, T limit = 1.0) {
59 if (input > limit) {output = limit;}
60 else if (input < 0) {output = 0.0;}
61 else {output = input;}
73 int satlins(T input, T &output, T limit = 1.0) {
75 if (input > limit) {output = limit;}
76 else if (input < -limit) {output = -limit;}
77 else {output = input;}
90 if (input > 0) {output = input;}
105 if (input < center) {output = 0.0;}
118 output = (input > 0) - (input < 0);
134 T _signum_input;
signum(input, _signum_input);
135 output = (std::abs(input) > bounds) ? (input - _signum_input*bounds) : 0.0;
151 output = (std::abs(input) > bounds) ? (input) : 0.0;
166 int clamp(T input, T min_val, T max_val, T &output) {
167 output = std::max(min_val, std::min(input, max_val));
194 int base = upper->first;
195 T result = upper->second;
196 for (
int i = base + 1; i <= n; ++i)
204 template <
typename T>
#define ERROR_INVALID_RANGE
Definition clockwerkerrors.h:53
#define ERROR_DIVIDE_BY_ZERO
Error code in the case where some fool tried to divide by zero.
Definition clockwerkerrors.h:49
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
int Heaviside(T input, T &output, T center=0.0)
This function is the Heaviside step function (or more colloquially the unit step function)....
Definition functionutils.hpp:103
int clamp(T input, T min_val, T max_val, T &output)
This function will force a value to be between the defined minimum and maximum values....
Definition functionutils.hpp:166
const std::map< int, double > FACTORIAL_CACHE
Definition functionutils.hpp:39
int factorial(int n, T &output)
Computes the factorial of a non-negative integer. Currently the gamma function is not supported.
Definition functionutils.hpp:176
int satlin(T input, T &output, T limit=1.0)
This function is a saturated linear function that behaves like a linear function in the range of [0,...
Definition functionutils.hpp:57
int satlins(T input, T &output, T limit=1.0)
This function is a symmetric saturated linear function that behaves like a linear function in the ran...
Definition functionutils.hpp:73
int poslin(T input, T &output)
This function is a positive linear transfer function that behaves like a linear function only when x ...
Definition functionutils.hpp:88
int deadzone(T input, T bounds, T &output)
This function will supress all inputs within (±) the specified bounds. The deadzone function is NOT p...
Definition functionutils.hpp:149
int signum(T input, T &output)
This function is the signum function (typically denoted sgn). Described simply, it outputs the sign (...
Definition functionutils.hpp:117
const int NO_ERROR
Definition simlicense.cpp:30
int deadzoneTrimmed(T input, T bounds, T &output)
This function will supress all inputs within (±) the specified bounds. The trimmed deadzone function ...
Definition functionutils.hpp:132