fuzzylite  6.0
A Fuzzy Logic Control Library in C++
fl::Operation Class Reference

The Operation class contains methods for numeric operations, string manipulation, and other functions, all of which are also accessible via fl::Op. More...

#include <Operation.h>

Collaboration diagram for fl::Operation:

Public Member Functions

template<>
FL_API std::string str (const std::string &x, int decimals, std::ios_base::fmtflags scalarFormat)
 
template<>
FL_API std::string join (const std::vector< std::string > &x, const std::string &separator)
 
template<>
FL_API std::string join (int items, const std::string &separator, float first,...)
 
template<>
FL_API std::string join (int items, const std::string &separator, const char *first,...)
 

Static Public Member Functions

template<typename T >
static T min (T a, T b)
 Returns the minimum between the two parameters. More...
 
template<typename T >
static T max (T a, T b)
 Returns the maximum between the two parameters. More...
 
template<typename T >
static T bound (T x, T min, T max)
 Returns \(x\) bounded in \([\min,\max]\). More...
 
template<typename T >
static bool in (T x, T min, T max, bool geq=true, bool leq=true)
 Indicates whether \(x\) is within the boundaries (open or closed) More...
 
template<typename T >
static bool isInf (T x)
 Indicates whether \(x\) is infinity. More...
 
template<typename T >
static bool isNaN (T x)
 Indicates whether \(x\) is not-a-number (NaN) More...
 
template<typename T >
static bool isFinite (T x)
 Indicates whether \(x\) is finite, that is, \(x \not\in \{\pm\infty, \mathrm{NaN}\}\). More...
 
static bool isLt (scalar a, scalar b, scalar macheps=fuzzylite::_macheps)
 Returns whether \(a\) is less than \(b\) at the given tolerance. More...
 
static bool isLE (scalar a, scalar b, scalar macheps=fuzzylite::_macheps)
 Returns whether \(a\) is less than or equal to \(b\) at the given tolerance. More...
 
static bool isEq (scalar a, scalar b, scalar macheps=fuzzylite::_macheps)
 Returns whether \(a\) is equal to \(b\) at the given tolerance. More...
 
static bool isGt (scalar a, scalar b, scalar macheps=fuzzylite::_macheps)
 Returns whether \(a\) is greater than \(b\) at the given tolerance. More...
 
static bool isGE (scalar a, scalar b, scalar macheps=fuzzylite::_macheps)
 Returns whether \(a\) is greater than or equal to \(b\) at the given tolerance. More...
 
static scalar scale (scalar x, scalar fromMin, scalar fromMax, scalar toMin, scalar toMax)
 Linearly interpolates the parameter \(x\) in range [fromMin,fromMax] to a new value in the range [toMin,toMax] More...
 
static scalar scale (scalar x, scalar fromMin, scalar fromMax, scalar toMin, scalar toMax, bool bounded)
 Linearly interpolates the parameter \(x\) in range [fromMin,fromMax] to a new value in the range [toMin,toMax], truncated to the range [toMin,toMax] if bounded is true. More...
 
static scalar add (scalar a, scalar b)
 Adds two values. More...
 
static scalar subtract (scalar a, scalar b)
 Subtracts two values. More...
 
static scalar multiply (scalar a, scalar b)
 Multiplies two values. More...
 
static scalar divide (scalar a, scalar b)
 Divides two values. More...
 
static scalar modulo (scalar a, scalar b)
 Computes the modulo. More...
 
static scalar logicalAnd (scalar a, scalar b)
 Computes the logical AND. More...
 
static scalar logicalOr (scalar a, scalar b)
 Computes the logical OR. More...
 
static scalar logicalNot (scalar a)
 Returns the complement of the value. More...
 
static scalar negate (scalar a)
 Negates the value. More...
 
static scalar round (scalar x)
 Rounds the value to the nearest integer. More...
 
static scalar gt (scalar a, scalar b)
 Returns whether \(a\) is greater than or equal to \(b\) at the default tolerance. More...
 
