blitz  Version 0.9
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tinyveciter.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  * blitz/tinyveciter.h Declaration of TinyVectorIter<T,N,stride>
4  *
5  * $Id: tinyveciter.h,v 1.6 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  * http://oonumerics.org/blitz/
24  *
25  ***************************************************************************/
26 
27 
28 #ifndef BZ_TINYVECITER_H
29 #define BZ_TINYVECITER_H
30 
31 #ifndef BZ_TINYVEC_H
32  #include <blitz/tinyvec.h>
33 #endif
34 
35 #ifndef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
36  #error "Debug in tinyveciter.h (this line shouldn't be here)"
37 #endif
38 
39 BZ_NAMESPACE(blitz)
40 
41 // N_stride has default 1, in forward declaration in <blitz/tinyvec.h>
42 template<typename P_numtype, int N_length, int N_stride>
44 public:
45  typedef P_numtype T_numtype;
46 
47  explicit TinyVectorIter(TinyVector<T_numtype, N_length>& x)
48  : data_(x.data())
49  { }
50 
51 #ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
52  TinyVectorIter(const TinyVectorIter<T_numtype, N_length, N_stride>& iter)
53  : data_(iter.data_)
54  {
55  }
56 #endif
57 
58  T_numtype operator[](int i) const
59  {
60  BZPRECONDITION(i >= 0 && i < N_length);
61  return data_[i * N_stride];
62  }
63 
64  T_numtype& restrict operator[](int i)
65  {
66  BZPRECONDITION(i >= 0 && i < N_length);
67  return data_[i * N_stride];
68  }
69 
70  T_numtype operator()(int i) const
71  {
72  BZPRECONDITION(i >= 0 && i < N_length);
73  return data_[i * N_stride];
74  }
75 
76  T_numtype& restrict operator()(int i)
77  {
78  BZPRECONDITION(i >= 0 && i < N_length);
79  return data_[i * N_stride];
80  }
81 
82  int length(int) const
83  { return N_length; }
84 
85  static const int _bz_staticLengthCount = 1,
86  _bz_dynamicLengthCount = 0,
87  _bz_staticLength = 0;
88 
89  bool _bz_hasFastAccess() const
90  { return true; }
91 
92  T_numtype _bz_fastAccess(int i) const
93  { return data_[i * N_stride]; }
94 
95  T_numtype& _bz_fastAccess(int i)
96  { return data_[i * N_stride]; }
97 
98  int _bz_suggestLength() const
99  { return N_length; }
100 
101 private:
102  T_numtype * restrict data_;
103 };
104 
105 // N_stride has default 1, in forward declaration in <blitz/tinyvec.h>
106 template<typename P_numtype, int N_length, int N_stride>
108 public:
109  typedef P_numtype T_numtype;
110 
112  : data_(x.data())
113  { }
114 
115 #ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
117  N_stride>& iter)
118  : data_(iter.data_)
119  {
120  }
121 
123  iter)
124  {
125  data_ = iter.data_;
126  }
127 #endif
128 
129  T_numtype operator[](int i) const
130  {
131  BZPRECONDITION(i >= 0 && i < N_length);
132  return data_[i * N_stride];
133  }
134 
135  T_numtype operator()(int i) const
136  {
137  BZPRECONDITION(i >= 0 && i < N_length);
138  return data_[i * N_stride];
139  }
140 
141  int length(int) const
142  { return N_length; }
143 
144  static const int _bz_staticLengthCount = 1,
147 
148  bool _bz_hasFastAccess() const
149  { return true; }
150 
152  { return data_[i * N_stride]; }
153 
154  int _bz_suggestLength() const
155  { return N_length; }
156 
157 private:
159 };
160 
162 
163 #endif // BZ_TINYVECITER_H