vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Public Types | Static Public Attributes | List of all members
vspline::unary_functor< IN, OUT, _vsize > Struct Template Reference

class unary_functor provides a functor object which offers a system of types for concrete unary functors derived from it. If vectorization isn't used, this is trivial, but with vectorization in use, we get vectorized types derived from plain IN and OUT via query of vspline::vector_traits. More...

#include <unary_functor.h>

Inheritance diagram for vspline::unary_functor< IN, OUT, _vsize >:
vspline::unary_functor_tag< vspline::vector_traits< IN > ::size >

Public Types

enum  { vsize = _vsize }
 
enum  { dim_in = vspline::vector_traits < IN > :: dimension }
 
enum  { dim_out = vspline::vector_traits < OUT > :: dimension }
 
typedef IN in_type
 
typedef OUT out_type
 
typedef vspline::vector_traits< IN >::ele_type in_ele_type
 
typedef vspline::vector_traits< OUT >::ele_type out_ele_type
 
typedef vigra::TinyVector< in_ele_type, dim_inin_nd_ele_type
 
typedef vigra::TinyVector< out_ele_type, dim_outout_nd_ele_type
 
typedef vector_traits< IN, vsize >::ele_v in_ele_v
 a simdized type of the elementary type of result_type, which is used for coefficients and results. this is fixed via the traits class vector_traits (in vector.h). Note how we derive this type using vsize from the template argument, not what vspline::vector_traits deems appropriate for ele_type - though both numbers will be the same in most cases. More...
 
typedef vector_traits< OUT, vsize >::ele_v out_ele_v
 
typedef vector_traits< IN, vsize >::nd_ele_v in_nd_ele_v
 
typedef vector_traits< OUT, vsize >::nd_ele_v out_nd_ele_v
 
typedef vector_traits< IN, vsize >::type in_v
 vectorized in_type and out_type. vspline::vector_traits supplies these types so that multidimensional/multichannel data come as vigra::TinyVectors, while 'singular' data won't be made into TinyVectors of one element. More...
 
typedef vector_traits< OUT, vsize >::type out_v
 
typedef vector_traits< int, vsize >::ele_v ic_v
 vsize wide vector of ints, used for gather/scatter indexes More...
 

Static Public Attributes

static const bool has_capped_eval = false
 

Detailed Description

template<typename IN, typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
struct vspline::unary_functor< IN, OUT, _vsize >

class unary_functor provides a functor object which offers a system of types for concrete unary functors derived from it. If vectorization isn't used, this is trivial, but with vectorization in use, we get vectorized types derived from plain IN and OUT via query of vspline::vector_traits.

class unary_functor itself does not provide operator(), this is left to the concrete functors inheriting from unary_functor. It is expected that the derived classes provide evaluation capability, either as a method template or as (overloaded) method(s) 'eval'. eval is to be coded as taking it's first argument as a const&, and writing it's result to it's second argument, which it receives by reference. eval's return type is void. Inside vspline, classes derived from unary_functor do provide operator(), so instances of these objects can be called with function call syntax as well.

Why not lay down an interface with a pure virtual function eval() which derived classes would need to override? Suppose you had, in unary_functor,

virtual void eval ( const in_type & in , out_type & out ) = 0 ;

Then, in a derived class, you'd have to provide an override with this signature. Initially, this seems reasonable enough, but if you want to implement eval() as a member function template in the derived class, you still would have to provide the override (calling an instantiated version of your template), because your template won't be recognized as a viable way to override the pure virtual base class member function. Since providing eval as a template is common (oftentimes vectorized and unvectorized code are the same) I've decided against having virtual eval routines, to avoid the need for explicitly overriding them in derived classes which provide eval() as a template.

How about providing operator() in unary_functor? We might add the derived class to the template argument list and use unary_functor with CRP. I've decideded against this and instead provide callability as a mixin to be used as needed. This keeps the complexity of unary_functor-derived objects low, adding the extra capability only where it's deemed appropriate. For the mixin, see class 'callable' further down.

