MeteoIODoc  2.10.0
mio::Array2D< T > Class Template Reference

Detailed Description

template<class T>
class mio::Array2D< T >

The template class Array2D is a 2D Array (Matrix) able to hold any type of object as datatype. It relies on the Array2DProxy class to provide the [][] operator (slower than the (i,j) call). If the compilation flag NOSAFECHECKS is used, bounds check is turned off (leading to increased performances).

Author
Thomas Egger

#include <Array2D.h>

Public Member Functions

 Array2D ()
 
 Array2D (const size_t &anx, const size_t &any)
 
 Array2D (const size_t &anx, const size_t &any, const T &init)
 
 Array2D (const Array2D< T > &i_array2D, const size_t &i_nx, const size_t &i_ny, const size_t &i_ncols, const size_t &i_nrows)
 
 Array2D (const Array3D< T > &array3D, const size_t &depth)
 
void subset (const Array2D< T > &i_array2D, const size_t &i_nx, const size_t &i_ny, const size_t &i_ncols, const size_t &i_nrows)
 A method that can be used to cut out a subplane of an existing Array2D object that is passed as i_array2D argument. The resulting Array2D object is a by value copy of a subplane of the plane spanned by the i_array2D. More...
 
void fill (const Array2D< T > &i_array2D, const size_t &i_nx, const size_t &i_ny, const size_t &i_ncols, const size_t &i_nrows)
 A method that can be used to insert a subplane into an existing Array2D object that is passed as i_array2D argument. This is exactly the opposite of the subset method an can be used to rebuild an array from subsets. More...
 
void fill (const Array2D< T > &i_array2D, const size_t &i_nx, const size_t &i_ny)
 
void setKeepNodata (const bool i_keep_nodata)
 set how to process nodata values (ie: as nodata or as normal numbers) More...
 
bool getKeepNodata () const
 get how to process nodata values (ie: as nodata or as normal numbers) More...
 
void resize (const size_t &anx, const size_t &any)
 
void resize (const size_t &anx, const size_t &any, const T &init)
 
void size (size_t &anx, size_t &any) const
 
size_t size () const
 
size_t getNx () const
 
size_t getNy () const
 
void clear ()
 
bool empty () const
 
getMin () const
 returns the minimum value contained in the grid More...
 
getMax () const
 returns the maximum value contained in the grid More...
 
getMean () const
 returns the mean value contained in the grid More...
 
size_t getCount () const
 returns the number of points contained in the grid. If setNodataHandling(IOUtils::RAW_NODATA), then the number of points is the size of the grid. If setNodataHandling(IOUtils::PARSE_NODATA), then it is the number of non-nodata values in the grid More...
 
const Array2D< T > getAbs () const
 returns the grid of the absolute value of values contained in the grid More...
 
void abs ()
 
const std::string toString () const
 
bool checkEpsilonEquality (const Array2D< double > &rhs, const double &epsilon) const
 
T & operator() (const size_t &x, const size_t &y)
 
const T operator() (const size_t &x, const size_t &y) const
 
T & operator() (const size_t &i)
 
const T operator() (const size_t &i) const
 
Array2DProxy< T > operator[] (const size_t &i)
 
Array2D< T > & operator= (const T &value)
 
Array2D< T > & operator+= (const T &rhs)
 
const Array2D< T > operator+ (const T &rhs) const
 
Array2D< T > & operator+= (const Array2D< T > &rhs)
 
const Array2D< T > operator+ (const Array2D< T > &rhs) const
 
Array2D< T > & operator-= (const T &rhs)
 
const Array2D< T > operator- (const T &rhs) const
 
Array2D< T > & operator-= (const Array2D< T > &rhs)
 
const Array2D< T > operator- (const Array2D< T > &rhs) const
 
Array2D< T > & operator*= (const T &rhs)
 
const Array2D< T > operator* (const T &rhs) const
 
Array2D< T > & operator*= (const Array2D< T > &rhs)
 
const Array2D< T > operator* (const Array2D< T > &rhs) const
 
Array2D< T > & operator/= (const T &rhs)
 
const Array2D< T > operator/ (const T &rhs) const
 
Array2D< T > & operator/= (const Array2D< T > &rhs)
 
const Array2D< T > operator/ (const Array2D< T > &rhs) const
 
bool operator== (const Array2D< T > &) const
 Operator that tests for equality. More...
 
bool operator!= (const Array2D< T > &) const
 Operator that tests for inequality. More...
 

Static Public Member Functions

static bool checkEpsilonEquality (const Array2D< double > &rhs1, const Array2D< double > &rhs2, const double &epsilon)
 

Protected Attributes

std::vector< T > vecData
 
size_t nx
 
size_t ny
 
bool keep_nodata
 

Friends

template<class P >
std::ostream & operator<< (std::ostream &os, const Array2D< P > &array)
 
template<class P >
std::istream & operator>> (std::istream &is, Array2D< P > &array)
 

Constructor & Destructor Documentation

◆ Array2D() [1/5]