static scalar ge (scalar a, scalar b)
 Returns whether \(a\) is greater than or equal to \(b\) at the default tolerance. More...
 
static scalar eq (scalar a, scalar b)
 Returns whether \(a\) is equal to \(b\) at the default tolerance. More...
 
static scalar neq (scalar a, scalar b)
 Returns whether \(a\) is different from \(b\) at the default tolerance. More...
 
static scalar le (scalar a, scalar b)
 Returns whether \(a\) is less than or equal to \(b\) at the default tolerance. More...
 
static scalar lt (scalar a, scalar b)
 Returns whether \(a\) is less than \(b\) at the default tolerance. More...
 
static int random ()
 Returns a random number. More...
 
static bool increment (std::vector< int > &x, std::vector< int > &min, std::vector< int > &max)
 Increments \(x\) by the unit, treating the entire vector as a number. More...
 
static bool increment (std::vector< int > &x, int position, std::vector< int > &min, std::vector< int > &max)
 Increments \(x\) by the unit at the given position, treating the entire vector as a number. More...
 
template<typename T >
static T sum (const std::vector< T > &x)
 Computes the sum of the vector. More...
 
template<typename T >
static scalar mean (const std::vector< T > &x)
 Computes the mean of the vector. More...
 
template<typename T >
static scalar variance (const std::vector< T > &x)
 Computes the variance of the vector. More...
 
template<typename T >
static scalar variance (const std::vector< T > &x, scalar mean)
 Computes the variance of the vector using the given mean. More...
 
template<typename T >
static scalar standardDeviation (const std::vector< T > &x)
 Computes the standard deviation of the vector. More...
 
template<typename T >
static scalar standardDeviation (const std::vector< T > &x, scalar mean)
 Computes the standard deviation of the vector using the given mean. More...
 
static std::string validName (const std::string &name)
 Returns a valid name for variables. More...
 
static std::string findReplace (const std::string &str, const std::string &find, const std::string &replace, bool replaceAll=true)
 Replaces the substrings that are equal to the given expression. More...
 
static std::string replaceFirst (const std::string &str, const std::string &find, const std::string &replace)
 Replaces the first substring that is equal to the given expression. More...
 
static std::string replaceAll (const std::string &str, const std::string &find, const std::string &replace)
 Replaces the every substring that is equal to the given expression. More...
 
static std::vector< std::string > split (const std::string &str, const std::string &delimiter=" ", bool ignoreEmpty=true)
 Splits the string around the given delimiter. More...
 
static std::string trim (const std::string &text)
 Removes whitespace at the beginning and end of the text. More...
 
static std::string format (const std::string &text, int matchesChar(int), const std::string &replacement="")
 Replaces every matching character in the text with the given replacement. More...
 
static scalar toScalar (const std::string &x)
 Parses the given string into a scalar value. More...
 
static scalar toScalar (const std::string &x, scalar alternative, bool *ok=fl::null) FL_INOEXCEPT
 Parses the given string into a scalar value without throwing an exception. More...
 
static std::vector< scalartoScalars (const std::string &x)
 Parses the given string into a vector of scalar values. More...
 
static std::vector< scalartoScalars (const std::string &x, scalar alternative, bool *ok=fl::null) FL_INOEXCEPT
 Parses the given string into a vector of scalar values. More...
 
static bool isNumeric (const std::string &x)
 Indicates whether the string can be converted to a numeric value. More...
 
template<typename T >
static std::string str (T x, int decimals=fuzzylite::_decimals, std::ios_base::fmtflags scalarFormat=fuzzylite::_scalarFormat)
 Returns a string representation of the given value. More...
 
template<typename T >
static std::string join (const std::vector< T > &x, const std::string &separator)
 Joins a vector of elements by the given separator into a single string. More...
 
template<typename T >
static std::string join (int items, const std::string &separator, T first,...)
 Joins a variadic number of elements by the given separator into a single string. More...
 

Detailed Description

The Operation class contains methods for numeric operations, string manipulation, and other functions, all of which are also accessible via fl::Op.

Author
Juan Rada-Vilela, Ph.D.
Since
4.0

