21 #ifndef _METAPROGRAMS_H_ 22 #define _METAPROGRAMS_H_ 38 template<
int N,
typename T,
typename RT,
typename PlusT,
typename TimesT>
47 TimesT()(v1[N-1],v2[N-1]) );
57 template<
typename PlusT,
typename T,
typename RT,
typename TimesT>
62 return TimesT()( v1[0], v2[0] );
66 return TimesT()( v[0], x );
72 template<
int N,
typename T,
typename CompareT>
76 std::logical_and<bool>,
77 CompareT >()( v1, v2 );
80 template<
int N,
typename T,
typename CompareT>
84 std::logical_and<bool>,
90 template<
int N,
typename T,
typename ReduceT,
typename TransformT=Identity<T> >
99 T
operator()( T
const * v, TransformT
const& xform )
const 101 return ReduceT()( xform(v,
N-1),
Accum<
N-1,T,ReduceT,TransformT>()(v,xform) );
105 template<
typename T,
typename ReduceT,
typename TransformT >
106 struct Accum<1,T,ReduceT,TransformT>
110 return TransformT()(v[0]);
122 template<
int N,
typename T>
struct LexLT 126 return doit( v1+
N, v2+
N );
129 static bool doit(
const T* v1,
const T* v2 )
131 if ( v1[-
N] < v2[-
N] )
return true;
132 else if ( v1[-
N] > v2[-
N] )
return false;
137 template<
typename T>
struct LexLT<1,T>
141 return doit( v1+1, v2+1 );
143 static bool doit(
const T* v1,
const T* v2 )
145 if ( v1[-1] < v2[-1] )
return true;
152 template<
int N,
typename T,
typename FunctorT>
struct Transform 156 v[
N-1] = FunctorT()(v[
N-1]);
161 v[
N-1] = FunctorT()(v[
N-1],x);
166 v1[
N-1] = FunctorT()(v1[
N-1],v2[
N-1]);
171 template<
typename T,
typename FunctorT>
struct Transform<1,T,FunctorT>
175 v[0] = FunctorT()(v[0]);
179 v[0] = FunctorT()(v[0],x);
183 v1[0] = FunctorT()(v1[0],v2[0]);
189 template<
int N,
int P>
struct Pow 191 static const int value =
N *
Pow<
N,P-1>::value;
194 template<
int N>
struct Pow<
N,1>
196 static const int value =
N;
205 for ( index[
N-1]=lo; index[
N-1]<hi; ++index[
N-1] )
210 void operator()(
int * index,
const int * lo,
const int * hi, OP& op )
const 212 for ( index[
N-1]=lo[
N-1]; index[
N-1]<hi[
N-1]; ++index[
N-1] )
225 void operator()(
int * index,
const int * lo,
const int * hi, OP& op )
const 237 for ( index[
N-1]=lo; index[
N-1]<hi; ++index[
N-1] )
243 void operator()(
int * index,
const int * lo,
const int * hi, OP& op )
const 245 for ( index[
N-1]=lo[
N-1]; index[
N-1]<hi[
N-1]; ++index[
N-1] )
259 void operator()(
int * index,
const int * lo,
const int * hi, OP& op )
const 270 template<
int N,
class OP>
struct dterm 279 template<
class OP>
struct dterm<1,OP>
290 #endif // include guard
void const char const int const int * N
Definition: Lapack.H:83