template<class T >
mio::Array2D< T >::Array2D

◆ Array2D() [2/5]

template<class T >
mio::Array2D< T >::Array2D ( const size_t &  anx,
const size_t &  any 
)

A constructor that creates an array of a given size

Parameters
anxnumber of columns of the new array
anynumber of rows of the new array

◆ Array2D() [3/5]

template<class T >
mio::Array2D< T >::Array2D ( const size_t &  anx,
const size_t &  any,
const T &  init 
)

A constructor that creates an array filled with constant values

Parameters
anxnumber of columns of the new array
anynumber of rows of the new array
initinitial value to fill the array with

◆ Array2D() [4/5]

template<class T >
mio::Array2D< T >::Array2D ( const Array2D< T > &  i_array2D,
const size_t &  i_nx,
const size_t &  i_ny,
const size_t &  i_ncols,
const size_t &  i_nrows 
)

A constructor that can be used to create an Array2D object that is contained in the one passed as i_array2D argument. The resulting Array2D object is a by value copy of a subplane of the plane spanned by the i_array2D

Parameters
i_array2Darray containing to extract the values from
i_nxlower left corner cell X index
i_nylower left corner cell Y index
i_ncolsnumber of columns of the new array
i_nrowsnumber of rows of the new array

◆ Array2D() [5/5]

template<class T >
mio::Array2D< T >::Array2D ( const Array3D< T > &  array3D,
const size_t &  depth 
)

A constructor that create an Array2D object from a layer of an Array3D

Parameters
array3Darray containing to extract the values from
depthlayer depth to extract

Member Function Documentation

◆ abs()

template<class T >
void mio::Array2D< T >::abs

◆ checkEpsilonEquality() [1/2]

template<class T >
bool mio::Array2D< T >::checkEpsilonEquality ( const Array2D< double > &  rhs,
const double &  epsilon 
) const

◆ checkEpsilonEquality() [2/2]

template<class T >
bool mio::Array2D< T >::checkEpsilonEquality ( const Array2D< double > &  rhs1,
const Array2D< double > &  rhs2,
const double &  epsilon 
)
static

◆ clear()

template<class T >
void mio::Array2D< T >::clear

◆ empty()

template<class T >
bool mio::Array2D< T >::empty

◆ fill() [1/2]

template<class T >
void mio::Array2D< T >::fill ( const Array2D< T > &  i_array2D,
const size_t &  i_nx,
const size_t &  i_ny 
)

◆ fill() [2/2]

template<class T >
void mio::Array2D< T >::fill ( const Array2D< T > &  i_array2D,
const size_t &  i_nx,
const size_t &  i_ny,
const size_t &  i_ncols,
const size_t &  i_nrows 
)

A method that can be used to insert a subplane into an existing Array2D object that is passed as i_array2D argument. This is exactly the opposite of the subset method an can be used to rebuild an array from subsets.

Parameters
i_array2Darray containing to subset values
i_nxlower left corner cell X index
i_nylower left corner cell Y index
i_ncolsnumber of columns of the new array
i_nrowsnumber of rows of the new array

◆ getAbs()

template<class T >
const Array2D< T > mio::Array2D< T >::getAbs

returns the grid of the absolute value of values contained in the grid

Returns
grid of abs(grid)

◆ getCount()

template<class T >
size_t mio::Array2D< T >::getCount

returns the number of points contained in the grid. If setNodataHandling(IOUtils::RAW_NODATA), then the number of points is the size of the grid. If setNodataHandling(IOUtils::PARSE_NODATA), then it is the number of non-nodata values in the grid

Returns
count

◆ getKeepNodata()

template<class T >
bool mio::Array2D< T >::getKeepNodata

get how to process nodata values (ie: as nodata or as normal numbers)

Returns
true means that NODATA is interpreted as NODATA, false means that it is a normal number

◆ getMax()

template<class T >
T mio::Array2D< T >::getMax

returns the maximum value contained in the grid

Returns
maximum value

◆ getMean()

template<class T >
T mio::Array2D< T >::getMean

returns the mean value contained in the grid

Returns
mean value

◆ getMin()

template<class T >
T mio::Array2D< T >::getMin

returns the minimum value contained in the grid

Returns
minimum value

◆ getNx()

template<class T >
size_t mio::Array2D< T >::getNx

◆ getNy()

template<class T >
size_t mio::Array2D< T >::getNy

◆ operator!=()

template<class T >
bool mio::Array2D< T >::operator!= ( const Array2D< T > &  in) const

Operator that tests for inequality.

◆ operator()() [1/4]

template<class T >
T & mio::Array2D< T >::operator() ( const size_t &  i)
inline

◆ operator()() [2/4]

template<class T >
const T mio::Array2D< T >::operator() ( const size_t &  i) const
inline

◆ operator()() [3/4]

template<class T >
T & mio::Array2D< T >::operator() ( const size_t &  x,
const size_t &  y 
)
inline

◆ operator()() [4/4]

template<class T >
const T mio::Array2D< T >::operator() ( const size_t &  x,
const size_t &  y 
) const
inline

