44 template <
class Array2D>
48 template <
class Array2D>
58 typedef typename Array2D::value_type
T;
69 const Array2D &
array()
const {
return A_; }
75 #ifdef TNT_BOUNDS_CHECK
76 BIASASSERT(
A_.lbound() <= i);
77 BIASASSERT( i<=
dim_[0] +
A_.lbound()-1);
84 #ifdef TNT_BOUNDS_CHECK
85 BIASASSERT(
A_.lbound() <= i);
86 BIASASSERT( i<=
dim_[0] +
A_.lbound()-1);
88 return dim_[i-
A_.lbound()];
96 #ifdef TNT_BOUNDS_CHECK
97 BIASASSERT( i1 <= i2 );
98 BIASASSERT( j1 <= j2);
99 BIASASSERT( A.lbound() <= i1);
100 BIASASSERT( i2<= A.dim(A.lbound()) + A.lbound()-1);
101 BIASASSERT( A.lbound() <= j1);
102 BIASASSERT( j2<= A.dim(A.lbound()+1) + A.lbound()-1 );
107 offset_[1] = j1-A.lbound();
114 #ifdef TNT_BOUNDS_CHECK
117 BIASASSERT( A.lbound() <= I.
lbound());
118 BIASASSERT( I.
ubound()<= A.dim(A.lbound()) + A.lbound()-1);
119 BIASASSERT( A.lbound() <= J.
lbound());
120 BIASASSERT( J.
ubound() <= A.dim(A.lbound()+1) + A.lbound()-1 );
124 offset_[1] = J.
lbound()-A.lbound();
132 #ifdef TNT_BOUNDS_CHECK
133 BIASASSERT( i1 <= i2 );
134 BIASASSERT( j1 <= j2);
135 BIASASSERT( A.
lbound() <= i1);
137 BIASASSERT( A.
lbound() <= j1);
149 #ifdef TNT_BOUNDS_CHECK
150 BIASASSERT( i1 <= i2 );
151 BIASASSERT( j1 <= j2);
152 BIASASSERT(
A_.lbound() <= i1);
153 BIASASSERT( i2<=
dim_[0] +
A_.lbound()-1);
154 BIASASSERT(
A_.lbound() <= j1);
155 BIASASSERT( j2<=
dim_[1] +
A_.lbound()-1 );
158 i1+
offset_[0], offset_[0] + i2,
159 j1+offset_[1], offset_[1] + j2);
166 #ifdef TNT_BOUNDS_CHECK
169 BIASASSERT(
A_.lbound() <= I.
lbound());
171 BIASASSERT(
A_.lbound() <= J.
lbound());
182 #ifdef TNT_BOUNDS_CHECK
183 BIASASSERT(
A_.lbound() <= i);
184 BIASASSERT( i<=
dim_[0] +
A_.lbound()-1);
185 BIASASSERT(
A_.lbound() <= j);
186 BIASASSERT( j<=
dim_[1] +
A_.lbound()-1 );
193 #ifdef TNT_BOUNDS_CHECK
194 BIASASSERT(
A_.lbound() <= i);
195 BIASASSERT( i<=
dim_[0] +
A_.lbound()-1);
196 BIASASSERT(
A_.lbound() <= j);
197 BIASASSERT( j<=
dim_[1] +
A_.lbound()-1 );
218 (*
this)(i,j) = R(i,j);
238 (*
this)(i,j) = R(i,j);
249 BIASASSERT(M == R.num_rows());
250 BIASASSERT(N == R.num_cols());
258 (*
this)(i,j) = R(i,j);
272 (*
this)(i,j) = scalar;
281 template <
class Array2D>
291 typedef typename Array2D::value_type
T;
303 #ifdef TNT_BOUNDS_CHECK
304 BIASASSERT( TNT_BASE_OFFSET <= i);
305 BIASASSERT( i<=
dim_[0] + TNT_BASE_OFFSET-1);
307 return offset_[i-TNT_BASE_OFFSET];
312 #ifdef TNT_BOUNDS_CHECK
313 BIASASSERT( TNT_BASE_OFFSET <= i);
314 BIASASSERT( i<=
dim_[0] + TNT_BASE_OFFSET-1);
316 return dim_[i-TNT_BASE_OFFSET];
323 #ifdef TNT_BOUNDS_CHECK
324 BIASASSERT( i1 <= i2 );
325 BIASASSERT( j1 <= j2);
326 BIASASSERT( TNT_BASE_OFFSET <= i1);
327 BIASASSERT( i2<= A.dim(TNT_BASE_OFFSET) + TNT_BASE_OFFSET-1);
328 BIASASSERT( TNT_BASE_OFFSET <= j1);
329 BIASASSERT( j2<= A.dim(TNT_BASE_OFFSET+1) + TNT_BASE_OFFSET-1 );
332 offset_[0] = i1-TNT_BASE_OFFSET;
333 offset_[1] = j1-TNT_BASE_OFFSET;
341 #ifdef TNT_BOUNDS_CHECK
344 BIASASSERT( TNT_BASE_OFFSET <= I.
lbound());
345 BIASASSERT( I.
ubound()<= A.dim(TNT_BASE_OFFSET) + TNT_BASE_OFFSET-1);
346 BIASASSERT( TNT_BASE_OFFSET <= J.
lbound());
347 BIASASSERT( J.
ubound() <= A.dim(TNT_BASE_OFFSET+1) + TNT_BASE_OFFSET-1 );
351 offset_[1] = J.
lbound()-TNT_BASE_OFFSET;
361 #ifdef TNT_BOUNDS_CHECK
362 BIASASSERT( i1 <= i2 );
363 BIASASSERT( j1 <= j2);
364 BIASASSERT( TNT_BASE_OFFSET <= i1);
365 BIASASSERT( i2<= A.dim(TNT_BASE_OFFSET) + TNT_BASE_OFFSET-1);
366 BIASASSERT( TNT_BASE_OFFSET <= j1);
367 BIASASSERT( j2<= A.dim(TNT_BASE_OFFSET+1) + TNT_BASE_OFFSET-1 );
369 offset_[0] = (i1 - TNT_BASE_OFFSET) + A.offset_[0];
370 offset_[1] = (j1 - TNT_BASE_OFFSET) + A.offset_[1];
378 #ifdef TNT_BOUNDS_CHECK
379 BIASASSERT( i1 <= i2 );
380 BIASASSERT( j1 <= j2);
381 BIASASSERT( TNT_BASE_OFFSET <= i1);
382 BIASASSERT( i2<=
dim_[0] + TNT_BASE_OFFSET-1);
383 BIASASSERT( TNT_BASE_OFFSET <= j1);
384 BIASASSERT( j2<=
dim_[0] + TNT_BASE_OFFSET-1 );
387 i1+
offset_[0], offset_[0] + i2,
388 j1+offset_[1], offset_[1] + j2);
395 #ifdef TNT_BOUNDS_CHECK
398 BIASASSERT( TNT_BASE_OFFSET <= I.
lbound());
399 BIASASSERT( I.
ubound()<=
dim_[0] + TNT_BASE_OFFSET-1);
400 BIASASSERT( TNT_BASE_OFFSET <= J.
lbound());
401 BIASASSERT( J.
ubound() <=
dim_[1] + TNT_BASE_OFFSET-1 );
412 #ifdef TNT_BOUNDS_CHECK
413 BIASASSERT( TNT_BASE_OFFSET <= i);
414 BIASASSERT( i<=
dim_[0] + TNT_BASE_OFFSET-1);
415 BIASASSERT( TNT_BASE_OFFSET <= j);
416 BIASASSERT( j<=
dim_[1] + TNT_BASE_OFFSET-1 );
426 template <
class Array2D>
427 std::ostream& operator<<(std::ostream &s, const const_Region2D<Array2D> &A)
430 Subscript Mend=A.lbound()+ A.num_rows() - 1;
431 Subscript Nend=A.lbound() + A.num_cols() - 1;
434 s << A.num_rows() <<
" " << A.num_cols() <<
"\n";
448 template <
class Array2D>
449 std::ostream& operator<<(std::ostream &s, const Region2D<Array2D> &A)
452 Subscript Mend=A.lbound()+ A.num_rows() - 1;
453 Subscript Nend=A.lbound() + A.num_cols() - 1;
456 s << A.num_rows() <<
" " << A.num_cols() <<
"\n";
const Array2D & array() const
const T & const_reference
Subscript dim(Subscript i) const
Region2D< Array2D > & operator=(const T &scalar)
Subscript num_rows() const
Region2D< Array2D > operator()(Subscript i1, Subscript i2, Subscript j1, Subscript j2)
Region2D(Array2D &A, Subscript i1, Subscript i2, Subscript j1, Subscript j2)
Region2D< Array2D > & operator=(const const_Region2D< Array2D > &R)
const Array2D & array() const
Region2D< Array2D > operator()(const Index1D &I, const Index1D &J)
Subscript offset(Subscript i) const
const_Region2D(const Array2D &A, Subscript i1, Subscript i2, Subscript j1, Subscript j2)
Region2D< Array2D > & operator=(const Region2D< Array2D > &R)
TNT_SUBSCRIPT_TYPE Subscript
Subscript num_cols() const
const_Region2D< Array2D > operator()(const Index1D &I, const Index1D &J)
const_Region2D(const Array2D &A, const Index1D &I, const Index1D &J)
const_Region2D< Array2D > operator()(Subscript i1, Subscript i2, Subscript j1, Subscript j2)
const T & const_reference
Subscript num_cols() const
const_Region2D(const_Region2D< Array2D > &A, Subscript i1, Subscript i2, Subscript j1, Subscript j2)
Subscript dim(Subscript i) const
Region2D(Array2D &A, const Index1D &I, const Index1D &J)
T & operator()(Subscript i, Subscript j)
Region2D< Array2D > & operator=(const Array2D &R)
Region2D(Region2D< Array2D > &A, Subscript i1, Subscript i2, Subscript j1, Subscript j2)
Subscript num_rows() const
Subscript offset(Subscript i) const