IMP logo
Public Types | Public Member Functions | Friends
IMP::algebra::Matrix3D< T > Class Template Reference

Detailed Description

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

Template class for managing 3D matrices. This class is based on boost multi_array. This class is primarily aimed at providing support for 3D bitmap images. See GridD for general spatial grids if that is what you are after.

Check MultiArray class for a list of added functionality

+ Inheritance diagram for IMP::algebra::Matrix3D< T >:

List of all members.

Public Types

typedef
boost::multi_array_types::index 
index
typedef MultiArray< T, 3 > MA3
typedef Matrix3D< T > This
- Public Types inherited from IMP::algebra::MultiArray< T, 3 >
typedef boost::multi_array< T, D > BMA
typedef
boost::multi_array_types::size_type 
size_type

Public Member Functions

 Matrix3D ()
 Empty constructor.
 Matrix3D (int Zdim, int Ydim, int Xdim)
 Constructor.
 Matrix3D (const This &v)
template<typename T1 >
void cast_values (Matrix3D< T1 > &out)
 Cast values.
bool get_is_valid () const
std::string get_name () const
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.
int get_number_of_slices () const
 Returns the number of slices in the matrix.
T & operator() (int k, int j, int i) const
template<typename T1 >
T & operator() (T1 &idx) const
This operator* (const This &v) const
 Multiplication operator.
This operator* (const T &v) const
 Multiplication operator for an array and a scalar.
Thisoperator*= (const This &v)
 Multiplication operator.
Thisoperator*= (const T &v)
 Multiplication operator for an array and a scalar.
This operator+ (const This &v) const
 Sum operator.
This operator+ (const T &v) const
 Sum operator for an array and a scalar.
Thisoperator+= (const This &v)
 Addition operator.
Thisoperator+= (const T &v)
 Addition operator for an array and a scalar.
This operator- (const This &v) const
 Minus operator.
This operator- (const T &v) const
 Minus operator for an array and a scalar.
Thisoperator-= (const This &v)
 Substraction operator.
Thisoperator-= (const T &v)
 Substraction operator for an array and a scalar.
This operator/ (const This &v) const
 Division operator.
This operator/ (const T &v) const
 Division operator for an array and a scalar.
Thisoperator/= (const This &v)
 Division operator.
Thisoperator/= (const T &v)
 Division operator for an array and a scalar.
void operator= (const This &v)
void pad (This &padded, T val)
void pad (This &padded)
template<typename T1 >
void reshape (const Matrix3D< T1 > &v)
 Reshapes the matrix copying the size and range of a given one.
void resize (int Zdim, int Ydim, int Xdim)
 Resizes the matrix.
template<typename T1 >
void resize (const Matrix3D< T1 > &v)
 Resizes the matrix copying the size of a given one.
void show (std::ostream &out=std::cout) const
- Public Member Functions inherited from IMP::algebra::MultiArray< T, 3 >
 MultiArray ()
 Empty constructor.
bool almost_equal (const double a, const double b, const double epsilon)
void centered_start ()
double compute_avg () const
 Average of the values in the array.
compute_max () const
 Maximum of the values in the array.
compute_max (T1 &max_idx) const
 Maximum of the values in the array.
compute_min () const
 Minimum of the values in the array.
compute_min (T1 &min_idx) const
 Minimum of the values in the array.
void compute_stats (double &avg, double &stddev, T &minval, T &maxval) const
 Compute average, standard deviation, minimum and maximum values.
double compute_stddev () const
 Standard deviation of the values in the array.
void copy (This &v)
void copy_with_casting (MultiArray< U, D > &v)
 Copy with casting. Use with care!
double cross_correlation_coefficient (const This &v, bool apply_threshold=false, double threshold=0.0, bool divide_by_stddev=true, bool force_recalc_stats=true, double avg=0.0, double stddev=0.0, double avg_v=0.0, double stddev_v=0.0)
 Computes the cross correlation coeffcient between two MultiArrays.
void fill_with_value (T val=0)
 Fill all the voxels of the array with a given value.
bool first_element () const
 Returns the first element.
int get_finish (const int dim) const
int get_size (const int dim) const
int get_start (const int dim) const
void init_zeros ()
 All the values of the array are set to zero.
bool is_logical_element (T1 &v) const
 Returns true if the LOGICAL index belongs to those of the matrix.
bool is_physical_element (T1 &v) const
 Returns true if the PHYSICAL index belongs to those of the matrix.
bool is_void () const
 Check if the array has some dimensionality or is just empty.
void normalize ()
This operator* (const This &v) const
 Multiplication operator.
void operator*= (const This &v) const
 Multiplication operator.
void operator*= (const T &v) const
 Multiplication operator for an array and a scalar.
This operator+ (const This &v) const
 Sum operator.
void operator+= (const This &v) const
 Addition operator.
void operator+= (const T &v) const
 Addition operator for an array and a scalar.
This operator- (const This &v) const
 Minus operator.
void operator-= (const This &v) const
 Substraction operator.
void operator-= (const T &v) const
 Substraction operator for an array and a scalar.
This operator/ (const This &v) const
 Division operator.
void operator/= (const This &v) const
 Division operator.
void operator/= (const T &v) const
 Division operator for an array and a scalar.
void print_shape (std::ostream &out=std::cout) const
 Print shape of multidimensional array.
void read (const std::string &filename)
 Read from an ASCII file.
void read_binary (const std::string &filename, bool reversed=false)
 Read from a binary file.
