2
/***************************************************************************
3
* blitz/tinyveciter.h Declaration of TinyVectorIter<T,N,stride>
5
* $Id: tinyveciter.h,v 1.6 2005/05/07 04:17:56 julianc Exp $
7
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
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.
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.
19
* Suggestions: blitz-dev@oonumerics.org
20
* Bugs: blitz-bugs@oonumerics.org
22
* For more information, please see the Blitz++ Home Page:
23
* http://oonumerics.org/blitz/
25
***************************************************************************/
28
#ifndef BZ_TINYVECITER_H
29
#define BZ_TINYVECITER_H
32
#include <blitz/tinyvec.h>
35
#ifndef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
36
#error "Debug in tinyveciter.h (this line shouldn't be here)"
41
// N_stride has default 1, in forward declaration in <blitz/tinyvec.h>
42
template<typename P_numtype, int N_length, int N_stride>
43
class TinyVectorIter {
45
typedef P_numtype T_numtype;
47
explicit TinyVectorIter(TinyVector<T_numtype, N_length>& x)
51
#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
52
TinyVectorIter(const TinyVectorIter<T_numtype, N_length, N_stride>& iter)
58
T_numtype operator[](int i) const
60
BZPRECONDITION(i >= 0 && i < N_length);
61
return data_[i * N_stride];
64
T_numtype& restrict operator[](int i)
66
BZPRECONDITION(i >= 0 && i < N_length);
67
return data_[i * N_stride];
70
T_numtype operator()(int i) const
72
BZPRECONDITION(i >= 0 && i < N_length);
73
return data_[i * N_stride];
76
T_numtype& restrict operator()(int i)
78
BZPRECONDITION(i >= 0 && i < N_length);
79
return data_[i * N_stride];
85
static const int _bz_staticLengthCount = 1,
86
_bz_dynamicLengthCount = 0,
89
bool _bz_hasFastAccess() const
92
T_numtype _bz_fastAccess(int i) const
93
{ return data_[i * N_stride]; }
95
T_numtype& _bz_fastAccess(int i)
96
{ return data_[i * N_stride]; }
98
int _bz_suggestLength() const
102
T_numtype * restrict data_;
105
// N_stride has default 1, in forward declaration in <blitz/tinyvec.h>
106
template<typename P_numtype, int N_length, int N_stride>
107
class TinyVectorIterConst {
109
typedef P_numtype T_numtype;
111
explicit TinyVectorIterConst(const TinyVector<T_numtype, N_length>& x)
115
#ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
116
TinyVectorIterConst(const TinyVectorIterConst<T_numtype, N_length,
122
void operator=(const TinyVectorIterConst<T_numtype, N_length, N_stride>&
129
T_numtype operator[](int i) const
131
BZPRECONDITION(i >= 0 && i < N_length);
132
return data_[i * N_stride];
135
T_numtype operator()(int i) const
137
BZPRECONDITION(i >= 0 && i < N_length);
138
return data_[i * N_stride];
141
int length(int) const
144
static const int _bz_staticLengthCount = 1,
145
_bz_dynamicLengthCount = 0,
146
_bz_staticLength = 0;
148
bool _bz_hasFastAccess() const
151
T_numtype _bz_fastAccess(int i) const
152
{ return data_[i * N_stride]; }
154
int _bz_suggestLength() const
158
const T_numtype * restrict data_;
163
#endif // BZ_TINYVECITER_H