| [658] | 1 | /*************************************************************************** | 
|---|
|  | 2 | * blitz/meta/vecassign.h   TinyVector assignment metaprogram | 
|---|
|  | 3 | * | 
|---|
|  | 4 | * $Id: vecassign.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_VECASSIGN_H | 
|---|
|  | 38 | #define BZ_META_VECASSIGN_H | 
|---|
|  | 39 |  | 
|---|
|  | 40 | BZ_NAMESPACE(blitz) | 
|---|
|  | 41 |  | 
|---|
|  | 42 | template<int N, int I> | 
|---|
|  | 43 | class _bz_meta_vecAssign { | 
|---|
|  | 44 | public: | 
|---|
|  | 45 | enum { loopFlag = (I < N-1) ? 1 : 0 }; | 
|---|
|  | 46 |  | 
|---|
|  | 47 | template<class T_vector, class T_expr, class T_updater> | 
|---|
|  | 48 | static inline void fastAssign(T_vector& vec, T_expr expr, T_updater u) | 
|---|
|  | 49 | { | 
|---|
|  | 50 | u.update(vec[I], expr._bz_fastAccess(I)); | 
|---|
|  | 51 | _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag> | 
|---|
|  | 52 | ::fastAssign(vec,expr,u); | 
|---|
|  | 53 | } | 
|---|
|  | 54 |  | 
|---|
|  | 55 | template<class T_vector, class T_expr, class T_updater> | 
|---|
|  | 56 | static inline void assign(T_vector& vec, T_expr expr, T_updater u) | 
|---|
|  | 57 | { | 
|---|
|  | 58 | u.update(vec[I], expr[I]); | 
|---|
|  | 59 | _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag> | 
|---|
|  | 60 | ::assign(vec,expr,u); | 
|---|
|  | 61 | } | 
|---|
|  | 62 |  | 
|---|
|  | 63 | template<class T_vector, class T_numtype, class T_updater> | 
|---|
|  | 64 | static inline void assignWithArgs(T_vector& vec, T_updater u, | 
|---|
|  | 65 | T_numtype x0, T_numtype x1=0, T_numtype x2=0, T_numtype x3=0, | 
|---|
|  | 66 | T_numtype x4=0, T_numtype x5=0, T_numtype x6=0, T_numtype x7=0, | 
|---|
|  | 67 | T_numtype x8=0, T_numtype x9=0) | 
|---|
|  | 68 | { | 
|---|
|  | 69 | u.update(vec[I], x0); | 
|---|
|  | 70 | _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag> | 
|---|
|  | 71 | ::assignWithArgs(vec, u, x1, x2, x3, x4, x5, x6, x7, x8, x9); | 
|---|
|  | 72 | } | 
|---|
|  | 73 |  | 
|---|
|  | 74 | }; | 
|---|
|  | 75 |  | 
|---|
|  | 76 | template<> | 
|---|
|  | 77 | class _bz_meta_vecAssign<0,0> { | 
|---|
|  | 78 | public: | 
|---|
|  | 79 | template<class T_vector, class T_expr, class T_updater> | 
|---|
|  | 80 | static inline void fastAssign(T_vector& vec, T_expr expr, T_updater u) | 
|---|
|  | 81 | { } | 
|---|
|  | 82 |  | 
|---|
|  | 83 | template<class T_vector, class T_expr, class T_updater> | 
|---|
|  | 84 | static inline void assign(T_vector& vec, T_expr expr, T_updater u) | 
|---|
|  | 85 | { } | 
|---|
|  | 86 |  | 
|---|
|  | 87 | template<class T_vector, class T_numtype, class T_updater> | 
|---|
|  | 88 | static inline void assignWithArgs(T_vector& vec, T_updater u, | 
|---|
|  | 89 | T_numtype x0, T_numtype x1=0, T_numtype x2=0, T_numtype x3=0, | 
|---|
|  | 90 | T_numtype x4=0, T_numtype x5=0, T_numtype x6=0, T_numtype x7=0, | 
|---|
|  | 91 | T_numtype x8=0, T_numtype x9=0) | 
|---|
|  | 92 | { | 
|---|
|  | 93 | } | 
|---|
|  | 94 | }; | 
|---|
|  | 95 |  | 
|---|
|  | 96 | BZ_NAMESPACE_END | 
|---|
|  | 97 |  | 
|---|
|  | 98 | #endif // BZ_META_ASSIGN_H | 
|---|