void read_binary (std::ifstream &input, bool reversed=false)
 Read from a input stream in binary mode.
bool same_shape (const MultiArray< T1, D > &b) const
 Compares the shape of two multidimensional arrays.
bool same_size (const MultiArray< T1, D > &b) const
 Compares the size of two multidimensional arrays.
bool same_start (const MultiArray< T1, D > &b) const
 Compares the origin of two multidimensional arrays.
void set_start (const int dim, const int value)
void set_start (const T1 &v)
squared_difference (const This &v) const
sum_elements () const
 Computes the sum of all the array elements.
sum_squared_elements () const
void write (const std::string &filename) const
 Write to an ASCII file.
void write_binary (const std::string &filename, bool reversed=false)
 Write to a binary file.
void write_binary (std::ofstream &out, bool reversed=false)
 Write to a output stream in binary mode.

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.

Constructor & Destructor Documentation

template<typename T>
IMP::algebra::Matrix3D< T >::Matrix3D ( )

Empty constructor.

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

Constructor.


Member Function Documentation

template<typename T>
template<typename T1 >
void IMP::algebra::Matrix3D< T >::cast_values ( Matrix3D< T1 > &  out)

Cast values.

template<typename T>
int IMP::algebra::Matrix3D< T >::get_number_of_columns ( ) const

Returns the number of columns in the matrix.

template<typename T>
int IMP::algebra::Matrix3D< T >::get_number_of_rows ( ) const

Returns the number of rows in the matrix.

template<typename T>
int IMP::algebra::Matrix3D< T >::get_number_of_slices ( ) const

Returns the number of slices in the matrix.

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

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

Parameters:
[in]kfirst index
[in]jsecond index
[in]ithird index
template<typename T>
template<typename T1 >
T& IMP::algebra::Matrix3D< T >::operator() ( T1 &  idx) const

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

Parameters:
[in]idxmust be a class supporting access via []
template<typename T>
This IMP::algebra::Matrix3D< T >::operator* ( const This v) const

Multiplication operator.

template<typename T>
This IMP::algebra::Matrix3D< T >::operator* ( const T &  v) const

Multiplication operator for an array and a scalar.

Reimplemented from IMP::algebra::MultiArray< T, 3 >.

template<typename T>
This& IMP::algebra::Matrix3D< T >::operator*= ( const This v)

Multiplication operator.

template<typename T>
This& IMP::algebra::Matrix3D< T >::operator*= ( const T &  v)

Multiplication operator for an array and a scalar.

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

Sum operator.

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

Sum operator for an array and a scalar.

Reimplemented from IMP::algebra::MultiArray< T, 3 >.

template<typename T>
This& IMP::algebra::Matrix3D< T >::operator+= ( const This v)

Addition operator.

template<typename T>
This& IMP::algebra::Matrix3D< T >::operator+= ( const T &  v)

Addition operator for an array and a scalar.

template<typename T>
This IMP::algebra::Matrix3D< T >::operator- ( const This v) const

Minus operator.

template<typename T>
This IMP::algebra::Matrix3D< T >::operator- ( const T &  v) const

Minus operator for an array and a scalar.

Reimplemented from IMP::algebra::MultiArray< T, 3 >.

template<typename T>
This& IMP::algebra::Matrix3D< T >::operator-= ( const This v)

Substraction operator.

template<typename T>
This& IMP::algebra::Matrix3D< T >::operator-= ( const T &  v)

Substraction operator for an array and a scalar.

template<typename T>
This IMP::algebra::Matrix3D< T >::operator/ ( const This v) const

Division operator.

template<typename T>
This IMP::algebra::Matrix3D< T >::operator/ ( const T &  v) const

Division operator for an array and a scalar.

Reimplemented from IMP::algebra::MultiArray< T, 3 >.

template<typename T>
This& IMP::algebra::Matrix3D< T >::operator/= ( const This v)

Division operator.

template<typename T>
This& IMP::algebra::Matrix3D< T >::operator/= ( const T &  v)

Division operator for an array and a scalar.

template<typename T>
void IMP::algebra::Matrix3D< 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]paddedthe output MultiArray
[in]valthe value to pad with
template<typename T>
void IMP::algebra::Matrix3D< 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]paddedthe MultiArray padded
template<typename T>
template<typename T1 >
void IMP::algebra::Matrix3D< T >::reshape ( const Matrix3D< T1 > &  v)

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

Parameters:
[in]vMatrix3D whose shape to copy
template<typename T>
void IMP::algebra::Matrix3D< T >::resize ( int  Zdim,
int  Ydim,
int  Xdim 
)

Resizes the matrix.

Parameters:
[in]ZdimNumber of slices
[in]YdimNumber of rows
[in]XdimNumber of columns
template<typename T>
template<typename T1 >
void IMP::algebra::Matrix3D< T >::resize ( const Matrix3D< T1 > &  v)

Resizes the matrix copying the size of a given one.

Parameters:
[in]vMatrix3D whose size to copy

Friends And Related Function Documentation

template<typename T>
This operator* ( const T &  X,
const This a1 
)
friend

Multiplication operator for a scalar and an array.

template<typename T>
This operator+ ( const T &  X,
const This a1 
)
friend

Sum operator for a scalar and an array.

template<typename T>
This operator- ( const T &  X,
const This a1 
)
friend

Minus operator for a scalar and an array.

template<typename T>
This operator/ ( const T &  X,
const This a1 
)
friend

Division operator for a scalar and an array.


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

Generated on Tue May 22 2012 23:33:25 for IMP by doxygen 1.8.1