~ubuntu-branches/ubuntu/raring/blitz++/raring

« back to all changes in this revision

Viewing changes to blitz/array/domain.h

  • Committer: Bazaar Package Importer
  • Author(s): Konstantinos Margaritis
  • Date: 2005-02-28 20:25:01 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050228202501-3i4f2sknnprsqfhz
Tags: 1:0.8-4
Added missing build-depends (Closes: #297323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 * blitz/array/domain.h  Declaration of the RectDomain class
 
3
 *
 
4
 * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * Suggestions:          blitz-dev@oonumerics.org
 
17
 * Bugs:                 blitz-bugs@oonumerics.org
 
18
 *
 
19
 * For more information, please see the Blitz++ Home Page:
 
20
 *    http://oonumerics.org/blitz/
 
21
 *
 
22
 ****************************************************************************/
1
23
#ifndef BZ_DOMAIN_H
2
24
#define BZ_DOMAIN_H
3
25
 
72
94
    TinyVector<int,N_rank> lbound_, ubound_;
73
95
};
74
96
 
 
97
/*
 
98
 * StridedDomain added by Julian Cummings
 
99
 */
 
100
template<int N_rank>
 
101
class StridedDomain {
 
102
 
 
103
public:
 
104
    StridedDomain(const TinyVector<int,N_rank>& lbound,
 
105
        const TinyVector<int,N_rank>& ubound,
 
106
        const TinyVector<int,N_rank>& stride)
 
107
      : lbound_(lbound), ubound_(ubound), stride_(stride)
 
108
    { }
 
109
 
 
110
    // NEEDS_WORK: better constructors
 
111
    // StridedDomain(Range, Range, ...)
 
112
    // StridedDomain with any combination of Range and int
 
113
 
 
114
    const TinyVector<int,N_rank>& lbound() const
 
115
    { return lbound_; }
 
116
 
 
117
    int lbound(int i) const
 
118
    { return lbound_(i); }
 
119
 
 
120
    const TinyVector<int,N_rank>& ubound() const
 
121
    { return ubound_; }
 
122
 
 
123
    int ubound(int i) const
 
124
    { return ubound_(i); }
 
125
 
 
126
    const TinyVector<int,N_rank>& stride() const
 
127
    { return stride_; }
 
128
 
 
129
    int stride(int i) const
 
130
    { return stride_(i); }
 
131
 
 
132
    Range operator[](int rank) const
 
133
    { return Range(lbound_(rank), ubound_(rank), stride_(rank)); }
 
134
 
 
135
    void shrink(int amount)
 
136
    {
 
137
        lbound_ += amount * stride_;
 
138
        ubound_ -= amount * stride_;
 
139
    }
 
140
 
 
141
    void shrink(int dim, int amount)
 
142
    {
 
143
        lbound_(dim) += amount * stride_(dim);
 
144
        ubound_(dim) -= amount * stride_(dim);
 
145
    }
 
146
 
 
147
    void expand(int amount)
 
148
    {
 
149
        lbound_ -= amount * stride_;
 
150
        ubound_ += amount * stride_;
 
151
    }
 
152
 
 
153
    void expand(int dim, int amount)
 
154
    {
 
155
        lbound_(dim) -= amount * stride_(dim);
 
156
        ubound_(dim) += amount * stride_(dim);
 
157
    }
 
158
 
 
159
private:
 
160
    TinyVector<int,N_rank> lbound_, ubound_, stride_;
 
161
};
 
162
 
 
163
 
75
164
template<int N_rank>
76
165
inline RectDomain<N_rank> strip(const TinyVector<int,N_rank>& startPosition,
77
166
    int stripDimension, int ubound)