source: Sophya/trunk/Poubelle/DPC:FitsIOServer/Blitz/blitz/tinyveciter.h@ 658

Last change on this file since 658 was 658, checked in by ansari, 26 years ago

no message

File size: 4.4 KB
Line 
1/***************************************************************************
2 * blitz/tinyveciter.h Declaration of TinyVectorIter<T,N,stride>
3 *
4 * $Id: tinyveciter.h,v 1.1.1.1 1999-11-26 16:37:05 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 * http://seurat.uwaterloo.ca/blitz/
23 *
24 ***************************************************************************
25 * $Log: not supported by cvs2svn $
26 * Revision 1.1.1.1 1999/04/09 17:59:01 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
38#ifndef BZ_TINYVECITER_H
39#define BZ_TINYVECITER_H
40
41#ifndef BZ_TINYVEC_H
42 #include <blitz/tinyvec.h>
43#endif
44
45#ifndef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
46 #error "Debug in tinyveciter.h (this line shouldn't be here)"
47#endif
48
49BZ_NAMESPACE(blitz)
50
51// N_stride has default 1, in forward declaration in <blitz/tinyvec.h>
52template<class P_numtype, int N_length, int N_stride>
53class TinyVectorIter {
54public:
55 typedef P_numtype T_numtype;
56
57 _bz_explicit TinyVectorIter(TinyVector<T_numtype, N_length>& x)
58 : data_(x.data())
59 { }
60
61#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
62 TinyVectorIter(const TinyVectorIter<T_numtype, N_length, N_stride>& iter)
63 : data_(iter.data_)
64 {
65 }
66#endif
67
68 T_numtype operator[](unsigned i) const
69 {
70 BZPRECONDITION(i < N_length);
71 return data_[i * N_stride];
72 }
73
74 T_numtype& _bz_restrict operator[](unsigned i)
75 {
76 BZPRECONDITION(i < N_length);
77 return data_[i * N_stride];
78 }
79
80 T_numtype operator()(unsigned i) const
81 {
82 BZPRECONDITION(i < N_length);
83 return data_[i * N_stride];
84 }
85
86 T_numtype& _bz_restrict operator()(unsigned i)
87 {
88 BZPRECONDITION(i < N_length);
89 return data_[i * N_stride];
90 }
91
92 unsigned length(unsigned) const
93 { return N_length; }
94
95 enum { _bz_staticLengthCount = 1,
96 _bz_dynamicLengthCount = 0,
97 _bz_staticLength = 0 };
98
99 _bz_bool _bz_hasFastAccess() const
100 { return _bz_true; }
101
102 T_numtype _bz_fastAccess(unsigned i) const
103 { return data_[i * N_stride]; }
104
105 T_numtype& _bz_fastAccess(unsigned i)
106 { return data_[i * N_stride]; }
107
108 unsigned _bz_suggestLength() const
109 { return N_length; }
110
111private:
112 T_numtype * _bz_restrict data_;
113};
114
115// N_stride has default 1, in forward declaration in <blitz/tinyvec.h>
116template<class P_numtype, int N_length, int N_stride>
117class TinyVectorIterConst {
118public:
119 typedef P_numtype T_numtype;
120
121 _bz_explicit TinyVectorIterConst(const TinyVector<T_numtype, N_length>& x)
122 : data_(x.data())
123 { }
124
125#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
126 TinyVectorIterConst(const TinyVectorIterConst<T_numtype, N_length,
127 N_stride>& iter)
128 : data_(iter.data_)
129 {
130 }
131
132 void operator=(const TinyVectorIterConst<T_numtype, N_length, N_stride>&
133 iter)
134 {
135 data_ = iter.data_;
136 }
137#endif
138
139 T_numtype operator[](unsigned i) const
140 {
141 BZPRECONDITION(i < N_length);
142 return data_[i * N_stride];
143 }
144
145 T_numtype operator()(unsigned i) const
146 {
147 BZPRECONDITION(i < N_length);
148 return data_[i * N_stride];
149 }
150
151 unsigned length(unsigned) const
152 { return N_length; }
153
154 enum { _bz_staticLengthCount = 1,
155 _bz_dynamicLengthCount = 0,
156 _bz_staticLength = 0 };
157
158 _bz_bool _bz_hasFastAccess() const
159 { return _bz_true; }
160
161 T_numtype _bz_fastAccess(unsigned i) const
162 { return data_[i * N_stride]; }
163
164 unsigned _bz_suggestLength() const
165 { return N_length; }
166
167private:
168 const T_numtype * _bz_restrict data_;
169};
170
171BZ_NAMESPACE_END
172
173#endif // BZ_TINYVECITER_H
Note: See TracBrowser for help on using the repository browser.