ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions
Vectorize.hpp File Reference

(Last Changed on June 07, 2016 for git-revision 4016d21a7338c3ebab529a77a936e243ddc56be0.)

Macros to do vectorization. More...

#include <df1b2fun.h>

Go to the source code of this file.

Classes

struct  getScalarType< VT >
 
struct  getScalarType< df1b2vector >
 
struct  getScalarType< dvar_vector >
 
struct  getScalarType< dvector >
 

Macros

#define commaI   ,
 
#define commaN
 
#define commaT   ,
 
#define commaV   ,
 
#define declareI(arg)   int arg
 
#define declareN(arg)
 
#define declareT(arg)   typename getScalarType<VectorType>::scalar arg
 
#define declareV(arg)   const VectorType &arg
 
#define elementI(arg, i)   arg
 
#define elementN(arg, i)
 
#define elementT(arg, i)   arg
 
#define elementV(arg, i)   (typename getScalarType<VectorType>::scalar) arg[arg.indexmin()+i]
 
#define GVECTORIZE(FUN, Type1, Type2, Type3, Type4, Type5, Type6)
 General vectorize macro up to 6 arguments. More...
 
#define outputsizeI(n, arg)
 
#define outputsizeN(n, arg)
 
#define outputsizeT(n, arg)
 
#define outputsizeV(n, arg)   n = ((arg.indexmax()-arg.indexmin()+1)>n ? (arg.indexmax()-arg.indexmin()+1) : n)
 
#define VECTORIZE1_t(FUN)   GVECTORIZE(FUN,V,N,N,N,N,N)
 Vectorize 1-argument functions. More...
 
#define VECTORIZE2_tt(FUN)
 Vectorize 2-argument functions. More...
 
#define VECTORIZE3_tti(FUN)
 Vectorize 3-argument functions. More...
 
#define VECTORIZE3_ttt(FUN)
 Vectorize 3-argument functions. More...
 
#define VECTORIZE4_ttti(FUN)
 Vectorize 4-argument functions. More...
 
#define VECTORIZE6_ttttti(FUN)
 Vectorize 6-argument functions. More...
 

Functions

 VECTORIZE3_ttt (pbeta)
 
 VECTORIZE3_ttt (qbeta)
 

Detailed Description

Macros to do vectorization.

Definition in file Vectorize.hpp.

Macro Definition Documentation

#define commaI   ,

Definition at line 49 of file Vectorize.hpp.

#define commaN

Definition at line 50 of file Vectorize.hpp.

#define commaT   ,

Definition at line 48 of file Vectorize.hpp.

#define commaV   ,

Definition at line 47 of file Vectorize.hpp.

#define declareI (   arg)    int arg

Definition at line 39 of file Vectorize.hpp.

#define declareN (   arg)

Definition at line 40 of file Vectorize.hpp.

#define declareT (   arg)    typename getScalarType<VectorType>::scalar arg

Definition at line 38 of file Vectorize.hpp.

#define declareV (   arg)    const VectorType &arg

Definition at line 37 of file Vectorize.hpp.

#define elementI (   arg,
 
)    arg

Definition at line 44 of file Vectorize.hpp.

#define elementN (   arg,
 
)

Definition at line 45 of file Vectorize.hpp.

#define elementT (   arg,
 
)    arg

Definition at line 43 of file Vectorize.hpp.

#define elementV (   arg,
 
)    (typename getScalarType<VectorType>::scalar) arg[arg.indexmin()+i]

Definition at line 42 of file Vectorize.hpp.

#define GVECTORIZE (   FUN,
  Type1,
  Type2,
  Type3,
  Type4,
  Type5,
  Type6 
)
Value:
template<class VectorType> \
VectorType FUN( declare##Type1(arg1) comma##Type2 \
declare##Type2(arg2) comma##Type3 \
declare##Type3(arg3) comma##Type4 \
declare##Type4(arg4) comma##Type5 \
declare##Type5(arg5) comma##Type6 \
declare##Type6(arg6) ) \
{ \
int n = 0; \
outputsize##Type1(n,arg1); \
outputsize##Type2(n,arg2); \
outputsize##Type3(n,arg3); \
outputsize##Type4(n,arg4); \
outputsize##Type5(n,arg5); \
outputsize##Type6(n,arg6); \
VectorType res(1,n); \
for(int i=0;i<n;i++) res[i+1] = FUN( element##Type1(arg1,i) comma##Type2 \
element##Type2(arg2,i) comma##Type3 \
element##Type3(arg3,i) comma##Type4 \
element##Type4(arg4,i) comma##Type5 \
element##Type5(arg5,i) comma##Type6 \
element##Type6(arg6,i) ); \
return res; \
}

General vectorize macro up to 6 arguments.

Applied type abbreviations: V=vector, T=scalar, I=integer, N=none. The longest vector input determines the length of the output. Arguments are not re-cycled; unequal vector lengths should result in a crash.

Definition at line 63 of file Vectorize.hpp.

#define outputsizeI (   n,
  arg 
)

Definition at line 54 of file Vectorize.hpp.

#define outputsizeN (   n,
  arg 
)

