classPii::BinaryCompose
#include <PiiFunctional.h>
A unary/binary function adaptor that makes the results of two unary functions the arguments of a binary function.
Inherits Pii::UnaryFunction< AdaptableUnaryFunction1::argument_type, AdaptableBinaryFunction::result_type >, Pii::BinaryFunction< AdaptableUnaryFunction1::argument_type, AdaptableUnaryFunction2::argument_type, AdaptableBinaryFunction::result_type >
Description
If the binary function is f(x,y) and the two unary functions are g(x) and h(x), the unary composition returns f(g(x),h(x)). If the object is used as a binary function, the composition returns f(g(x), h(y)).
PiiMatrix<double> mat(1,5, 1.0, 2.0, 3.0, 4.0, 5.0); // Calculate sin(mat) + cos(mat) mat.map(Pii::binaryCompose(std::plus<double>(), std::ptr_fun(sin), std::ptr_fun(cos))); PiiMatrix<double> mat2(1,5, -1.0, 2.0, -3.0, 4.0, -5.0); // Calculate mat - sqrt(mat2) mat.map(Pii::binaryCompose(std::minus<double>(), Pii::Identity<double>, Pii::Sqrt<double>()), mat2);
See also
Constructors and destructor
|
(
Construct a BinaryCompose object. |
Public member functions
|
AdaptableBinaryFunction::result_type
|
(
|
|
AdaptableBinaryFunction::result_type
|
(
|
|
template<class AdaptableBinaryFunction, class
AdaptableUnaryFunction1, class AdaptableUnaryFunction2>
BinaryCompose<
AdaptableBinaryFunction, AdaptableUnaryFunction1,
AdaptableUnaryFunction2 >
|
(
Construct a composed unary function (BinaryCompose) out of an adaptable binary function and two adaptable unary functions. |
Function details
-
BinaryCompose
(- const AdaptableBinaryFunction & op1
- const AdaptableUnaryFunction1 & op2
- const AdaptableUnaryFunction2 & op3
[inline]Construct a BinaryCompose object.
It is seldom necessary to use the constructor directly. Use the binaryCompose() function instead.
-
AdaptableBinaryFunction::result_type operator()
(- const typename AdaptableUnaryFunction1::argument_type & value1
- const typename AdaptableUnaryFunction2::argument_type & value2
[inline] -
AdaptableBinaryFunction::result_type operator()
(- const typename AdaptableUnaryFunction1::argument_type & value
[inline] -
template<class AdaptableBinaryFunction, class AdaptableUnaryFunction1, class AdaptableUnaryFunction2>
BinaryCompose< AdaptableBinaryFunction, AdaptableUnaryFunction1, AdaptableUnaryFunction2 > binaryCompose
(- const AdaptableBinaryFunction & op1
- const AdaptableUnaryFunction1 & op2
- const AdaptableUnaryFunction2 & op3
[inline]Construct a composed unary function (BinaryCompose) out of an adaptable binary function and two adaptable unary functions.
Add a note
Not a single note added yet. Be the first, add yours.