source: XMLIO_V2/external/include/blitz/indexexpr.h @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
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
34BZ_NAMESPACE(blitz)
35
36template<int N>
37class IndexPlaceholder
38#ifdef BZ_NEW_EXPRESSION_TEMPLATES
39  : public ETBase<IndexPlaceholder<N> > 
40#endif
41{
42public:
43    IndexPlaceholder()
44    { }
45
46#ifdef BZ_NEW_EXPRESSION_TEMPLATES
47    IndexPlaceholder(const IndexPlaceholder<N>& x)
48        : ETBase< IndexPlaceholder<N> >(x)
49    { }
50#else
51    IndexPlaceholder(const IndexPlaceholder<N>&)
52    { }
53#endif
54
55    ~IndexPlaceholder()
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
141typedef IndexPlaceholder<0> firstIndex;
142typedef IndexPlaceholder<1> secondIndex;
143typedef IndexPlaceholder<2> thirdIndex;
144typedef IndexPlaceholder<3> fourthIndex;
145typedef IndexPlaceholder<4> fifthIndex;
146typedef IndexPlaceholder<5> sixthIndex;
147typedef IndexPlaceholder<6> seventhIndex;
148typedef IndexPlaceholder<7> eighthIndex;
149typedef IndexPlaceholder<8> ninthIndex;
150typedef IndexPlaceholder<9> tenthIndex;
151typedef IndexPlaceholder<10> eleventhIndex;
152
153#ifndef BZ_NO_TENSOR_INDEX_OBJECTS
154
155BZ_NAMESPACE(tensor)
156    _bz_global blitz::IndexPlaceholder<0> i;
157    _bz_global blitz::IndexPlaceholder<1> j;
158    _bz_global blitz::IndexPlaceholder<2> k;
159    _bz_global blitz::IndexPlaceholder<3> l;
160    _bz_global blitz::IndexPlaceholder<4> m;
161    _bz_global blitz::IndexPlaceholder<5> n;
162    _bz_global blitz::IndexPlaceholder<6> o;
163    _bz_global blitz::IndexPlaceholder<7> p;
164    _bz_global blitz::IndexPlaceholder<8> q;
165    _bz_global blitz::IndexPlaceholder<9> r;
166    _bz_global blitz::IndexPlaceholder<10> s;
167    _bz_global blitz::IndexPlaceholder<11> t;
168BZ_NAMESPACE_END // tensor
169
170#endif
171
172BZ_NAMESPACE_END
173
174#endif // BZ_INDEXEXPR_H
175
Note: See TracBrowser for help on using the repository browser.