23 #include "vnl/vnl_matrix.h"
44 template<
typename TValue >
45 class ITK_TEMPLATE_EXPORT
Array2D:
public vnl_matrix< TValue >
55 Array2D(
unsigned int rows,
unsigned int cols);
59 const Self & operator=(
const Self & array);
63 void Fill(TValue
const & v) { this->fill(v); }
68 return this->operator()(static_cast<unsigned int>(row), static_cast<unsigned int>(col));
74 this->operator()(static_cast<unsigned int>(row), static_cast<unsigned int>(col)) = value;
78 void SetSize(
unsigned int m,
unsigned int n);
85 template<
typename TValue >
86 std::ostream & operator<<(std::ostream & os, const Array2D< TValue > & arr)
88 const unsigned int numberOfRows = arr.rows();
89 const unsigned int numberOfColumns = arr.cols();
91 for (
unsigned int r = 0; r < numberOfRows; ++r )
94 if ( numberOfColumns >= 1 )
96 const unsigned int lastColumn = numberOfColumns - 1;
97 for (
unsigned int c = 0; c < lastColumn; ++c )
99 os << arr(r, c) <<
", ";
101 os << arr(r, lastColumn);
103 os <<
"]" << std::endl;
110 template<> ITKCommon_EXPORT std::ostream & operator<<(std::ostream & os, const Array2D< float > & arr);
111 template<> ITKCommon_EXPORT std::ostream & operator<<(std::ostream & os, const Array2D< double > & arr);
115 #ifndef ITK_MANUAL_INSTANTIATION
116 #include "itkArray2D.hxx"
const TValue & GetElement(SizeValueType row, SizeValueType col) const
unsigned long SizeValueType
WeightsValueType ValueType
void Fill(TValue const &v)
vnl_matrix< WeightsValueType > VnlMatrixType
Array2D class representing a 2D array with size defined at construction time.
void SetElement(SizeValueType row, SizeValueType col, const TValue &value)