Main MRPT website > C++ reference
MRPT logo
Classes | Public Types

mrpt::math::CArrayNumeric< T, N > Class Template Reference

A CArrayPOD for numeric types, supporting several mathematical operations. More...

#include <mrpt/math/CArray.h>

Inheritance diagram for mrpt::math::CArrayNumeric< T, N >:
Inheritance graph
[legend]
Collaboration diagram for mrpt::math::CArrayNumeric< T, N >:
Collaboration graph
[legend]

List of all members.

Classes

struct  mrpt_container

Public Types

typedef CArrayNumeric< T, N > mrpt_autotype

Public Member Functions

Methods common to all containers

size_t countNonZero () const
void fill (const T &val)
T maximum (size_t *maxIndex=NULL) const
T minimum (size_t *minIndex=NULL) const
void minimum_maximum (T &out_min, T &out_max, size_t *minIndex=NULL, size_t *maxIndex=NULL) const
T norm_inf (size_t *maxIndex=NULL) const
T sumAll () const
template<typename RET_TYPE >
RET_TYPE sumAllRetType () const
template<class CONTAINEROUT >
void cumsum (CONTAINEROUT &out) const
template<class CONTAINEROUT >
CONTAINEROUT cumsum () const
template<class CONTAINER2 >
size_t countCommonElements (const CONTAINER2 &b) const
 Counts the number of elements that appear in both containers (comparison through the == operator).
std::vector< double > histogram (double limit_min, double limit_max, size_t number_bins, bool do_normalization=false) const
 Computes the normalized or normal histogram of a sequence of numbers given the number of bins and the limits.
template<class F >
mrpt_autotype & applyToAllElements (T(*function)(T))
mrpt_autotype & Sqrt ()
mrpt_autotype & Abs ()
mrpt_autotype & Square ()
mrpt_autotype & Exp ()
mrpt_autotype & Log ()
T squareNorm () const
T norm () const
double mean () const
void adjustRange (const T min_val, const T max_val)
void normalize (const T min_val=0, const T max_val=1)
double std (bool unbiased=true) const
void meanAndStd (double &out_mean, double &out_std, bool unbiased=true)
void loadFromTextFileAsVector (const std::string &file)
void saveToTextFileAsVector (const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool asColumnVector=false) const
 CArrayNumeric ()
 Default constructor.
 CArrayNumeric (const T *ptr)
 Constructor from initial values ptr[0]-ptr[N-1].
template<class ARRAYLIKE >
 CArrayNumeric (const ARRAYLIKE &obj)
 Initialization from a vector-like source, that is, anything implementing operator[].
CArrayNumeric< T, N > & operator+= (const CArrayNumeric< T, N > &o)
 Add: this+=other.
CArrayNumeric< T, N > & operator-= (const CArrayNumeric< T, N > &o)
 Substract: this-=other.

Detailed Description

template<typename T, std::size_t N>
class mrpt::math::CArrayNumeric< T, N >

A CArrayPOD for numeric types, supporting several mathematical operations.

See also:
CArrayFloat, CArrayDouble, CArrayInt, CArrayPOD, CArray

Definition at line 345 of file CArray.h.


Member Typedef Documentation

template<typename T, std::size_t N>
typedef CArrayNumeric<T,N> mrpt::math::CArrayNumeric< T, N >::mrpt_autotype

Definition at line 349 of file CArray.h.


Constructor & Destructor Documentation

template<typename T, std::size_t N>
mrpt::math::CArrayNumeric< T, N >::CArrayNumeric (  )  [inline]

Default constructor.

Definition at line 354 of file CArray.h.

template<typename T, std::size_t N>
mrpt::math::CArrayNumeric< T, N >::CArrayNumeric ( const T *  ptr  )  [inline]

Constructor from initial values ptr[0]-ptr[N-1].

Definition at line 356 of file CArray.h.

template<typename T, std::size_t N>
template<class ARRAYLIKE >
mrpt::math::CArrayNumeric< T, N >::CArrayNumeric ( const ARRAYLIKE &  obj  )  [inline, explicit]

Initialization from a vector-like source, that is, anything implementing operator[].

Definition at line 360 of file CArray.h.


Member Function Documentation

template<typename T, std::size_t N>
mrpt_autotype& mrpt::math::CArrayNumeric< T, N >::Abs (  )  [inline]

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
void mrpt::math::CArrayNumeric< T, N >::adjustRange ( const T  min_val,
const T  max_val 
) [inline]
Parameters:
max_val Normalize all the elements such as they are in the given range

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
template<class F >
mrpt_autotype& mrpt::math::CArrayNumeric< T, N >::applyToAllElements ( T(*)(T)  function  )  [inline]

Applies a generic operation "T func(T val)" to all the elements.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
template<class CONTAINER2 >
size_t mrpt::math::CArrayNumeric< T, N >::countCommonElements ( const CONTAINER2 &  b  )  const [inline]

Counts the number of elements that appear in both containers (comparison through the == operator).

It is assumed that no repeated elements appear within each of the containers.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
size_t mrpt::math::CArrayNumeric< T, N >::countNonZero (  )  const [inline]

Count how many elements in a container are non-zero.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
template<class CONTAINEROUT >
void mrpt::math::CArrayNumeric< T, N >::cumsum ( CONTAINEROUT &  out  )  const [inline]

