1 | /***************************************************************************
|
---|
2 | * blitz/indexexpr.h Declaration of the IndexPlaceholder<N> class
|
---|
3 | *
|
---|
4 | * $Id: indexexpr.h,v 1.1.1.1 1999-11-26 16:37:03 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 | * p://seurat.uhttwaterloo.ca/blitz/
|
---|
23 | *
|
---|
24 | ***************************************************************************
|
---|
25 | * $Log: not supported by cvs2svn $
|
---|
26 | * Revision 1.1.1.1 1999/04/09 17:59:02 ansari
|
---|
27 | * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99
|
---|
28 | *
|
---|
29 | * Revision 1.2 1998/03/14 00:04:47 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_INDEXEXPR_H
|
---|
38 | #define BZ_INDEXEXPR_H
|
---|
39 |
|
---|
40 | #ifndef BZ_TINYVEC_H
|
---|
41 | #include <blitz/tinyvec.h>
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #ifndef BZ_PRETTYPRINT_H
|
---|
45 | #include <blitz/prettyprint.h>
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | BZ_NAMESPACE(blitz)
|
---|
49 |
|
---|
50 | template<int N>
|
---|
51 | class IndexPlaceholder {
|
---|
52 | public:
|
---|
53 | IndexPlaceholder()
|
---|
54 | { }
|
---|
55 |
|
---|
56 | IndexPlaceholder(const IndexPlaceholder<N>&)
|
---|
57 | { }
|
---|
58 |
|
---|
59 | ~IndexPlaceholder()
|
---|
60 | { }
|
---|
61 |
|
---|
62 | void operator=(const IndexPlaceholder<N>&)
|
---|
63 | { }
|
---|
64 |
|
---|
65 | typedef int T_numtype;
|
---|
66 | typedef int T_ctorArg1; // Dummy; not used
|
---|
67 | typedef int T_ctorArg2; // Ditto
|
---|
68 |
|
---|
69 | enum { numArrayOperands = 0, numIndexPlaceholders = 1,
|
---|
70 | rank = N+1 };
|
---|
71 |
|
---|
72 | // If you have a precondition failure on this routine, it means
|
---|
73 | // you are trying to use stack iteration mode on an expression
|
---|
74 | // which contains an index placeholder. You must use index
|
---|
75 | // iteration mode instead.
|
---|
76 | int operator*()
|
---|
77 | {
|
---|
78 | BZPRECONDITION(0);
|
---|
79 | return 0;
|
---|
80 | }
|
---|
81 |
|
---|
82 | #ifdef BZ_ARRAY_EXPR_PASS_INDEX_BY_VALUE
|
---|
83 | template<int N_rank>
|
---|
84 | T_numtype operator()(TinyVector<int, N_rank> i)
|
---|
85 | { return i[N]; }
|
---|
86 | #else
|
---|
87 | template<int N_rank>
|
---|
88 | T_numtype operator()(const TinyVector<int, N_rank>& i)
|
---|
89 | { return i[N]; }
|
---|
90 | #endif
|
---|
91 |
|
---|
92 | int lbound(int) const
|
---|
93 | { return INT_MIN; } // tiny(int());
|
---|
94 |
|
---|
95 | int ubound(int) const
|
---|
96 | { return INT_MAX; } // huge(int());
|
---|
97 |
|
---|
98 | // See operator*() note
|
---|
99 | void push(int)
|
---|
100 | {
|
---|
101 | BZPRECONDITION(0);
|
---|
102 | }
|
---|
103 |
|
---|
104 | // See operator*() note
|
---|
105 | void pop(int)
|
---|
106 | {
|
---|
107 | BZPRECONDITION(0);
|
---|
108 | }
|
---|
109 |
|
---|
110 | // See operator*() note
|
---|
111 | void advance()
|
---|
112 | {
|
---|
113 | BZPRECONDITION(0);
|
---|
114 | }
|
---|
115 |
|
---|
116 | // See operator*() note
|
---|
117 | void advance(int)
|
---|
118 | {
|
---|
119 | BZPRECONDITION(0);
|
---|
120 | }
|
---|
121 |
|
---|
122 | // See operator*() note
|
---|
123 | void loadStride(int)
|
---|
124 | {
|
---|
125 | BZPRECONDITION(0);
|
---|
126 | }
|
---|
127 |
|
---|
128 | _bz_bool isUnitStride(int rank) const
|
---|
129 | {
|
---|
130 | BZPRECONDITION(0);
|
---|
131 | return false;
|
---|
132 | }
|
---|
133 |
|
---|
134 | void advanceUnitStride()
|
---|
135 | {
|
---|
136 | BZPRECONDITION(0);
|
---|
137 | }
|
---|
138 |
|
---|
139 | _bz_bool canCollapse(int,int) const
|
---|
140 | {
|
---|
141 | BZPRECONDITION(0);
|
---|
142 | return _bz_false;
|
---|
143 | }
|
---|
144 |
|
---|
145 | T_numtype operator[](int)
|
---|
146 | {
|
---|
147 | BZPRECONDITION(0);
|
---|
148 | return T_numtype();
|
---|
149 | }
|
---|
150 |
|
---|
151 | T_numtype fastRead(int)
|
---|
152 | {
|
---|
153 | BZPRECONDITION(0);
|
---|
154 | return T_numtype();
|
---|
155 | }
|
---|
156 |
|
---|
157 | int suggestStride(int) const
|
---|
158 | {
|
---|
159 | BZPRECONDITION(0);
|
---|
160 | return 0;
|
---|
161 | }
|
---|
162 |
|
---|
163 | _bz_bool isStride(int,int) const
|
---|
164 | {
|
---|
165 | BZPRECONDITION(0);
|
---|
166 | return _bz_true;
|
---|
167 | }
|
---|
168 |
|
---|
169 | void prettyPrint(string& str, prettyPrintFormat& format) const
|
---|
170 | {
|
---|
171 | // NEEDS_WORK-- do real formatting for reductions
|
---|
172 | str += "index-expr[NEEDS_WORK]";
|
---|
173 | }
|
---|
174 |
|
---|
175 | template<class T_shape>
|
---|
176 | _bz_bool shapeCheck(const T_shape& shape) const
|
---|
177 | {
|
---|
178 | return _bz_true;
|
---|
179 | }
|
---|
180 | };
|
---|
181 |
|
---|
182 | typedef IndexPlaceholder<0> firstIndex;
|
---|
183 | typedef IndexPlaceholder<1> secondIndex;
|
---|
184 | typedef IndexPlaceholder<2> thirdIndex;
|
---|
185 | typedef IndexPlaceholder<3> fourthIndex;
|
---|
186 | typedef IndexPlaceholder<4> fifthIndex;
|
---|
187 | typedef IndexPlaceholder<5> sixthIndex;
|
---|
188 | typedef IndexPlaceholder<6> seventhIndex;
|
---|
189 | typedef IndexPlaceholder<7> eighthIndex;
|
---|
190 | typedef IndexPlaceholder<8> ninthIndex;
|
---|
191 | typedef IndexPlaceholder<9> tenthIndex;
|
---|
192 | typedef IndexPlaceholder<10> eleventhIndex;
|
---|
193 |
|
---|
194 | #ifndef BZ_NO_TENSOR_INDEX_OBJECTS
|
---|
195 |
|
---|
196 | BZ_NAMESPACE(tensor)
|
---|
197 | _bz_global IndexPlaceholder<0> i;
|
---|
198 | _bz_global IndexPlaceholder<1> j;
|
---|
199 | _bz_global IndexPlaceholder<2> k;
|
---|
200 | _bz_global IndexPlaceholder<3> l;
|
---|
201 | _bz_global IndexPlaceholder<4> m;
|
---|
202 | _bz_global IndexPlaceholder<5> n;
|
---|
203 | _bz_global IndexPlaceholder<6> o;
|
---|
204 | _bz_global IndexPlaceholder<7> p;
|
---|
205 | _bz_global IndexPlaceholder<8> q;
|
---|
206 | _bz_global IndexPlaceholder<9> r;
|
---|
207 | _bz_global IndexPlaceholder<10> s;
|
---|
208 | _bz_global IndexPlaceholder<11> t;
|
---|
209 | BZ_NAMESPACE_END // tensor
|
---|
210 |
|
---|
211 | #endif
|
---|
212 |
|
---|
213 | BZ_NAMESPACE_END
|
---|
214 |
|
---|
215 | #endif // BZ_INDEXEXPR_H
|
---|
216 |
|
---|