CXXR (C++ R) API
Public Member Functions
CXXR::VectorOps::BinaryFunction< Functor, AttributeCopier, FunctorWrapper > Class Template Reference

Class used to apply a binary function to vectors. More...

#include <BinaryFunction.hpp>

List of all members.

Public Member Functions

 BinaryFunction (const Functor &f=Functor())
 Constructor.
template<class Vout , class Vl , class Vr >
Vout * apply (const Vl *vl, const Vr *vr) const
 Apply a binary function to a vector.

Detailed Description

template<typename Functor, class AttributeCopier = GeneralBinaryAttributeCopier, template< typename, typename, typename, typename > class FunctorWrapper = BinaryNAPropagator>
class CXXR::VectorOps::BinaryFunction< Functor, AttributeCopier, FunctorWrapper >

Class used to apply a binary function to vectors.

An object of this class is used to create a vector from two others (the operands); the operands must be conformable as tested by checkOperandsConformable().

If either operand has size zero then the result will have size zero. Otherwise, the result will have the same number of elements as the larger of the operands, and each element of the result is obtained by applying the binary function to the corresponding elements of the two operands (treating them for this purpose as vectors). If the operands are of unequal length, the elements in the shorter operand are recycled as necessary; in this case a warning is raised if shorter operand has non-zero length but its length is not an exact submultiple of the length of the longer operand.

Template Parameters:
FunctorFunction or function object type, representing a binary function.
AttributeCopierThis class must define a static member function with the signature copyAttributes(VectorBase* vout, const VectorBase* vl, const VectorBase* vr). (Its return value, if any, is ignored.) The apply() method of BinaryFunction will invoke this member function to copy attributes from the operands vl and vr of the binary function to its result vout. See the description of VectorOps::GeneralBinaryAttributeCopier for a commonly used example (in fact, the default).
FunctorWrapperEach invocation of apply() will create an object of class FunctorWrapper<Functor>, and delegate to it the task of calling the binary function; the FunctorWrapper objects can then monitor any special conditions. See the description of VectorOps::BinaryNAPropagator for further information.

Constructor & Destructor Documentation

template<typename Functor , class AttributeCopier = GeneralBinaryAttributeCopier, template< typename, typename, typename, typename > class FunctorWrapper = BinaryNAPropagator>
CXXR::VectorOps::BinaryFunction< Functor, AttributeCopier, FunctorWrapper >::BinaryFunction ( const Functor &  f = Functor())
inline

Constructor.

Parameters:
fPointer to an object of type Functor defining the binary function that this BinaryFunction object will use to generate an output vector from the operands.

Member Function Documentation

template<typename Functor , class AttributeCopier , template< typename, typename, typename, typename > class FunctorWrapper>
template<class Vout , class Vl , class Vr >
Vout * CXXR::VectorOps::BinaryFunction< Functor, AttributeCopier, FunctorWrapper >::apply ( const Vl *  vl,
const Vr *  vr 
) const

Apply a binary function to a vector.

Template Parameters:
VoutClass of vector to be produced as a result. It must be possible to assign values of the return type of f to the elements of a vector of type Vout .
VlClass of vector forming the first operand. It must be possible implicitly to convert the element data type of Vl to the type of the first argument of f .
VrClass of vector forming the second operand. It must be possible implicitly to convert the element data type of Vr to the type of the second argument of f .
Parameters:
vlNon-null pointer to the first operand.
vrNon-null pointer to the second operand.
Returns:
Pointer to the result vector.

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