5 # include <tpl_dynArray.H>
52 const T & read_array_entry(
const size_t i)
const
54 const T * entry_ptr = array_ptr->test(i);
56 return entry_ptr == NULL ? Zero : *entry_ptr;
59 T & write_array_entry(
const size_t i,
const T & data)
61 T & ref = array_ptr->touch(i) = data;
66 size_t get_index(
const size_t i,
const size_t j)
const
73 void set_default_initial_value(
const T & value)
75 array_ptr->set_default_initial_value(value);
82 std::swap(Zero, mat.Zero);
83 std::swap(array_ptr, mat.array_ptr);
89 if (array_ptr != NULL)
99 array_ptr->set_default_initial_value(Zero);
105 array_ptr->reserve(n*m);
118 DynMatrix(
const size_t __n,
const size_t __m,
const T & zero = T())
119 : n(__n), m(__m), array_ptr(NULL), Zero(zero)
141 *array_ptr = *mat.array_ptr;
163 array_ptr->copy_array_exactly(*
this, mat);
176 const size_t N = n*m;
177 for (
int i = 0; i < N; ++i)
178 if (read_array_entry(i) != mat.read_array_entry(i))
185 const size_t &
rows()
const {
return n; }
188 const size_t &
cols()
const {
return m; }
191 const T &
read(
const size_t i,
const size_t j)
const
195 return read_array_entry(get_index(i, j));
205 T &
write(
const size_t i,
const size_t j,
const T & data)
209 return write_array_entry(get_index(i, j), data);
213 T &
access(
const size_t i,
const size_t j)
215 return array_ptr->access(get_index(i, j));
218 T & operator () (
const size_t i,
const size_t j)
223 T &
access(
const size_t i,
const size_t j)
const
225 return array_ptr->access(get_index(i, j));
228 T & operator () (
const size_t i,
const size_t j)
const
233 template <
class Operation>
234 bool traverse(Operation & operation)
const
236 return array_ptr->traverse(operation);
239 template <
class Operation>
240 bool traverse(Operation & operation)
242 return array_ptr->traverse(operation);
245 template <
class Operation>
246 bool traverse(Operation && operation = Operation())
const
248 return traverse<Operation>(operation);
251 template <
class Operation>
252 bool traverse(Operation && operation = Operation())
254 return traverse<Operation>(operation);
257 Functional_Methods(T);
262 #endif // TPL_DYNMAT_H
const T & read(const size_t i, const size_t j) const
Lee el valor de la i fila j columna.
Definition: tpl_dynMat.H:191
DynMatrix(const DynMatrix< T > &mat)
Definition: tpl_dynMat.H:138
Definition: tpl_dynMat.H:43
DynMatrix< T > & operator=(const DynMatrix< T > &mat)
Definition: tpl_dynMat.H:156
DynMatrix(const size_t __n, const size_t __m, const T &zero=T())
Definition: tpl_dynMat.H:118
static void compute_sizes(const size_t n, size_t &d, size_t &s, size_t &b)
Definition: tpl_dynArray.H:123
const size_t & rows() const
Retorna la cantidad de filas de la matriz.
Definition: tpl_dynMat.H:185
void set_dimension(const size_t __n, const size_t __m)
Reajusta la dimensión del arreglo.
Definition: tpl_dynMat.H:87
T & access(const size_t i, const size_t j)
acceso sin verificación de entrada esparcida
Definition: tpl_dynMat.H:213
Definition: tpl_dynArray.H:70
T & write(const size_t i, const size_t j, const T &data)
Definition: tpl_dynMat.H:205
void allocate()
Asegura que toda la memoria del arreglo esté apartada.
Definition: tpl_dynMat.H:103
const size_t & cols() const
Retorna la cantidad de columnas de la matriz.
Definition: tpl_dynMat.H:188