IMP logo

IMP::algebra::Matrix2D< T > Class Template Reference


Detailed Description

template<typename T>
class IMP::algebra::Matrix2D< T >

Template class for managing 2D matrices. This class is based on boost multi_array Check MultiArray class for a list of added functionality
Inheritance diagram for IMP::algebra::Matrix2D< T >:

Inheritance graph
[legend]

Public Types

typedef
boost::multi_array_types::index 
index
typedef MultiArray< T, 2 > MA2
typedef Matrix2D< T > This

Public Member Functions

template<typename T1 >
void cast_values (Matrix2D< T1 > &out)
 Cast values.
double det () const
 Determinant (only for 2x2).
int get_number_of_columns () const
 Returns the number of columns in the matrix.
int get_number_of_rows () const
 Returns the number of rows in the matrix.
bool is_square () const
 Matrix2D (const This &v)
 Copy constructor.
 Matrix2D (int Ydim, int Xdim)
 Constructor.
 Matrix2D ()
 Empty constructor.
template<typename T1 >
T & operator() (T1 &idx) const
T & operator() (int j, int i) const
This operator* (const T &v) const
 Multiplication operator for an array and a scalar.
This operator* (const This &v) const
 Multiplication operator (element by element).
Thisoperator*= (const T &v)
 Multiplication operator for an array and a scalar.
Thisoperator*= (const This &v)
 Multiplication operator.
This operator+ (const T &v) const
 Sub operator for an array and a scalar.
This operator+ (const This &v) const
 Sum operator.
Thisoperator+= (const T &v)
 Addition operator for an array and a scalar.
Thisoperator+= (const This &v)
 Addition operator.
This operator- (const T &v) const
 Minus operator for an array and a scalar.
This operator- (const This &v) const
 Minus operator.
Thisoperator-= (const T &v)
 Substraction operator for an array and a scalar.
Thisoperator-= (const This &v)
 Subtraction operator.
This operator/ (const T &v) const
 Division operator for an array and a scalar.
This operator/ (const This &v) const
 Division operator (element by element).
Thisoperator/= (const T &v)
 Division operator for an array and a scalar.
Thisoperator/= (const This &v)
 Division operator.
void operator= (const This &v)
void pad (This &padded)
void pad (This &padded, T val)
T & physical_get (const int j, const int i) const
 Physicial access to the elements of the matrix.
void physical_set (const int j, const int i, const T &val)
 Physicial set of the elements of the matrix.
template<typename T1 >
void reshape (const Matrix2D< T1 > &v)
 Reshapes the matrix copying the size and range of a given one.
template<typename T1 >
void resize (const Matrix2D< T1 > &m2)
 Resizes the matrix copying the size of a given one.
void resize (int Ydim, int Xdim)
 Resizes the matrix.
void set_identity ()
 Set the matrix to be an indentity matrix.
void set_zero ()
 Set the matrix to be a zero matrix.
void show (std::ostream &o=std::cout) const
This transpose ()

Friends

This operator* (const T &X, const This &a1)
 Multiplication operator for a scalar and an array.
This operator+ (const T &X, const This &a1)
 Sum operator for a scalar and an array.
This operator- (const T &X, const This &a1)
 Minus operator for a scalar and an array.
This operator/ (const T &X, const This &a1)
 Division operator for a scalar and an array.

Related Functions

(Note that these are not member functions.)

double bilinear_interpolation (Matrix2D< double > &m, VectorD< 2 > &idx, bool wrap=false, double outside=0.0)
double interpolate (algebra::Matrix2D< double > &m, VectorD< 2 > &idx, bool wrap=false, double outside=0.0, int interp=0)
 General function to call in case of interpolation in 2D matrices.

Constructor & Destructor Documentation

template<typename T>
IMP::algebra::Matrix2D< T >::Matrix2D ( int  Ydim,
int  Xdim 
)

Constructor.

Parameters:
[in] Ydim Number of rows
[in] Xdim Number of columns


Member Function Documentation

template<typename T>
template<typename T1 >
T& IMP::algebra::Matrix2D< T >::operator() ( T1 &  idx  )  const

Access operator. The returned element is the LOGICAL element of the matrix, NOT the direct one

Parameters:
[in] idx must be a class supporting access via []

template<typename T>
T& IMP::algebra::Matrix2D< T >::operator() ( int  j,
int  i 
) const

Access operator. The returned element is the LOGICAL element of the matrix, NOT the direct one

Parameters:
[in] j Row to access
[in] i Column to access

template<typename T>
This IMP::algebra::Matrix2D< T >::operator+ ( const This v  )  const

Sum operator.

Parameters:
[in] v The matrix to add

template<typename T>
void IMP::algebra::Matrix2D< T >::pad ( This padded  ) 

Pad the MultiArray. Padding is defined as doubling the size in each dimension and fill the new values with the previous average value.

Parameters:
[in] padded the MultiArray padded

template<typename T>
void IMP::algebra::Matrix2D< T >::pad ( This padded,
val 
)

Pad with a given value. Padding is defined as doubling the size in each dimension and fill the new values with the value.

Parameters:
[out] padded the output MultiArray
[in] val the value to pad with

template<typename T>
T& IMP::algebra::Matrix2D< T >::physical_get ( const int  j,
const int  i 
) const

Physicial access to the elements of the matrix.

Parameters:
[in] j physical row to access
[in] i physical Column to access

template<typename T>
void IMP::algebra::Matrix2D< T >::physical_set ( const int  j,
const int  i,
const T &  val 
)

Physicial set of the elements of the matrix.

Parameters:
[in] j physical row to access
[in] i physical Column to access
[in] val the value to set

template<typename T>
template<typename T1 >
void IMP::algebra::Matrix2D< T >::reshape ( const Matrix2D< T1 > &  v  ) 

Reshapes the matrix copying the size and range of a given one.

Parameters:
[in] v Matrix2D whose shape to copy

template<typename T>
template<typename T1 >
void IMP::algebra::Matrix2D< T >::resize ( const Matrix2D< T1 > &  m2  ) 

Resizes the matrix copying the size of a given one.

Parameters:
[in] m2 Matrix2D whose size to copy

template<typename T>
void IMP::algebra::Matrix2D< T >::resize ( int  Ydim,
int  Xdim 
)

Resizes the matrix.

Parameters:
[in] Ydim Number of rows
[in] Xdim Number of columns

template<typename T>
This IMP::algebra::Matrix2D< T >::transpose (  ) 

Returns a matrix with this matrix transposed. The original one is not modified


Friends And Related Function Documentation

template<typename T>
double bilinear_interpolation ( Matrix2D< double > &  m,
VectorD< 2 > &  idx,
bool  wrap = false,
double  outside = 0.0 
) [related]

Performs bilinear interpolation for a point using the 4 closest values in the matrix

Parameters:
[in] m the Matrix (2D)
[in] idx must be a class supporting access via []. It must have 2 elements.
[in] wrap if true, the image is wrapped and values from the right are used when the left limit is excedeed, and viceversa. Same thing is done between top and bottom.
[in] outside Value to apply if the requested idx falls outside the limits of the matrix. (It is never used if wrap is requested)

template<typename T>
double interpolate ( algebra::Matrix2D< double > &  m,
VectorD< 2 > &  idx,
bool  wrap = false,
double  outside = 0.0,
int  interp = 0 
) [related]

General function to call in case of interpolation in 2D matrices.

Parameters:
[in] m the Matrix (2D)
[in] idx must be a class supporting access via [] and must have 2 elements.
[in] wrap If true, the matrix is wrapped: values from the right are used when the left limit is excedeed, and viceversa. Same thing for other dimensions.
[in] outside Value to apply if the requested idx falls outside the limits of the matrix. (Never used if wrap is requested)
[in] interp type of interpolation desired. Right now it is only bilinear interpolation


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

Generated on Mon Mar 8 23:08:47 2010 for IMP by doxygen 1.5.8