◆ operator*() [1/2]

template<class T >
const Array2D< T > mio::Array2D< T >::operator* ( const Array2D< T > &  rhs) const

◆ operator*() [2/2]

template<class T >
const Array2D< T > mio::Array2D< T >::operator* ( const T &  rhs) const

◆ operator*=() [1/2]

template<class T >
Array2D< T > & mio::Array2D< T >::operator*= ( const Array2D< T > &  rhs)

◆ operator*=() [2/2]

template<class T >
Array2D< T > & mio::Array2D< T >::operator*= ( const T &  rhs)

◆ operator+() [1/2]

template<class T >
const Array2D< T > mio::Array2D< T >::operator+ ( const Array2D< T > &  rhs) const

◆ operator+() [2/2]

template<class T >
const Array2D< T > mio::Array2D< T >::operator+ ( const T &  rhs) const

◆ operator+=() [1/2]

template<class T >
Array2D< T > & mio::Array2D< T >::operator+= ( const Array2D< T > &  rhs)

◆ operator+=() [2/2]

template<class T >
Array2D< T > & mio::Array2D< T >::operator+= ( const T &  rhs)

◆ operator-() [1/2]

template<class T >
const Array2D< T > mio::Array2D< T >::operator- ( const Array2D< T > &  rhs) const

◆ operator-() [2/2]

template<class T >
const Array2D< T > mio::Array2D< T >::operator- ( const T &  rhs) const

◆ operator-=() [1/2]

template<class T >
Array2D< T > & mio::Array2D< T >::operator-= ( const Array2D< T > &  rhs)

◆ operator-=() [2/2]

template<class T >
Array2D< T > & mio::Array2D< T >::operator-= ( const T &  rhs)

◆ operator/() [1/2]

template<class T >
const Array2D< T > mio::Array2D< T >::operator/ ( const Array2D< T > &  rhs) const

◆ operator/() [2/2]

template<class T >
const Array2D< T > mio::Array2D< T >::operator/ ( const T &  rhs) const

◆ operator/=() [1/2]

template<class T >
Array2D< T > & mio::Array2D< T >::operator/= ( const Array2D< T > &  rhs)

◆ operator/=() [2/2]

template<class T >
Array2D< T > & mio::Array2D< T >::operator/= ( const T &  rhs)

◆ operator=()

template<class T >
Array2D< T > & mio::Array2D< T >::operator= ( const T &  value)

◆ operator==()

template<class T >
bool mio::Array2D< T >::operator== ( const Array2D< T > &  in) const

Operator that tests for equality.

◆ operator[]()

template<class T >
Array2DProxy< T > mio::Array2D< T >::operator[] ( const size_t &  i)

◆ resize() [1/2]

template<class T >
void mio::Array2D< T >::resize ( const size_t &  anx,
const size_t &  any 
)

◆ resize() [2/2]

template<class T >
void mio::Array2D< T >::resize ( const size_t &  anx,
const size_t &  any,
const T &  init 
)

◆ setKeepNodata()

template<class T >
void mio::Array2D< T >::setKeepNodata ( const bool  i_keep_nodata)

set how to process nodata values (ie: as nodata or as normal numbers)

Parameters
i_keep_nodatatrue means that NODATA is interpreted as NODATA, false means that it is a normal number By default, arrays keep nodata.

◆ size() [1/2]

template<class T >
size_t mio::Array2D< T >::size

◆ size() [2/2]

template<class T >
void mio::Array2D< T >::size ( size_t &  anx,
size_t &  any 
) const

◆ subset()

template<class T >
void mio::Array2D< T >::subset ( const Array2D< T > &  i_array2D,
const size_t &  i_nx,
const size_t &  i_ny,
const size_t &  i_ncols,
const size_t &  i_nrows 
)

A method that can be used to cut out a subplane of an existing Array2D object that is passed as i_array2D argument. The resulting Array2D object is a by value copy of a subplane of the plane spanned by the i_array2D.

Parameters
i_array2Darray containing to extract the values from
i_nxlower left corner cell X index
i_nylower left corner cell Y index
i_ncolsnumber of columns of the new array
i_nrowsnumber of rows of the new array

◆ toString()

template<class T >
const std::string mio::Array2D< T >::toString

Friends And Related Function Documentation

◆ operator<<

template<class T >
template<class P >
std::ostream& operator<< ( std::ostream &  os,
const Array2D< P > &  array 
)
friend

◆ operator>>

template<class T >
template<class P >
std::istream& operator>> ( std::istream &  is,
Array2D< P > &  array 
)
friend

Member Data Documentation

◆ keep_nodata

template<class T >
bool mio::Array2D< T >::keep_nodata
protected

◆ nx

template<class T >
size_t mio::Array2D< T >::nx
protected

◆ ny

template<class T >
size_t mio::Array2D< T >::ny
protected

◆ vecData

template<class T >
std::vector<T> mio::Array2D< T >::vecData
protected

The documentation for this class was generated from the following file: