FuncSketch
Loading...
Searching...
No Matches
func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument > Class Template Reference

Class of general implementation of mathematical functions. More...

#include <func_sketch/math/general_math_function.h>

Collaboration diagram for func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >:

Public Member Functions

template<typename InputFunctionType>
 GeneralMathFunction (std::string name, InputFunctionType &&function)
 Constructor.
std::string_view name () const noexcept
 Get the name of the function.
void operator() (const std::vector< Number > &args, Number &result) const
 Operate on scalars.

Private Types

using AcceptableTypesTuples = std::tuple<AcceptableTypesPerArgument...>
 Type of tuples of acceptable types.

Private Member Functions

template<std::size_t... Indices>
void operate_impl (const std::vector< Number > &args, Number &result, std::index_sequence< Indices... >) const
 Operate on scalars (internal implementation).

Static Private Member Functions

template<typename GivenType, std::size_t Index>
static constexpr bool is_acceptable ()
 Check whether the given type is acceptable for the argument at the given index.
template<typename GivenType, std::size_t Index>
static auto convert_to_acceptable_type (const GivenType &value)
 Convert the given value to an acceptable type for the argument at the given index.
template<std::same_as< bool >... T>
static constexpr std::size_t get_first_false (bool first, T... remaining)
 Get the index of the first false value.
static constexpr std::size_t get_first_false ()
 Get the first false. (Variadic template base case).

Private Attributes

std::string name_
 Function name.
FunctionType function_
 Function object to compute numbers.

Detailed Description

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
class func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >

Class of general implementation of mathematical functions.

Template Parameters
FunctionTypeType of the function object to compute numbers.
AcceptableTypesPerArgumentfunc_sketch::math::AcceptableTypes types for each argument.

Definition at line 49 of file general_math_function.h.

Member Typedef Documentation

◆ AcceptableTypesTuples

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
using func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::AcceptableTypesTuples = std::tuple<AcceptableTypesPerArgument...>
private

Type of tuples of acceptable types.

Definition at line 88 of file general_math_function.h.

Constructor & Destructor Documentation

◆ GeneralMathFunction()

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
template<typename InputFunctionType>
func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::GeneralMathFunction ( std::string name,
InputFunctionType && function )
inline

Constructor.

Template Parameters
InputFunctionTypeType of the function object to compute numbers.
Parameters
[in]nameName of the function.
[in]functionFunction object to compute numbers.

Definition at line 59 of file general_math_function.h.

Member Function Documentation

◆ name()

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
std::string_view func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::name ( ) const
inlinenodiscardnoexcept

Get the name of the function.

Returns
Name of the function.

Definition at line 68 of file general_math_function.h.

◆ operator()()

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
void func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::operator() ( const std::vector< Number > & args,
Number & result ) const
inline

Operate on scalars.

Parameters
[in]argsArguments.
[out]resultResult.

Definition at line 76 of file general_math_function.h.

◆ operate_impl()

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
template<std::size_t... Indices>
void func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::operate_impl ( const std::vector< Number > & args,
Number & result,
std::index_sequence< Indices... >  ) const
inlineprivate

Operate on scalars (internal implementation).

Template Parameters
IndicesIndices of arguments.
Parameters
[in]argsArguments.
[out]resultResult.

Definition at line 98 of file general_math_function.h.

◆ is_acceptable()

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
template<typename GivenType, std::size_t Index>
constexpr bool func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::is_acceptable ( )
inlinestaticnodiscardconstexprprivate

Check whether the given type is acceptable for the argument at the given index.

Template Parameters
GivenTypeType of the given argument.
IndexIndex of the argument.
Return values
trueThe given type is acceptable for the argument at the given index.
falseThe given type is not acceptable for the argument at the given index.

Definition at line 139 of file general_math_function.h.

◆ convert_to_acceptable_type()

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
template<typename GivenType, std::size_t Index>
auto func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::convert_to_acceptable_type ( const GivenType & value)
inlinestaticnodiscardprivate

Convert the given value to an acceptable type for the argument at the given index.

Template Parameters
GivenTypeType of the given argument.
IndexIndex of the argument.
Parameters
[in]valueValue to convert.
Returns
Converted value.

Definition at line 157 of file general_math_function.h.

◆ get_first_false() [1/2]

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
template<std::same_as< bool >... T>
constexpr std::size_t func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::get_first_false ( bool first,
T... remaining )
inlinestaticnodiscardconstexprprivate

Get the index of the first false value.

Template Parameters
TTypes of the remaining boolean values.
Parameters
[in]firstThe first boolean value.
[in]remainingThe remaining boolean values.
Returns
Index of the first false value. Returns the size of the list if all values are true.

Definition at line 175 of file general_math_function.h.

◆ get_first_false() [2/2]

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
constexpr std::size_t func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::get_first_false ( )
inlinestaticnodiscardconstexprprivate

Get the first false. (Variadic template base case).

Returns
Index of the first false value. Returns 0 in this base case.

Definition at line 188 of file general_math_function.h.

Member Data Documentation

◆ name_

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
std::string func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::name_
private

Function name.

Definition at line 191 of file general_math_function.h.

◆ function_

template<typename FunctionType, AcceptableTypesSpec... AcceptableTypesPerArgument>
FunctionType func_sketch::math::GeneralMathFunction< FunctionType, AcceptableTypesPerArgument >::function_
private

Function object to compute numbers.

Definition at line 194 of file general_math_function.h.


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