MGIS 3.1.0
Loading...
Searching...
No Matches
UnaryOperation.hxx File Reference

This file declares the UnaryOperation and UnaryOperation2 classes, which build a new evaluator by applying a unary operation to the values returned by an existing evaluator, the unary_operation and transform functions used to build such evaluators, the customization points used to implement unary operations on the supported result types and the predefined modifiers absolute_value, maximum_component, minimum_component, negate, multiply_by_scalar and divide_by_scalar. More...

#include <span>
#include <algorithm>
#include <type_traits>
#include "MGIS/Function/EvaluatorModifierBase.hxx"
#include "MGIS/Function/UnaryOperation.ixx"

Classes

struct  mgis::function::internals::UnaryOperationBase< CallableType, EvaluatorType >
 helper base class giving the number of components of the values returned by a unary operation applied to an evaluator More...
struct  mgis::function::UnaryOperation< CallableType, EvaluatorType >
 an evaluator applying a unary operation to the values returned by another evaluator More...
struct  mgis::function::UnaryOperation2< CallableType, EvaluatorType >
 an evaluator applying a unary operation to the values returned by another evaluator, without storing this operation More...
struct  mgis::function::internals::unary_operation_modifier< CallableType >
 a modifier building a UnaryOperation from a callable object which is stored in the modifier itself More...
struct  mgis::function::internals::unary_operation_modifier2_impl< CallableType >
 a modifier building a UnaryOperation2 from a callable object which is not stored in the modifier More...
struct  mgis::function::customization_points::AbsoluteValue< real >
 specialization for scalar values More...
struct  mgis::function::customization_points::AbsoluteValue< std::span< const real, N > >
 specialization for constant fixed sized spans More...
struct  mgis::function::customization_points::AbsoluteValue< std::array< real, N > >
 specialization for fixed sized arrays of scalar values More...
struct  mgis::function::customization_points::MaximumComponent< real >
 specialization for scalar values More...
struct  mgis::function::customization_points::MaximumComponent< std::span< const real, N > >
 specialization for constant fixed sized spans More...
struct  mgis::function::customization_points::MaximumComponent< std::array< real, N > >
 specialization for fixed sized arrays of scalar values More...
struct  mgis::function::customization_points::MinimumComponent< real >
 specialization for scalar values More...
struct  mgis::function::customization_points::MinimumComponent< std::span< const real, N > >
 specialization for constant fixed sized spans More...
struct  mgis::function::customization_points::MinimumComponent< std::array< real, N > >
 specialization for fixed sized arrays of scalar values More...
struct  mgis::function::internals::AbsoluteValueOperator
 functor returning the absolute value of the values returned by an evaluator, using the customization_points::AbsoluteValue customization point More...
struct  mgis::function::internals::MaximumComponentOperator
 functor returning the largest component of the values returned by an evaluator, using the customization_points::MaximumComponent customization point More...
struct  mgis::function::internals::MinimumComponentOperator
 functor returning the smallest component of the values returned by an evaluator, using the customization_points::MinimumComponent customization point More...

Namespaces

namespace  mgis
 the namespace mgis encloses all the MGIS project.

Functions

template<typename CallableType, EvaluatorConcept EvaluatorType>
constexpr mgis::size_type mgis::function::getNumberOfComponents (const UnaryOperation< CallableType, EvaluatorType > &) MGIS_NOEXCEPT
 return the number of components of the values returned by a unary operation
template<typename CallableType, EvaluatorConcept EvaluatorType>
constexpr mgis::size_type mgis::function::getNumberOfComponents (const UnaryOperation2< CallableType, EvaluatorType > &) MGIS_NOEXCEPT
 return the number of components of the values returned by a unary operation which does not store its callable object
template<typename CallableType>
MGIS_HOST_DEVICE constexpr auto mgis::function::internals::unary_operation_modifier2 (CallableType)
 create a modifier from a callable object which is only used to deduce the type of the unary operation
template<typename CallableType>
constexpr auto mgis::function::unary_operation (CallableType &&)
 create a modifier applying a unary operation to the values returned by an evaluator
template<typename CallableType, EvaluatorConcept EvaluatorType>
constexpr auto mgis::function::unary_operation (CallableType &&, const EvaluatorType &)
 apply a unary operation to the values returned by an evaluator
template<typename CallableType>
constexpr auto mgis::function::transform (CallableType &&)
 create a modifier transforming the values returned by an evaluator
template<typename CallableType, EvaluatorConcept EvaluatorType>
constexpr auto mgis::function::transform (CallableType &&, const EvaluatorType &)
 transform the values returned by an evaluator

Variables

constexpr auto mgis::function::absolute_value
 modifier returning the absolute value of the values returned by an evaluator, as in e | absolute_value
constexpr auto mgis::function::maximum_component
 modifier returning the largest component of the values returned by an evaluator as a scalar value, as in e | maximum_component
constexpr auto mgis::function::minimum_component
 modifier returning the smallest component of the values returned by an evaluator as a scalar value, as in e | minimum_component

Detailed Description

This file declares the UnaryOperation and UnaryOperation2 classes, which build a new evaluator by applying a unary operation to the values returned by an existing evaluator, the unary_operation and transform functions used to build such evaluators, the customization points used to implement unary operations on the supported result types and the predefined modifiers absolute_value, maximum_component, minimum_component, negate, multiply_by_scalar and divide_by_scalar.

