source: XIOS/dev/dev_olga/src/extern/blitz/include/blitz/meta/vecassign.h @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 3.1 KB
Line 
1// -*- C++ -*-
2/***************************************************************************
3 * blitz/meta/vecassign.h   TinyVector assignment metaprogram
4 *
5 * $Id$
6 *
7 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
8 *
9 * This file is a part of Blitz.
10 *
11 * Blitz is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation, either version 3
14 * of the License, or (at your option) any later version.
15 *
16 * Blitz is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with Blitz.  If not, see <http://www.gnu.org/licenses/>.
23 *
24 * Suggestions:          blitz-devel@lists.sourceforge.net
25 * Bugs:                 blitz-support@lists.sourceforge.net   
26 *
27 * For more information, please see the Blitz++ Home Page:
28 *    https://sourceforge.net/projects/blitz/
29 *
30 ***************************************************************************/
31
32#ifndef BZ_META_VECASSIGN_H
33#define BZ_META_VECASSIGN_H
34
35#include <blitz/blitz.h>
36
37BZ_NAMESPACE(blitz)
38
39template<int N, int I> 
40class _bz_meta_vecAssign {
41public:
42    static const int loopFlag = (I < N-1) ? 1 : 0;
43
44    template<typename T_data, typename T_expr, typename T_updater>
45    static inline void fastAssign(T_data* data, T_expr expr, T_updater u)
46    {
47      u.update(data[I], expr.fastRead(I));
48        _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag>
49          ::fastAssign(data,expr,u);
50    }
51
52    template<typename T_vector, typename T_expr, typename T_updater>
53    static inline void assign(T_vector& vec, T_expr expr, T_updater u)
54    {
55        u.update(vec[I], expr[I]);
56        _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag>
57           ::assign(vec,expr,u);
58    }
59
60    template<typename T_vector, typename T_numtype, typename T_updater>
61    static inline void assignWithArgs(T_vector& vec, T_updater u,
62        T_numtype x0, T_numtype x1=0, T_numtype x2=0, T_numtype x3=0,
63        T_numtype x4=0, T_numtype x5=0, T_numtype x6=0, T_numtype x7=0,
64        T_numtype x8=0, T_numtype x9=0)
65    {
66        u.update(vec[I], x0);
67        _bz_meta_vecAssign<N * loopFlag, (I+1) * loopFlag>
68            ::assignWithArgs(vec, u, x1, x2, x3, x4, x5, x6, x7, x8, x9);
69    }
70       
71};
72
73template<>
74class _bz_meta_vecAssign<0,0> {
75public:
76    template<typename T_vector, typename T_expr, typename T_updater>
77    static inline void fastAssign(T_vector&, T_expr, T_updater)
78    { }
79
80    template<typename T_vector, typename T_expr, typename T_updater>
81    static inline void assign(T_vector&, T_expr, T_updater)
82    { }
83
84    template<typename T_vector, typename T_numtype, typename T_updater>
85    static inline void assignWithArgs(T_vector&, T_updater,
86        T_numtype, T_numtype =0, T_numtype =0, T_numtype =0,
87        T_numtype =0, T_numtype =0, T_numtype =0, T_numtype =0,
88        T_numtype =0, T_numtype =0)
89    {
90    }
91};
92
93
94
95BZ_NAMESPACE_END
96
97#endif // BZ_META_ASSIGN_H
Note: See TracBrowser for help on using the repository browser.