Definition at line 37 of file Operation.h.

Member Function Documentation

◆ add()

scalar fl::Operation::add ( scalar  a,
scalar  b 
)
inlinestatic

Adds two values.

Parameters
a
b
Returns
\(a+b\)

Definition at line 665 of file Operation.h.

◆ bound()

template<typename T >
T fl::Operation::bound ( x,
min,
max 
)
inlinestatic

Returns \(x\) bounded in \([\min,\max]\).

Parameters
xis the value to be bounded
minis the minimum value of the range
maxis the maximum value of the range
Returns
\( \begin{cases} \min & \mbox{if $x < \min$} \cr \max & \mbox{if $x > \max$} \cr x & \mbox{otherwise} \end{cases} \)

Definition at line 608 of file Operation.h.

References max(), and min().

Referenced by scale().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ divide()

scalar fl::Operation::divide ( scalar  a,
scalar  b 
)
inlinestatic

Divides two values.

Parameters
a
b
Returns
\(a/b\)

Definition at line 677 of file Operation.h.

◆ eq()

scalar fl::Operation::eq ( scalar  a,
scalar  b 
)
inlinestatic

Returns whether \(a\) is equal to \(b\) at the default tolerance.

Parameters
a
b
Returns
whether \(a\) is equal to \(b\) at the default tolerance

Definition at line 713 of file Operation.h.

References isEq().

Here is the call graph for this function:

◆ findReplace()

std::string fl::Operation::findReplace ( const std::string &  str,
const std::string &  find,
const std::string &  replace,
bool  replaceAll = true 
)
inlinestatic

Replaces the substrings that are equal to the given expression.

Parameters
stris the target string
findis the string to find
replaceis the string to replace the findings
replaceAllwhether all the substrings are to be replaced or just the first string
Returns
the original string with replacements

Definition at line 813 of file Operation.h.

Referenced by replaceAll(), and replaceFirst().

Here is the caller graph for this function:

◆ format()

std::string fl::Operation::format ( const std::string &  text,
int   matchesCharint,
const std::string &  replacement = "" 
)
inlinestatic

Replaces every matching character in the text with the given replacement.

Parameters
textis the string to have replacements
matchesCharis a pointer to a method that indicates whether the given character is a match
replacementa string to replace a matching character
Returns
the string with every matching character replaced

Definition at line 874 of file Operation.h.

◆ ge()

scalar fl::Operation::ge ( scalar  a,
scalar  b 
)
inlinestatic

Returns whether \(a\) is greater than or equal to \(b\) at the default tolerance.

Parameters
a
b
Returns
whether \(a\) is greater than or equal to \(b\) at the default tolerance

Definition at line 709 of file Operation.h.

References isGE().

Here is the call graph for this function:

◆ gt()

scalar fl::Operation::gt ( scalar  a,
scalar  b 
)
inlinestatic

Returns whether \(a\) is greater than or equal to \(b\) at the default tolerance.

Parameters
a
b
Returns
whether \(a\) is greater than or equal to \(b\) at the default tolerance

Definition at line 705 of file Operation.h.

References isGt().

Here is the call graph for this function:

◆ in()

template<typename T >
bool fl::Operation::in ( x,
min,
max,
bool  geq = true,
bool  leq = true 
)
inlinestatic

Indicates whether \(x\) is within the boundaries (open or closed)

Parameters
xis the value
minis the minimum of the range
maxis the maximum of the range
geqdetermines whether the maximum is a closed interval
leqdetermines whether the minimum is a closed interval
Returns
\( \begin{cases} x \in [\min,\max] & \mbox{if $geq \wedge leq$} \cr x \in (\min,\max] & \mbox{if $geq \wedge \bar{leq}$} \cr x \in [\min, \max) & \mbox{if $\bar{geq} \wedge leq$} \cr x \in (\min, \max) & \mbox{if $\bar{geq} \wedge \bar{leq}$} \cr \end{cases} \)

Definition at line 615 of file Operation.h.

References isGE(), isGt(), isLE(), and isLt().

Here is the call graph for this function:

◆ increment() [1/2]

bool fl::Operation::increment ( std::vector< int > &  x,
std::vector< int > &  min,
std::vector< int > &  max 
)
inlinestatic

Increments \(x\) by the unit, treating the entire vector as a number.

For example, incrementing a few times \(x_0=\{0,0\}\) within boundaries \([0,1]\) results in: \(x_1=\{0,1\}\), \(x_2=\{1,0\}\), \(x_3=\{1,1\}\), \(x_4=\{0,0\}\).

Parameters
xis the vector to increment
minis the minimum value of the dimension
maxis the maximum value of the dimension
Returns
true if \(x\) was incremented, false otherwise (e.g., incrementing \(x_3\) returns false). In earlier versions to 6.0, the result was the inverse and indicated whether the counter had overflown (most sincere apologies for this change).

Definition at line 733 of file Operation.h.

Referenced by increment().

Here is the caller graph for this function:

◆ increment() [2/2]

bool fl::Operation::increment ( std::vector< int > &  x,
int  position,
std::vector< int > &  min,
std::vector< int > &  max 
)
inlinestatic

Increments \(x\) by the unit at the given position, treating the entire vector as a number.

For example, incrementing \(x_0=\{0,0,0\}\) within boundaries \([0,1]\) at the second position results in: \(x_1=\{0,1,0\}\), \(x_2=\{1,0,0\}\), \(x_3=\{1,1,0\}\), \(x_4=\{0,0,0\}\).

Parameters
xis the vector to increment
positionis the position of the vector to increment, where smaller values lead to higher significance digits
minis the minimum value of the dimension
maxis the maximum value of the dimension
Returns
true if \(x\) was incremented, false otherwise (e.g., incrementing \(x_3\) returns false). In earlier versions to 6.0, the result was the inverse and indicated whether the counter had overflown (most sincere apologies for this change).

Definition at line 737 of file Operation.h.

References increment().

Here is the call graph for this function:

◆ isEq()

bool fl::Operation::isEq ( scalar  a,
scalar  b,
scalar  macheps = fuzzylite::_macheps 
)
inlinestatic

Returns whether \(a\) is equal to \(b\) at the given tolerance.

Parameters
a
b
machepsis the minimum difference upon which two floating-point values are considered equivalent
Returns
whether \(a\) is equal to \(b\) at the given tolerance

Definition at line 644 of file Operation.h.

Referenced by eq(), logicalAnd(), logicalNot(), logicalOr(), neq(), and str().

Here is the caller graph for this function:

◆ isFinite()

template<typename T >
bool fl::Operation::isFinite ( x)
inlinestatic

Indicates whether \(x\) is finite, that is, \(x \not\in \{\pm\infty, \mathrm{NaN}\}\).

Parameters
xis the value
Returns
whether \(x\) is finite

Definition at line 632 of file Operation.h.

◆ isGE()

bool fl::Operation::isGE ( scalar  a,
scalar  b,
scalar  macheps = fuzzylite::_macheps 
)
inlinestatic

Returns whether \(a\) is greater than or equal to \(b\) at the given tolerance.

Parameters
a
b
machepsis the minimum difference upon which two floating-point values are considered equivalent
Returns
whether \(a\) is greater than or equal to \(b\) at the given tolerance

Definition at line 652 of file Operation.h.

Referenced by ge(), and in().

Here is the caller graph for this function:

◆ isGt()

bool fl::Operation::isGt ( scalar  a,
scalar  b,
scalar  macheps = fuzzylite::_macheps 
)
inlinestatic

Returns whether \(a\) is greater than \(b\) at the given tolerance.

Parameters
a
b
machepsis the minimum difference upon which two floating-point values are considered equivalent
Returns
whether \(a\) is greater than \(b\) at the given tolerance

Definition at line 648 of file Operation.h.

Referenced by gt(), and in().

Here is the caller graph for this function:

◆ isInf()

template<typename T >
bool fl::Operation::isInf ( x)
inlinestatic

Indicates whether \(x\) is infinity.

