27 #ifdef TNT_BOUNDS_CHECK
31 #include "tnt_array1d.h"
56 Array2D(
int m,
int n,
const T &a);
58 inline operator T**();
59 inline operator const T**();
60 inline Array2D & operator=(
const T &a);
65 inline T* operator[](
int i);
66 inline const T* operator[](
int i)
const;
67 inline int dim1()
const;
68 inline int dim2()
const;
74 inline int ref_count();
75 inline int ref_count_data();
76 inline int ref_count_dim1();
86 Array2D<T>::Array2D(
const Array2D<T> &A) : data_(A.data_), v_(A.v_),
93 Array2D<T>::Array2D(
int m,
int n) : data_(m*n), v_(m), m_(m), n_(n)
98 for (
int i=0; i<m; i++)
109 Array2D<T>::Array2D(
int m,
int n,
const T &val) : data_(m*n), v_(m),
116 for (
int i=0; i<m; i++)
125 Array2D<T>::Array2D(
int m,
int n, T *a) : data_(m*n, a), v_(m), m_(m), n_(n)
131 for (
int i=0; i<m; i++)
141 inline T* Array2D<T>::operator[](
int i)
143 #ifdef TNT_BOUNDS_CHECK
154 inline const T* Array2D<T>::operator[](
int i)
const
156 #ifdef TNT_BOUNDS_CHECK
166 Array2D<T> & Array2D<T>::operator=(
const T &a)
170 for (
int i=0; i<m_; i++)
171 for (
int j=0; j<n_; j++)
180 Array2D<T> Array2D<T>::copy()
const
184 for (
int i=0; i<m_; i++)
185 for (
int j=0; j<n_; j++)
194 Array2D<T> & Array2D<T>::inject(
const Array2D &A)
196 if (A.m_ == m_ && A.n_ == n_)
198 for (
int i=0; i<m_; i++)
199 for (
int j=0; j<n_; j++)
209 Array2D<T> & Array2D<T>::ref(
const Array2D<T> &A)
225 Array2D<T> & Array2D<T>::operator=(
const Array2D<T> &A)
231 inline int Array2D<T>::dim1()
const {
return m_; }
234 inline int Array2D<T>::dim2()
const {
return n_; }
238 Array2D<T>::~Array2D() {}
244 inline Array2D<T>::operator T**()
249 inline Array2D<T>::operator
const T**()
279 T* p = &(data_[0]) + i0 * n_ + j0;
280 for (
int i=0; i<m; i++)
291 return ref_count_data();
297 inline int Array2D<T>::ref_count_data()
299 return data_.ref_count();
303 inline int Array2D<T>::ref_count_dim1()
305 return v_.ref_count();