Author
Thomas Helfer
Date
09/05/2025

Function Documentation

◆ getNumberOfComponents() [1/2]

template<typename CallableType, EvaluatorConcept EvaluatorType>
mgis::size_type mgis::function::getNumberOfComponents ( const UnaryOperation2< CallableType, EvaluatorType > & e)
constexpr

return the number of components of the values returned by a unary operation which does not store its callable object

forwards the call to the getNumberOfComponents member

Template Parameters
CallableTypetype of the unary operation
EvaluatorTypetype of the evaluator whose values are modified
Parameters
[in]eunary operation
Returns
number of components of the values returned by the operation

◆ getNumberOfComponents() [2/2]

template<typename CallableType, EvaluatorConcept EvaluatorType>
mgis::size_type mgis::function::getNumberOfComponents ( const UnaryOperation< CallableType, EvaluatorType > & e)
constexpr

return the number of components of the values returned by a unary operation

forwards the call to the getNumberOfComponents member

Template Parameters
CallableTypetype of the unary operation
EvaluatorTypetype of the evaluator whose values are modified
Parameters
[in]eunary operation
Returns
number of components of the values returned by the operation

◆ transform() [1/2]

template<typename CallableType>
auto mgis::function::transform ( CallableType && c)
constexpr

create a modifier transforming the values returned by an evaluator

alias of the single argument unary_operation function

This function is an alias of the unary_operation function, which is often more readable when the operation is a user defined lambda:

const auto e2 = e | transform([](const real v) { return v * v; });
Template Parameters
CallableTypetype of the unary operation, which may be a qualified type
Parameters
[in]cunary operation, a copy of it is stored in the modifier
Returns
a internals::unary_operation_modifier object

◆ transform() [2/2]

template<typename CallableType, EvaluatorConcept EvaluatorType>
auto mgis::function::transform ( CallableType && c,
const EvaluatorType & e )
constexpr

transform the values returned by an evaluator

alias of the two arguments unary_operation function

This function is an alias of the unary_operation function taking an evaluator as second argument.

Template Parameters
CallableTypetype of the unary operation, which may be a qualified type
EvaluatorTypetype of the evaluator
Parameters
[in]cunary operation, which must be callable with the values returned by the evaluator
[in]eevaluator whose values are modified
Returns
a UnaryOperation object, i.e. an evaluator returning the values computed by the callable object

◆ unary_operation() [1/2]

template<typename CallableType>
auto mgis::function::unary_operation ( CallableType && c)
constexpr

create a modifier applying a unary operation to the values returned by an evaluator

creates a modifier storing a copy of the given callable

The returned modifier can be applied to an evaluator using operator| or composed with other modifiers, as in e | unary_operation(c1) | unary_operation(c2).

Template Parameters
CallableTypetype of the unary operation, which may be a qualified type
Parameters
[in]cunary operation, a copy of it is stored in the modifier
Returns
a internals::unary_operation_modifier object

◆ unary_operation() [2/2]

template<typename CallableType, EvaluatorConcept EvaluatorType>
auto mgis::function::unary_operation ( CallableType && c,
const EvaluatorType & e )
constexpr

apply a unary operation to the values returned by an evaluator

applies the modifier to the given evaluator using operator|

Template Parameters
CallableTypetype of the unary operation, which may be a qualified type
EvaluatorTypetype of the evaluator
Parameters
[in]cunary operation, which must be callable with the values returned by the evaluator
[in]eevaluator whose values are modified
Returns
a UnaryOperation object, i.e. an evaluator returning the values computed by the callable object

◆ unary_operation_modifier2()

template<typename CallableType>
MGIS_HOST_DEVICE constexpr auto mgis::function::internals::unary_operation_modifier2 ( CallableType )
constexpr

create a modifier from a callable object which is only used to deduce the type of the unary operation

Template Parameters
CallableTypetype of the unary operation, which must be trivially default constructible
Parameters
[in]ccallable object which is discarded, as the operation is recreated when the values are computed
Returns
a stateless modifier of type unary_operation_modifier2_impl<CallableType>

create a modifier from a callable object which is only used to deduce the type of the unary operation

Variable Documentation

◆ absolute_value

auto mgis::function::absolute_value
inlineconstexpr
Initial value:
=
MGIS_HOST_DEVICE constexpr auto unary_operation_modifier2(CallableType)
create a modifier from a callable object which is only used to deduce the type of the unary operation
Definition UnaryOperation.ixx:108
functor returning the absolute value of the values returned by an evaluator, using the customization_...
Definition UnaryOperation.hxx:621

modifier returning the absolute value of the values returned by an evaluator, as in e | absolute_value

The number of components of the values returned by the modifier is that of the values computed by the underlying evaluator: the result is a scalar value if the evaluator returns a scalar value, a std::array of scalar values if it returns a fixed size span.

◆ maximum_component

auto mgis::function::maximum_component
inlineconstexpr
Initial value:
=
functor returning the largest component of the values returned by an evaluator, using the customizati...
Definition UnaryOperation.hxx:642

modifier returning the largest component of the values returned by an evaluator as a scalar value, as in e | maximum_component

◆ minimum_component

auto mgis::function::minimum_component
inlineconstexpr
Initial value:
=
functor returning the smallest component of the values returned by an evaluator, using the customizat...
Definition UnaryOperation.hxx:663

modifier returning the smallest component of the values returned by an evaluator as a scalar value, as in e | minimum_component