Parameters
xis the value
Returns
whether \(x\) is infinity

Definition at line 622 of file Operation.h.

Referenced by str().

Here is the caller graph for this function:

◆ isLE()

bool fl::Operation::isLE ( scalar  a,
scalar  b,
scalar  macheps = fuzzylite::_macheps 
)
inlinestatic

Returns whether \(a\) is less than or equal to \(b\) at the given tolerance.

Parameters
a
b
machepsis the minimum difference upon which two floating-point values are considered equivalent
Returns
whether \(a\) is less than or equal to \(b\) at the given tolerance

Definition at line 640 of file Operation.h.

Referenced by in(), and le().

Here is the caller graph for this function:

◆ isLt()

bool fl::Operation::isLt ( scalar  a,
scalar  b,
scalar  macheps = fuzzylite::_macheps 
)
inlinestatic

Returns whether \(a\) is less than \(b\) at the given tolerance.

Parameters
a
b
machepsis the minimum difference upon which two floating-point values are considered equivalent
Returns
whether \(a\) is less than \(b\) at the given tolerance

Definition at line 636 of file Operation.h.

Referenced by in(), and lt().

Here is the caller graph for this function:

◆ isNaN()

template<typename T >
bool fl::Operation::isNaN ( x)
inlinestatic

Indicates whether \(x\) is not-a-number (NaN)

Parameters
xis the value
Returns
whether \(x\) is not-a-number (NaN)

Definition at line 627 of file Operation.h.

Referenced by max(), min(), and str().

Here is the caller graph for this function:

◆ isNumeric()

bool fl::Operation::isNumeric ( const std::string &  x)
inlinestatic

Indicates whether the string can be converted to a numeric value.

Parameters
x
Returns
whether the string can be converted to a numeric value

Definition at line 966 of file Operation.h.

References toScalar().

Here is the call graph for this function:

◆ join() [1/5]

template<typename T >
std::string fl::Operation::join ( const std::vector< T > &  x,
const std::string &  separator 
)
inlinestatic

Joins a vector of elements by the given separator into a single string.

The elements are represented as strings utilizing the Operation::str() method on each element

Parameters
xis the vector of elements
separatoris the string to add between the elements
Returns
a single string joining the vector of elements by the given separator

Definition at line 1001 of file Operation.h.

References FL_API, and str().

Here is the call graph for this function:

◆ join() [2/5]

template<typename T >
std::string fl::Operation::join ( int  items,
const std::string &  separator,
first,
  ... 
)
inlinestatic

Joins a variadic number of elements by the given separator into a single string.

The elements are represented as strings utilizing the Operation::str() method on each element

Parameters
itemsis the number of elements to join
separatoris the string to add between the elements
firstis the first element, which defines the type of the subsequent elements
...are the remaining elements to join
Returns
a single string joining the variadic number of elements by the given separator

Definition at line 1023 of file Operation.h.

References FL_API, and str().

Here is the call graph for this function:

◆ join() [3/5]

template<>
FL_API std::string fl::Operation::join ( const std::vector< std::string > &  x,
const std::string &  separator 
)
inline

Definition at line 1012 of file Operation.h.

◆ join() [4/5]

template<>
FL_API std::string fl::Operation::join ( int  items,
const std::string &  separator,
float  first,
  ... 
)
inline

Definition at line 1038 of file Operation.h.

References FL_API, and str().

Here is the call graph for this function:

◆ join() [5/5]

template<>
FL_API std::string fl::Operation::join ( int  items,
const std::string &  separator,
const char *  first,
  ... 
)
inline

Definition at line 1054 of file Operation.h.

◆ le()

scalar fl::Operation::le ( scalar  a,
scalar  b 
)
inlinestatic

Returns whether \(a\) is less than or equal to \(b\) at the default tolerance.

Parameters
a
b
Returns
whether \(a\) is less than or equal to \(b\) at the default tolerance

Definition at line 721 of file Operation.h.

References isLE().

Here is the call graph for this function:

◆ logicalAnd()

scalar fl::Operation::logicalAnd ( scalar  a,
scalar  b 
)
inlinestatic

