~ubuntu-branches/ubuntu/raring/blitz++/raring

« back to all changes in this revision

Viewing changes to blitz/array/stencil-et.h

  • Committer: Bazaar Package Importer
  • Author(s): Konstantinos Margaritis
  • Date: 2005-02-28 20:25:01 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050228202501-3i4f2sknnprsqfhz
Tags: 1:0.8-4
Added missing build-depends (Closes: #297323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- C++ -*-
 
2
/***************************************************************************
 
3
 * blitz/array/stencil-et.h  Expression-template-capabale stencils
 
4
 *
 
5
 * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU General Public License
 
9
 * as published by the Free Software Foundation; either version 2
 
10
 * of the License, or (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * Suggestions:          blitz-dev@oonumerics.org
 
18
 * Bugs:                 blitz-bugs@oonumerics.org
 
19
 *
 
20
 * For more information, please see the Blitz++ Home Page:
 
21
 *    http://oonumerics.org/blitz/
 
22
 *
 
23
 ****************************************************************************/
1
24
#ifndef BZ_ARRAY_STENCIL_ET_H
2
25
#define BZ_ARRAY_STENCIL_ET_H
3
26
 
51
74
    void loadStride(int rank)
52
75
    { iter_.loadStride(rank); }
53
76
 
54
 
    _bz_bool isUnitStride(int rank) const
 
77
    bool isUnitStride(int rank) const
55
78
    { return iter_.isUnitStride(rank); }
56
79
 
57
80
    void advanceUnitStride()
58
81
    { iter_.advanceUnitStride(); }
59
82
 
60
 
    _bz_bool canCollapse(int outerLoopRank, int innerLoopRank) const
 
83
    bool canCollapse(int outerLoopRank, int innerLoopRank) const
61
84
    {
62
85
        // BZ_DEBUG_MESSAGE("_bz_ArrayExpr<>::canCollapse()");
63
86
        return iter_.canCollapse(outerLoopRank, innerLoopRank);
70
93
    int suggestStride(int rank) const
71
94
    { return iter_.suggestStride(rank); }
72
95
 
73
 
    _bz_bool isStride(int rank, int stride) const
 
96
    bool isStride(int rank, int stride) const
74
97
    { return iter_.isStride(rank,stride); }
75
98
 
76
 
    void prettyPrint(string& str) const
 
99
    void prettyPrint(BZ_STD_SCOPE(string) &str) const
77
100
    {
78
101
        str += "(stencil)";    // lame, needs work
79
102
    }
80
103
 
81
 
    void prettyPrint(string& str, prettyPrintFormat& format) const
 
104
    void prettyPrint(BZ_STD_SCOPE(string) &str, prettyPrintFormat&) const
82
105
    {   str += "(stencil)"; }
83
106
 
84
 
    template<class T_shape>
85
 
    _bz_bool shapeCheck(const T_shape& shape)
 
107
    template<typename T_shape>
 
108
    bool shapeCheck(const T_shape& shape)
86
109
    { return iter_.shapeCheck(shape); }
87
110
 
88
111
    void moveTo(const TinyVector<int,N_rank>& i)
95
118
};
96
119
 
97
120
#define BZ_ET_STENCIL(name,result) \
98
 
template<class P_numtype, int N_rank> \
 
121
template<typename P_numtype, int N_rank> \
99
122
class name ## _et : public StencilExpr<P_numtype,N_rank,result>, \
100
123
  public ETBase<name ## _et<P_numtype,N_rank> > \
101
124
 { \
 
125
private: \
 
126
    typedef StencilExpr<P_numtype,N_rank,result> T_base; \
 
127
    using T_base::iter_; \
102
128
public: \
103
 
    name ## _et(const Array<T_numtype,N_rank>& A) \
104
 
        : StencilExpr<T_numtype,N_rank,result>(A) \
 
129
    name ## _et(const Array<P_numtype,N_rank>& A) \
 
130
        : StencilExpr<P_numtype,N_rank,result>(A) \
105
131
    { } \
106
132
    result operator*() \
107
133
    { return name(iter_); } \
109
135
    { iter_.moveTo(a); return name(iter_); } \
110
136
    result fastRead(int i) \
111
137
    { \
112
 
      const T_numtype* tmp = iter_.data(); \
 
138
      const P_numtype* tmp = iter_.data(); \
113
139
      iter_._bz_setData(tmp + i); \
114
 
      T_numtype r = name(iter_); \
 
140
      P_numtype r = name(iter_); \
115
141
      iter_._bz_setData(tmp); \
116
142
      return r; \
117
143
    } \
118
144
}; \
119
 
template<class T_numtype, int N_rank> \
120
 
inline _bz_ArrayExpr<name ## _et<T_numtype, N_rank> > \
121
 
name(Array<T_numtype,N_rank>& A) \
 
145
template<typename P_numtype, int N_rank> \
 
146
inline _bz_ArrayExpr<name ## _et<P_numtype, N_rank> > \
 
147
name(Array<P_numtype,N_rank>& A) \
122
148
{ \
123
 
    return _bz_ArrayExpr<name ## _et<T_numtype, N_rank> >(A); \
 
149
    return _bz_ArrayExpr<name ## _et<P_numtype, N_rank> >(A); \
124
150
}
125
151
 
126
152
#define BZ_ET_STENCILV(name,rank) \
127
 
template<class P_numtype, int N_rank> \
 
153
template<typename P_numtype, int N_rank> \
128
154
class name ## _et : public StencilExpr<P_numtype,N_rank, \
129
155
    TinyVector<P_numtype,rank> >, \
130
156
  public ETBase<name ## _et<P_numtype,N_rank> > \
131
157
 { \
 
158
private: \
 
159
    typedef StencilExpr<P_numtype,N_rank,TinyVector<P_numtype,rank> > T_base; \
 
160
    using T_base::iter_; \
132
161
public: \
133
 
    typedef TinyVector<T_numtype,rank> result; \
134
 
    name ## _et(const Array<T_numtype,N_rank>& A) \
135
 
        : StencilExpr<T_numtype,N_rank,result>(A) \
 
162
    typedef TinyVector<P_numtype,rank> result; \
 
163
    name ## _et(const Array<P_numtype,N_rank>& A) \
 
164
        : StencilExpr<P_numtype,N_rank,result>(A) \
136
165
    { } \
137
166
    result operator*() \
138
167
    { return name(iter_); } \
140
169
    { iter_.moveTo(a); return name(iter_); } \
141
170
    result fastRead(int i) \
142
171
    { \
143
 
      const T_numtype* tmp = iter_.data(); \
 
172
      const P_numtype* tmp = iter_.data(); \
144
173
      iter_._bz_setData(tmp + i); \
145
 
      T_numtype r = name(iter_); \
 
174
      P_numtype r = name(iter_); \
146
175
      iter_._bz_setData(tmp); \
147
176
      return r; \
148
177
    } \
149
178
}; \
150
 
template<class T_numtype, int N_rank> \
151
 
inline _bz_ArrayExpr<name ## _et<T_numtype, N_rank> > \
152
 
name(Array<T_numtype,N_rank>& A) \
 
179
template<typename P_numtype, int N_rank> \
 
180
inline _bz_ArrayExpr<name ## _et<P_numtype, N_rank> > \
 
181
name(Array<P_numtype,N_rank>& A) \
153
182
{ \
154
 
    return _bz_ArrayExpr< name ## _et<T_numtype, N_rank> >(A); \
 
183
    return _bz_ArrayExpr< name ## _et<P_numtype, N_rank> >(A); \
155
184
}
156
185
 
157
186
#define BZ_ET_STENCIL_DIFF(name) \
158
 
template<class P_numtype, int N_rank> \
 
187
template<typename P_numtype, int N_rank> \
159
188
class name ## _et : public StencilExpr<P_numtype,N_rank,P_numtype>, \
160
189
  public ETBase<name ## _et<P_numtype,N_rank> > \
161
190
 { \
 
191
private: \
 
192
    typedef StencilExpr<P_numtype,N_rank,P_numtype> T_base; \
 
193
    using T_base::iter_; \
162
194
public: \
163
 
    name ## _et(const Array<T_numtype,N_rank>& A, int dim) \
164
 
        : StencilExpr<T_numtype,N_rank,P_numtype>(A), dim_(dim) \
 
195
    name ## _et(const Array<P_numtype,N_rank>& A, int dim) \
 
196
        : StencilExpr<P_numtype,N_rank,P_numtype>(A), dim_(dim) \
165
197
    { } \
166
 
    T_numtype operator*() \
 
198
    P_numtype operator*() \
167
199
    { return name(iter_); } \
168
 
    T_numtype operator()(const TinyVector<int,N_rank>& a) \
 
200
    P_numtype operator()(const TinyVector<int,N_rank>& a) \
169
201
    { iter_.moveTo(a); return name(iter_,dim_); } \
170
 
    T_numtype fastRead(int i) \
 
202
    P_numtype fastRead(int i) \
171
203
    { \
172
 
      const T_numtype* tmp = iter_.data(); \
 
204
      const P_numtype* tmp = iter_.data(); \
173
205
      iter_._bz_setData(tmp + i); \
174
 
      T_numtype r = name(iter_,dim_); \
 
206
      P_numtype r = name(iter_,dim_); \
175
207
      iter_._bz_setData(tmp); \
176
208
      return r; \
177
209
    } \
178
210
private: \
179
211
    int dim_; \
180
212
}; \
181
 
template<class T_numtype, int N_rank> \
182
 
inline _bz_ArrayExpr<name ## _et<T_numtype, N_rank> > \
183
 
name(Array<T_numtype,N_rank>& A, int dim) \
 
213
template<typename P_numtype, int N_rank> \
 
214
inline _bz_ArrayExpr<name ## _et<P_numtype, N_rank> > \
 
215
name(Array<P_numtype,N_rank>& A, int dim) \
184
216
{ \
185
 
    return _bz_ArrayExpr<name ## _et<T_numtype, N_rank> >(A,dim); \
 
217
    return _bz_ArrayExpr<name ## _et<P_numtype, N_rank> >(A,dim); \
186
218
}
187
219
 
188
220