| [658] | 1 | /***************************************************************************
 | 
|---|
 | 2 |  * blitz/meta/sum.h      TinyVector sum metaprogram
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  * $Id: sum.h,v 1.1.1.1 1999-11-26 16:37:08 ansari Exp $
 | 
|---|
 | 5 |  *
 | 
|---|
 | 6 |  * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
 | 
|---|
 | 7 |  *
 | 
|---|
 | 8 |  * This program is free software; you can redistribute it and/or
 | 
|---|
 | 9 |  * modify it under the terms of the GNU General Public License
 | 
|---|
 | 10 |  * as published by the Free Software Foundation; either version 2
 | 
|---|
 | 11 |  * of the License, or (at your option) any later version.
 | 
|---|
 | 12 |  *
 | 
|---|
 | 13 |  * This program is distributed in the hope that it will be useful,
 | 
|---|
 | 14 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 15 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 16 |  * GNU General Public License for more details.
 | 
|---|
 | 17 |  *
 | 
|---|
 | 18 |  * Suggestions:          blitz-suggest@cybervision.com
 | 
|---|
 | 19 |  * Bugs:                 blitz-bugs@cybervision.com
 | 
|---|
 | 20 |  *
 | 
|---|
 | 21 |  * For more information, please see the Blitz++ Home Page:
 | 
|---|
 | 22 |  *    http://seurat.uwaterloo.ca/blitz/
 | 
|---|
 | 23 |  *
 | 
|---|
 | 24 |  ***************************************************************************
 | 
|---|
 | 25 |  * $Log: not supported by cvs2svn $
 | 
|---|
 | 26 |  * Revision 1.1.1.1  1999/04/09  17:59:03  ansari
 | 
|---|
 | 27 |  * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99
 | 
|---|
 | 28 |  *
 | 
|---|
 | 29 |  * Revision 1.2  1998/03/14 00:08:44  tveldhui
 | 
|---|
 | 30 |  * 0.2-alpha-05
 | 
|---|
 | 31 |  *
 | 
|---|
 | 32 |  * Revision 1.1  1997/07/16 14:51:20  tveldhui
 | 
|---|
 | 33 |  * Update: Alpha release 0.2 (Arrays)
 | 
|---|
 | 34 |  *
 | 
|---|
 | 35 |  */
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | #ifndef BZ_META_SUM_H
 | 
|---|
 | 38 | #define BZ_META_SUM_H
 | 
|---|
 | 39 | 
 | 
|---|
 | 40 | #ifndef BZ_METAPROG_H
 | 
|---|
 | 41 |  #include <blitz/meta/metaprog.h>
 | 
|---|
 | 42 | #endif
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | BZ_NAMESPACE(blitz)
 | 
|---|
 | 45 | 
 | 
|---|
 | 46 | template<int N, int I>
 | 
|---|
 | 47 | class _bz_meta_vectorSum {
 | 
|---|
 | 48 | public:
 | 
|---|
 | 49 |     enum { loopFlag = (I < N-1) ? 1 : 0 };
 | 
|---|
 | 50 | 
 | 
|---|
 | 51 |     template<class T_expr1>
 | 
|---|
 | 52 |     static inline _bz_typename T_expr1::T_numtype
 | 
|---|
 | 53 |     f(const T_expr1& a)
 | 
|---|
 | 54 |     {
 | 
|---|
 | 55 |         return a[I] +
 | 
|---|
 | 56 |             + _bz_meta_vectorSum<loopFlag * N, loopFlag * (I+1)>::f(a);
 | 
|---|
 | 57 |     }
 | 
|---|
 | 58 | };
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 | template<>
 | 
|---|
 | 61 | class _bz_meta_vectorSum<0,0> {
 | 
|---|
 | 62 | public:
 | 
|---|
 | 63 |     template<class T_expr1>
 | 
|---|
 | 64 |     static inline _bz_meta_nullOperand f(const T_expr1&)
 | 
|---|
 | 65 |     { return _bz_meta_nullOperand(); }
 | 
|---|
 | 66 | 
 | 
|---|
 | 67 | };
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 | BZ_NAMESPACE_END
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 | #endif // BZ_META_SUM_H
 | 
|---|