Computes the logical AND.

Parameters
a
b
Returns
\( \begin{cases} 1.0 & \mbox{if $a=1 \wedge b=1$}\cr 0.0 & \mbox{otherwise} \end{cases} \)

Definition at line 685 of file Operation.h.

References isEq().

Here is the call graph for this function:

◆ logicalNot()

scalar fl::Operation::logicalNot ( scalar  a)
inlinestatic

Returns the complement of the value.

Parameters
a
Returns
\( \begin{cases} 0.0 & \mbox{if $a=1$}\cr 1.0 & \mbox{otherwise} \end{cases} \)

Definition at line 693 of file Operation.h.

References isEq().

Here is the call graph for this function:

◆ logicalOr()

scalar fl::Operation::logicalOr ( scalar  a,
scalar  b 
)
inlinestatic

Computes the logical OR.

Parameters
a
b
Returns
\( \begin{cases} 1.0 & \mbox{if $a=1 \vee b=1$}\cr 0.0 & \mbox{otherwise} \end{cases} \)

Definition at line 689 of file Operation.h.

References isEq().

Here is the call graph for this function:

◆ lt()

scalar fl::Operation::lt ( scalar  a,
scalar  b 
)
inlinestatic

Returns whether \(a\) is less than \(b\) at the default tolerance.

Parameters
a
b
Returns
whether \(a\) is less than \(b\) at the default tolerance

Definition at line 725 of file Operation.h.

References isLt().

Here is the call graph for this function:

◆ max()

template<typename T >
T fl::Operation::max ( a,
b 
)
inlinestatic

Returns the maximum between the two parameters.

Parameters
a
b
Returns
\(\max(a,b)\)

Definition at line 601 of file Operation.h.

References isNaN().

Referenced by bound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mean()

template<typename T >
scalar fl::Operation::mean ( const std::vector< T > &  x)
inlinestatic

Computes the mean of the vector.

Parameters
xis the vector
Returns
\(\dfrac{\sum_i{x_i}}{|x|}\)

Definition at line 764 of file Operation.h.

References sum().

Referenced by standardDeviation(), and variance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ min()

template<typename T >
T fl::Operation::min ( a,
b 
)
inlinestatic

Returns the minimum between the two parameters.

Parameters
a
b
Returns
\(\min(a,b)\)

Definition at line 594 of file Operation.h.

References isNaN().

Referenced by bound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modulo()

scalar fl::Operation::modulo ( scalar  a,
scalar  b 
)
inlinestatic

Computes the modulo.

Parameters
a
b
Returns
\(a \mod b\)

Definition at line 681 of file Operation.h.

◆ multiply()

scalar fl::Operation::multiply ( scalar  a,
scalar  b 
)
inlinestatic

Multiplies two values.

Parameters
a
b
Returns
\(a\times b\)

Definition at line 673 of file Operation.h.

◆ negate()

scalar fl::Operation::negate ( scalar  a)
inlinestatic

Negates the value.

Parameters
a
Returns
-a

Definition at line 697 of file Operation.h.

◆ neq()

scalar fl::Operation::neq ( scalar  a,
scalar  b 
)
inlinestatic

Returns whether \(a\) is different from \(b\) at the default tolerance.

Parameters
a
b
Returns
whether \(a\) is different from \(b\) at the default tolerance

Definition at line 717 of file Operation.h.

References isEq().

Here is the call graph for this function:

◆ random()

int fl::Operation::random ( )
inlinestatic

Returns a random number.

Definition at line 729 of file Operation.h.

◆ replaceAll()

std::string fl::Operation::replaceAll ( const std::string &  str,
const std::string &  find,
const std::string &  replace 
)
inlinestatic

Replaces the every substring that is equal to the given expression.

Parameters
stris the target string
findis the string to find
replaceis the string to replace
Returns
the original string with all of the replacements

Definition at line 832 of file Operation.h.

References findReplace().

Here is the call graph for this function:

◆ replaceFirst()

