18 #ifndef __itkArray2D_h
19 #define __itkArray2D_h
22 #include "vnl/vnl_matrix.h"
43 template<
typename TValue >
44 class Array2D:
public vnl_matrix< TValue >
54 Array2D(
unsigned int rows,
unsigned int cols);
62 void Fill(TValue
const & v) { this->fill(v); }
65 void SetSize(
unsigned int m,
unsigned int n);
72 template<
typename TValue >
73 std::ostream & operator<<(std::ostream & os, const Array2D< TValue > & arr)
75 const unsigned int numberOfRows = arr.rows();
76 const unsigned int numberOfColumns = arr.cols();
78 for (
unsigned int r = 0; r < numberOfRows; ++r )
81 if ( numberOfColumns >= 1 )
83 const unsigned int lastColumn = numberOfColumns - 1;
84 for (
unsigned int c = 0; c < lastColumn; ++c )
86 os << arr(r, c) <<
", ";
88 os << arr(r, lastColumn);
90 os <<
"]" << std::endl;
97 template<> ITKCommon_EXPORT std::ostream & operator<<(std::ostream & os, const Array2D< float > & arr);
98 template<> ITKCommon_EXPORT std::ostream & operator<<(std::ostream & os, const Array2D< double > & arr);
102 #ifndef ITK_MANUAL_INSTANTIATION
103 #include "itkArray2D.hxx"
const Self & operator=(const Self &array)
void SetSize(unsigned int m, unsigned int n)
void Fill(TValue const &v)
Array2D class representing a 2D array with size defined at construction time.
vnl_matrix< TValue > VnlMatrixType