With no virtual member functions, class unary_functor becomes very simple, which is desirable from a design standpoint, and also makes unary_functors smaller, avoiding the creation of the virtual function table.

The type system used in unary_functor is taken from vspline::vector_traits, additionally prefixing the types with in_ and out_, for input and output types. The other elements of the type names are the same as in vector_traits.

Definition at line 188 of file unary_functor.h.

Member Typedef Documentation

◆ ic_v

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vector_traits<int,vsize>::ele_v vspline::unary_functor< IN, OUT, _vsize >::ic_v

vsize wide vector of ints, used for gather/scatter indexes

Definition at line 259 of file unary_functor.h.

◆ in_ele_type

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vspline::vector_traits<IN>::ele_type vspline::unary_functor< IN, OUT, _vsize >::in_ele_type

Definition at line 214 of file unary_functor.h.

◆ in_ele_v

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vector_traits<IN,vsize>::ele_v vspline::unary_functor< IN, OUT, _vsize >::in_ele_v

a simdized type of the elementary type of result_type, which is used for coefficients and results. this is fixed via the traits class vector_traits (in vector.h). Note how we derive this type using vsize from the template argument, not what vspline::vector_traits deems appropriate for ele_type - though both numbers will be the same in most cases.

Definition at line 240 of file unary_functor.h.

◆ in_nd_ele_type

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vigra::TinyVector< in_ele_type , dim_in > vspline::unary_functor< IN, OUT, _vsize >::in_nd_ele_type

Definition at line 224 of file unary_functor.h.

◆ in_nd_ele_v

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vector_traits<IN,vsize>::nd_ele_v vspline::unary_functor< IN, OUT, _vsize >::in_nd_ele_v

Definition at line 247 of file unary_functor.h.

◆ in_type

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef IN vspline::unary_functor< IN, OUT, _vsize >::in_type

Definition at line 208 of file unary_functor.h.

◆ in_v

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vector_traits<IN,vsize>::type vspline::unary_functor< IN, OUT, _vsize >::in_v

vectorized in_type and out_type. vspline::vector_traits supplies these types so that multidimensional/multichannel data come as vigra::TinyVectors, while 'singular' data won't be made into TinyVectors of one element.

Definition at line 254 of file unary_functor.h.

◆ out_ele_type

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vspline::vector_traits<OUT>::ele_type vspline::unary_functor< IN, OUT, _vsize >::out_ele_type

Definition at line 215 of file unary_functor.h.

◆ out_ele_v

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vector_traits<OUT,vsize>::ele_v vspline::unary_functor< IN, OUT, _vsize >::out_ele_v

Definition at line 241 of file unary_functor.h.

◆ out_nd_ele_type

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vigra::TinyVector< out_ele_type , dim_out > vspline::unary_functor< IN, OUT, _vsize >::out_nd_ele_type

Definition at line 225 of file unary_functor.h.

◆ out_nd_ele_v

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vector_traits<OUT,vsize>::nd_ele_v vspline::unary_functor< IN, OUT, _vsize >::out_nd_ele_v

Definition at line 248 of file unary_functor.h.

◆ out_type

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef OUT vspline::unary_functor< IN, OUT, _vsize >::out_type

Definition at line 209 of file unary_functor.h.

◆ out_v

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
typedef vector_traits<OUT,vsize>::type vspline::unary_functor< IN, OUT, _vsize >::out_v

Definition at line 255 of file unary_functor.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
anonymous enum
Enumerator
vsize 

Definition at line 196 of file unary_functor.h.

◆ anonymous enum

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
anonymous enum
Enumerator
dim_in 

Definition at line 200 of file unary_functor.h.

◆ anonymous enum

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
anonymous enum
Enumerator
dim_out 

Definition at line 201 of file unary_functor.h.

Member Data Documentation

◆ has_capped_eval

template<typename IN , typename OUT = IN, size_t _vsize = vspline::vector_traits < IN > :: size>
const bool vspline::unary_functor< IN, OUT, _vsize >::has_capped_eval = false
static

Definition at line 191 of file unary_functor.h.


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