Definition at line 55 of file Vectorize.hpp.

#define outputsizeT (   n,
  arg 
)

Definition at line 53 of file Vectorize.hpp.

#define outputsizeV (   n,
  arg 
)    n = ((arg.indexmax()-arg.indexmin()+1)>n ? (arg.indexmax()-arg.indexmin()+1) : n)

Definition at line 52 of file Vectorize.hpp.

#define VECTORIZE1_t (   FUN)    GVECTORIZE(FUN,V,N,N,N,N,N)

Vectorize 1-argument functions.

Definition at line 90 of file Vectorize.hpp.

#define VECTORIZE2_tt (   FUN)
Value:
GVECTORIZE(FUN,V,T,N,N,N,N) \
GVECTORIZE(FUN,T,V,N,N,N,N) \
GVECTORIZE(FUN,V,V,N,N,N,N)
#define N
Definition: rngen.cpp:56
#define GVECTORIZE(FUN, Type1, Type2, Type3, Type4, Type5, Type6)
General vectorize macro up to 6 arguments.
Definition: Vectorize.hpp:63

Vectorize 2-argument functions.

For two-arguments functions (Type, Type), vectorize both arguments.

Definition at line 98 of file Vectorize.hpp.

#define VECTORIZE3_tti (   FUN)
Value:
GVECTORIZE(FUN,V,T,I,N,N,N) \
GVECTORIZE(FUN,T,V,I,N,N,N) \
GVECTORIZE(FUN,V,V,I,N,N,N)
#define N
Definition: rngen.cpp:56
#define GVECTORIZE(FUN, Type1, Type2, Type3, Type4, Type5, Type6)
General vectorize macro up to 6 arguments.
Definition: Vectorize.hpp:63

Vectorize 3-argument functions.

For three-arguments functions (Type, Type, int), vectorize first two arguments.

Definition at line 108 of file Vectorize.hpp.

#define VECTORIZE3_ttt (   FUN)
Value:
GVECTORIZE(FUN,V,T,T,N,N,N) \
GVECTORIZE(FUN,T,V,T,N,N,N) \
GVECTORIZE(FUN,T,T,V,N,N,N) \
GVECTORIZE(FUN,V,V,T,N,N,N) \
GVECTORIZE(FUN,T,V,V,N,N,N) \
GVECTORIZE(FUN,V,T,V,N,N,N) \
GVECTORIZE(FUN,V,V,V,N,N,N)
#define N
Definition: rngen.cpp:56
#define GVECTORIZE(FUN, Type1, Type2, Type3, Type4, Type5, Type6)
General vectorize macro up to 6 arguments.
Definition: Vectorize.hpp:63

Vectorize 3-argument functions.

For three-arguments functions (Type, Type, Type), vectorize all three arguments.

Definition at line 118 of file Vectorize.hpp.

#define VECTORIZE4_ttti (   FUN)
Value:
GVECTORIZE(FUN,V,T,T,I,N,N) \
GVECTORIZE(FUN,T,V,T,I,N,N) \
GVECTORIZE(FUN,T,T,V,I,N,N) \
GVECTORIZE(FUN,V,V,T,I,N,N) \
GVECTORIZE(FUN,T,V,V,I,N,N) \
GVECTORIZE(FUN,V,T,V,I,N,N) \
GVECTORIZE(FUN,V,V,V,I,N,N)
#define N
Definition: rngen.cpp:56
#define GVECTORIZE(FUN, Type1, Type2, Type3, Type4, Type5, Type6)
General vectorize macro up to 6 arguments.
Definition: Vectorize.hpp:63

Vectorize 4-argument functions.

For Four-arguments functions (Type, Type, Type, int), vectorize first three arguments.

Definition at line 132 of file Vectorize.hpp.

#define VECTORIZE6_ttttti (   FUN)
Value:
GVECTORIZE(FUN,V,T,T,T,T,I) \
GVECTORIZE(FUN,T,V,T,T,T,I) \
GVECTORIZE(FUN,T,T,V,T,T,I) \
GVECTORIZE(FUN,V,V,T,T,T,I) \
GVECTORIZE(FUN,T,V,V,T,T,I) \
GVECTORIZE(FUN,V,T,V,T,T,I) \
GVECTORIZE(FUN,V,V,V,T,T,I)
#define GVECTORIZE(FUN, Type1, Type2, Type3, Type4, Type5, Type6)
General vectorize macro up to 6 arguments.
Definition: Vectorize.hpp:63

Vectorize 6-argument functions.

For Six-arguments functions (Type, Type, Type, Type, Type, int), vectorize first three arguments.

Definition at line 146 of file Vectorize.hpp.

Function Documentation

VECTORIZE3_ttt ( pbeta  )
VECTORIZE3_ttt ( qbeta  )