std::string fl::Operation::replaceFirst ( const std::string &  str,
const std::string &  find,
const std::string &  replace 
)
inlinestatic

Replaces the first substring that is equal to the given expression.

Parameters
stris the target string
findis the string to find
replaceis the string to replace
Returns
the original string with the replacement

Definition at line 827 of file Operation.h.

References findReplace().

Here is the call graph for this function:

◆ round()

scalar fl::Operation::round ( scalar  x)
inlinestatic

Rounds the value to the nearest integer.

Parameters
x
Returns
\( \begin{cases} \lfloor x + 0.5 \rfloor & \mbox{if $x > 0$}\cr \lceil x - 0.5 \rceil & \mbox{otherwise} \end{cases} \)

Definition at line 701 of file Operation.h.

◆ scale() [1/2]

scalar fl::Operation::scale ( scalar  x,
scalar  fromMin,
scalar  fromMax,
scalar  toMin,
scalar  toMax 
)
inlinestatic

Linearly interpolates the parameter \(x\) in range [fromMin,fromMax] to a new value in the range [toMin,toMax]

Parameters
xis the source value to interpolate
fromMinis the minimum value of the source range
fromMaxis the maximum value of the source range
toMinis the minimum value of the target range
toMaxis the maximum value of the target range
Returns
the source value linearly interpolated to the target range: \( y = y_a + (y_b - y_a) \dfrac{x-x_a}{x_b-x_a} \)

Definition at line 656 of file Operation.h.

◆ scale() [2/2]

scalar fl::Operation::scale ( scalar  x,
scalar  fromMin,
scalar  fromMax,
scalar  toMin,
scalar  toMax,
bool  bounded 
)
inlinestatic

Linearly interpolates the parameter \(x\) in range [fromMin,fromMax] to a new value in the range [toMin,toMax], truncated to the range [toMin,toMax] if bounded is true.

Parameters
xis the source value to interpolate
fromMinis the minimum value of the source range
fromMaxis the maximum value of the source range
toMinis the minimum value of the target range
toMaxis the maximum value of the target range
boundeddetermines whether the resulting value is bounded to the range
Returns
the source value linearly interpolated to the target range: \( y = y_a + (y_b - y_a) \dfrac{x-x_a}{x_b-x_a} \)

Definition at line 660 of file Operation.h.

References bound().

Here is the call graph for this function:

◆ split()

std::vector< std::string > fl::Operation::split ( const std::string &  str,
const std::string &  delimiter = " ",
bool  ignoreEmpty = true 
)
inlinestatic

Splits the string around the given delimiter.

Parameters
stris the string to split
delimiteris the substrings on which the string will be split
ignoreEmptywhether the empty strings are discarded
Returns
the string split around the given delimiter

Definition at line 837 of file Operation.h.

◆ standardDeviation() [1/2]

template<typename T >
scalar fl::Operation::standardDeviation ( const std::vector< T > &  x)
inlinestatic

Computes the standard deviation of the vector.

Parameters
x
Returns
\( \sqrt{\mbox{variance}(x, \bar{x})} \)

Definition at line 769 of file Operation.h.

References mean().

Here is the call graph for this function:

◆ standardDeviation() [2/2]

template<typename T >
scalar fl::Operation::standardDeviation ( const std::vector< T > &  x,
scalar  mean 
)
inlinestatic

Computes the standard deviation of the vector using the given mean.

Parameters
x
meanis the mean value of x
Returns
\( \sqrt{\mbox{variance}(x, \bar{x})} \)

Definition at line 774 of file Operation.h.

References variance().

Here is the call graph for this function:

◆ str() [1/2]

template<typename T >
std::string fl::Operation::str ( x,
int  decimals = fuzzylite::_decimals,
std::ios_base::fmtflags  scalarFormat = fuzzylite::_scalarFormat 
)
inlinestatic

Returns a string representation of the given value.

Parameters
xis the value
decimalsis the number of decimals to display
scalarFormatare the flags for the underlying std::ostringstream
Returns
a string representation of the given value

Definition at line 976 of file Operation.h.

References FL_API, isEq(), isInf(), and isNaN().

