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