blitz  Version 0.9
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
indexexpr.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  * blitz/indexexpr.h Declaration of the IndexPlaceholder<N> class
4  *
5  * $Id: indexexpr.h,v 1.7 2005/05/07 04:17:56 julianc Exp $
6  *
7  * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * Suggestions: blitz-dev@oonumerics.org
20  * Bugs: blitz-bugs@oonumerics.org
21  *
22  * For more information, please see the Blitz++ Home Page:
23  * p://seurat.uhttwaterloo.ca/blitz/
24  *
25  ***************************************************************************/
26 
27 #ifndef BZ_INDEXEXPR_H
28 #define BZ_INDEXEXPR_H
29 
30 #include <blitz/tinyvec.h>
31 #include <blitz/prettyprint.h>
32 #include <blitz/etbase.h>
33 
34 BZ_NAMESPACE(blitz)
35 
36 template<int N>
38 #ifdef BZ_NEW_EXPRESSION_TEMPLATES
39  : public ETBase<IndexPlaceholder<N> >
40 #endif
41 {
42 public:
44  { }
45 
46 #ifdef BZ_NEW_EXPRESSION_TEMPLATES
48  : ETBase< IndexPlaceholder<N> >(x)
49  { }
50 #else
52  { }
53 #endif
54 
56  { }
57 
58  void operator=(const IndexPlaceholder<N>&)
59  { }
60 
61  typedef int T_numtype;
62  typedef int T_ctorArg1; // Dummy; not used
63  typedef int T_ctorArg2; // Ditto
64 
65  static const int
66  numArrayOperands = 0,
67  numIndexPlaceholders = 1,
68  rank = N+1;
69 
70  // If you have a precondition failure on this routine, it means
71  // you are trying to use stack iteration mode on an expression
72  // which contains an index placeholder. You must use index
73  // iteration mode instead.
74  int operator*() {
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) { return i[N]; }
82 #else
83  template<int N_rank>
84  T_numtype operator()(const TinyVector<int, N_rank>& i) { return i[N]; }
85 #endif
86 
87  int ascending(int) const { return INT_MIN; }
88  int ordering(int) const { return INT_MIN; }
89  int lbound(int) const { return INT_MIN; } // tiny(int());
90  int ubound(int) const { return INT_MAX; } // huge(int());
91 
92  // See operator*() note
93 
94  void push(int) { BZPRECONDITION(0); }
95  void pop(int) { BZPRECONDITION(0); }
96  void advance() { BZPRECONDITION(0); }
97  void advance(int) { BZPRECONDITION(0); }
98  void loadStride(int) { BZPRECONDITION(0); }
99 
100  bool isUnitStride(int) const {
101  BZPRECONDITION(0);
102  return false;
103  }
104 
105  void advanceUnitStride() { BZPRECONDITION(0); }
106 
107  bool canCollapse(int,int) const {
108  BZPRECONDITION(0);
109  return false;
110  }
111 
112  T_numtype operator[](int) {
113  BZPRECONDITION(0);
114  return T_numtype();
115  }
116 
117  T_numtype fastRead(int) {
118  BZPRECONDITION(0);
119  return T_numtype();
120  }
121 
122  int suggestStride(int) const {
123  BZPRECONDITION(0);
124  return 0;
125  }
126 
127  bool isStride(int,int) const {
128  BZPRECONDITION(0);
129  return true;
130  }
131 
132  void prettyPrint(BZ_STD_SCOPE(string) &str, prettyPrintFormat&) const {
133  // NEEDS_WORK-- do real formatting for reductions
134  str += "index-expr[NEEDS_WORK]";
135  }
136 
137  template<typename T_shape>
138  bool shapeCheck(const T_shape&) const { return true; }
139 };
140 
152 
153 #ifndef BZ_NO_TENSOR_INDEX_OBJECTS
154 
155 BZ_NAMESPACE(tensor)
168 BZ_NAMESPACE_END // tensor
169 
170 #endif
171 
173 
174 #endif // BZ_INDEXEXPR_H
175