Referenced by join().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str() [2/2]

template<>
FL_API std::string fl::Operation::str ( const std::string &  x,
int  decimals,
std::ios_base::fmtflags  scalarFormat 
)
inline

Definition at line 993 of file Operation.h.

References FL_IUNUSED.

◆ subtract()

scalar fl::Operation::subtract ( scalar  a,
scalar  b 
)
inlinestatic

Subtracts two values.

Parameters
a
b
Returns
\(a-b\)

Definition at line 669 of file Operation.h.

◆ sum()

template<typename T >
T fl::Operation::sum ( const std::vector< T > &  x)
inlinestatic

Computes the sum of the vector.

Definition at line 755 of file Operation.h.

Referenced by mean().

Here is the caller graph for this function:

◆ toScalar() [1/2]

scalar fl::Operation::toScalar ( const std::string &  x)
inlinestatic

Parses the given string into a scalar value.

Parameters
xis the string to parse
Returns
the given string into a scalar value
Exceptions
fl::Exceptionif the string does not contain a scalar value

Definition at line 889 of file Operation.h.

References FL_AT.

Referenced by isNumeric(), and toScalars().

Here is the caller graph for this function:

◆ toScalar() [2/2]

scalar fl::Operation::toScalar ( const std::string &  x,
scalar  alternative,
bool *  ok = fl::null 
)
inlinestatic

Parses the given string into a scalar value without throwing an exception.

Parameters
xis the string to parse
alternativeis the value to return if the string does not contain a scalar value
okcontains whether the operation was successful (optional)
Returns
the given string into a scalar value or the alternative value if the string does not contain a scalar value

Definition at line 914 of file Operation.h.

◆ toScalars() [1/2]

std::vector< scalar > fl::Operation::toScalars ( const std::string &  x)
inlinestatic

Parses the given string into a vector of scalar values.

Parameters
xis the string containing space-separated values to parse
Returns
the vector of scalar values
Exceptions
fl::Exceptionif the string contains an invalid scalar value

Definition at line 941 of file Operation.h.

References toScalar().

Here is the call graph for this function:

◆ toScalars() [2/2]

std::vector< scalar > fl::Operation::toScalars ( const std::string &  x,
scalar  alternative,
bool *  ok = fl::null 
)
inlinestatic

Parses the given string into a vector of scalar values.

Parameters
xis the string containing space-separated values to parse
alternativeis the value to use if an invalid value is found
okcontains whether the operation was successful (optional)
Returns
the vector of scalar values

Definition at line 951 of file Operation.h.

References toScalar().

Here is the call graph for this function:

◆ trim()

std::string fl::Operation::trim ( const std::string &  text)
inlinestatic

Removes whitespace at the beginning and end of the text.

Parameters
text
Returns
a space-trimmed string

Definition at line 858 of file Operation.h.

Referenced by validName().

Here is the caller graph for this function:

◆ validName()

std::string fl::Operation::validName ( const std::string &  name)
inlinestatic

Returns a valid name for variables.

Parameters
name
Returns
an name whose characters are in [a-zA-Z_0-9.]

Definition at line 801 of file Operation.h.

References trim().

Here is the call graph for this function:

◆ variance() [1/2]

template<typename T >
scalar fl::Operation::variance ( const std::vector< T > &  x)
inlinestatic

Computes the variance of the vector.

Parameters
xis the vector
Returns
\( \sum_i{ (x_i - \bar{x})^2 } / (|x| - 1) \)

Definition at line 781 of file Operation.h.

References mean().

Referenced by standardDeviation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ variance() [2/2]

template<typename T >
scalar fl::Operation::variance ( const std::vector< T > &  x,
scalar  mean 
)
inlinestatic

Computes the variance of the vector using the given mean.

Parameters
xis the vector
meanis the mean value of the vector
Returns
\( \sum_i{ (x_i - \bar{x})^2 } / (|x| - 1) \)

Definition at line 786 of file Operation.h.

References mean().

Here is the call graph for this function:

The documentation for this class was generated from the following file: