typedef Value_T value_type;
typedef matrix self;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef Value_T* row_type;
typedef stride_iter<value_type*> col_type;
typedef const value_type* const_row_type;
typedef stride_iter<const value_type*> const_col_type;
// конструкторы
matrix() : nrows(0), ncols(0), m() {}
matrix(int r, int c) : nrows(r), ncols(c), m(r * с) {}
matrix(const self& x) : m(x.m), nrows(x.nrows), ncols(x.ncols) {}
template<typename T>
explicit matrix(const valarray<T>& x)
: m(x.size() + 1), nrows(x.size()), ncols(1) {
for (int i=0; i<x.size(); ++i) m[i] = x[i];
}
// позволить конструирование из матриц других типов
template<typename T> explicit matrix(const matrix<T>& x)
: m(x.size() + 1), nrows(x.nrows), ncols(x.ncols) {
copy(x.begin(), x.end(), m.begin());
}
// открытые функции
int rows() const { return nrows; }
int cols() const { return ncols; }
int size() const { return nrows * ncols; }
// доступ к элементам
row_type row begin(int n) { return &m[n * cols()]; }
row_type row_end(int n) { return row_begin() + cols(); }
col_type col_begin(int n) { return col_type(&m[n], cols()); }