Cumsum of all the elements, saving in an output container

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
template<class CONTAINEROUT >
CONTAINEROUT mrpt::math::CArrayNumeric< T, N >::cumsum (  )  const [inline]

Cumsum of all the elements, returning a container of the given type, for example: CMatrixDouble m = mat.cumsum<CMatrixDouble>();

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
mrpt_autotype& mrpt::math::CArrayNumeric< T, N >::Exp (  )  [inline]

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
void mrpt::math::CArrayNumeric< T, N >::fill ( const T &  val  )  [inline]

Fill all the elements with a given value

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
std::vector<double> mrpt::math::CArrayNumeric< T, N >::histogram ( double  limit_min,
double  limit_max,
size_t  number_bins,
bool  do_normalization = false 
) const [inline]

Computes the normalized or normal histogram of a sequence of numbers given the number of bins and the limits.

In any case this is a "linear" histogram, i.e. for matrices, all the elements are taken as if they were a plain sequence, not taking into account they were in columns or rows.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
void mrpt::math::CArrayNumeric< T, N >::loadFromTextFileAsVector ( const std::string &  file  )  [inline]

Load this matrix or vector from a text file which can contain a column or row vector or a matrix, then assigns to this container all those elements in order (for example, a file with a 10x2 matrix can be loaded into a 20-length array)

Exceptions:
std::exception On any error.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
mrpt_autotype& mrpt::math::CArrayNumeric< T, N >::Log (  )  [inline]

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
T mrpt::math::CArrayNumeric< T, N >::maximum ( size_t *  maxIndex = NULL  )  const [inline]

Finds the maximum value (and the corresponding zero-based index).

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
double mrpt::math::CArrayNumeric< T, N >::mean (  )  const [inline]

Return the mean of the container (for matrices, as if it were a vector with all its elements).

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
void mrpt::math::CArrayNumeric< T, N >::meanAndStd ( double &  out_mean,
double &  out_std,
bool  unbiased = true 
) [inline]

Return the mean and standard deviation of all the elements in the container.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
T mrpt::math::CArrayNumeric< T, N >::minimum ( size_t *  minIndex = NULL  )  const [inline]

Finds the minimum value (and the corresponding zero-based index).

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
void mrpt::math::CArrayNumeric< T, N >::minimum_maximum ( T &  out_min,
T &  out_max,
size_t *  minIndex = NULL,
size_t *  maxIndex = NULL 
) const [inline]

Minimum and maximum of a vector at once

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
T mrpt::math::CArrayNumeric< T, N >::norm (  )  const [inline]

Return the norm of the container (for matrices, as if it were a vector with all its elements).

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
T mrpt::math::CArrayNumeric< T, N >::norm_inf ( size_t *  maxIndex = NULL  )  const [inline]

Compute the norm-infinite of a vector ($f[ ||{v}||_ $f]), ie the maximum absolute value of the elements.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
void mrpt::math::CArrayNumeric< T, N >::normalize ( const T  min_val = 0,
const T  max_val = 1 
) [inline]
Parameters:
max_val Normalize all the elements such as they are in the given range

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
CArrayNumeric<T,N>& mrpt::math::CArrayNumeric< T, N >::operator+= ( const CArrayNumeric< T, N > &  o  )  [inline]

Add: this+=other.

Definition at line 363 of file CArray.h.

template<typename T, std::size_t N>
CArrayNumeric<T,N>& mrpt::math::CArrayNumeric< T, N >::operator-= ( const CArrayNumeric< T, N > &  o  )  [inline]

Substract: this-=other.

Definition at line 369 of file CArray.h.

template<typename T, std::size_t N>
void mrpt::math::CArrayNumeric< T, N >::saveToTextFileAsVector ( const std::string &  file,
mrpt::math::TMatrixTextFileFormat  fileFormat = mrpt::math::MATRIX_FORMAT_ENG,
bool  asColumnVector = false 
) const [inline]

Save this matrix or vector to a text file as a row (or optionally as a vector), independently of this containers actually being a vector, an array or a matrix.

Exceptions:
std::exception On any error.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
mrpt_autotype& mrpt::math::CArrayNumeric< T, N >::Sqrt (  )  [inline]

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
mrpt_autotype& mrpt::math::CArrayNumeric< T, N >::Square (  )  [inline]

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
T mrpt::math::CArrayNumeric< T, N >::squareNorm (  )  const [inline]

Return the square norm of the container (for matrices, as if it were a vector with all its elements).

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
double mrpt::math::CArrayNumeric< T, N >::std ( bool  unbiased = true  )  const [inline]

Return the standard deviation of all the elements in the container.

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
T mrpt::math::CArrayNumeric< T, N >::sumAll (  )  const [inline]

Sum all the elements, returning a value of the same type than the container

Definition at line 352 of file CArray.h.

template<typename T, std::size_t N>
template<typename RET_TYPE >
RET_TYPE mrpt::math::CArrayNumeric< T, N >::sumAllRetType (  )  const [inline]

Sum all the elements, returning a value of a custom type (this could be used to avoid overflow with containers of integers)

Definition at line 352 of file CArray.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



Page generated by Doxygen 1.7.1 for MRPT 0.9.1 SVN:exported at Fri Aug 6 10:31:35 UTC 2010