Public Types | |
typedef boost::multi_array< T, D > | BMA |
typedef boost::multi_array_types::index | index |
typedef boost::multi_array_types::size_type | size_type |
typedef MultiArray< T, D > | This |
Public Member Functions | |
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. | |
template<typename T1 > | |
T | compute_max (T1 &max_idx) const |
Maximum of the values in the array. | |
T | compute_max () const |
Maximum of the values in the array. | |
template<typename T1 > | |
T | compute_min (T1 &min_idx) const |
Minimum of the values in the array. | |
T | compute_min () 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) |
template<typename U > | |
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. | |
template<typename T1 > | |
bool | is_logical_element (T1 &v) const |
Returns true if the LOGICAL index belongs to those of the matrix. | |
template<typename T1 > | |
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. | |
MultiArray () | |
Empty constructor. | |
void | normalize () |
This | operator* (const T &v) const |
Multiplication operator for an array and a scalar. | |
This | operator* (const This &v) const |
Multiplication operator. | |
void | operator*= (const T &v) const |
Multiplication operator for an array and a scalar. | |
void | operator*= (const This &v) const |
Multiplication operator. | |
This | operator+ (const T &v) const |
Sum operator for an array and a scalar. | |
This | operator+ (const This &v) const |
Sum operator. | |
void | operator+= (const T &v) const |
Addition operator for an array and a scalar. | |
void | operator+= (const This &v) const |
Addition operator. | |
This | operator- (const T &v) const |
Minus operator for an array and a scalar. | |
This | operator- (const This &v) const |
Minus operator. | |
void | operator-= (const T &v) const |
Substraction operator for an array and a scalar. | |
void | operator-= (const This &v) const |
Substraction operator. | |
This | operator/ (const T &v) const |
Division operator for an array and a scalar. | |
This | operator/ (const This &v) const |
Division operator. | |
void | operator/= (const T &v) const |
Division operator for an array and a scalar. | |
void | operator/= (const This &v) const |
Division operator. | |
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 (std::ifstream &in, bool reversed=false) |
Read from a input stream in binary mode. | |
void | read_binary (const std::string &filename, bool reversed=false) |
Read from a binary file. | |
template<typename T1 > | |
bool | same_shape (const MultiArray< T1, D > &b) const |
Compares the shape of two multidimensional arrays. | |
template<typename T1 > | |
bool | same_size (const MultiArray< T1, D > &b) const |
Compares the size of two multidimensional arrays. | |
template<typename T1 > | |
bool | same_start (const MultiArray< T1, D > &b) const |
Compares the origin of two multidimensional arrays. | |
template<typename T1 > | |
void | set_start (const T1 &v) |
void | set_start (const int dim, const int value) |
T | squared_difference (const This &v) const |
T | sum_elements () const |
Computes the sum of all the array elements. | |
T | sum_squared_elements () const |
void | write (const std::string &filename) const |
Write to an ASCII file. | |
void | write_binary (std::ofstream &out, bool reversed=false) |
Write to a output stream in binary mode. | |
void | write_binary (const std::string &filename, bool reversed=false) |
Write to a binary file. | |
Friends | |
std::istream & | operator>> (std::istream &in, This &v) |
Related Functions | |
(Note that these are not member functions.) | |
template<class T , int D> | |
MultiArray< T, D > | operator* (const T &X, const MultiArray< T, D > &a1) |
Multiplication operator for a scalar and an array. | |
template<class T , int D> | |
MultiArray< T, D > | operator+ (const T &X, const MultiArray< T, D > &a1) |
Sum operator for a scalar and an array. | |
template<class T , int D> | |
MultiArray< T, D > | operator- (const T &X, const MultiArray< T, D > &a1) |
Minus operator for a scalar and an array. | |
template<class T , int D> | |
MultiArray< T, D > | operator/ (const T &X, const MultiArray< T, D > &a1) |
Division operator for a scalar and an array. |
void IMP::algebra::MultiArray< T, D >::centered_start | ( | ) |
Sets the zero (0,0,0,...) of the logical coordinates at the center of the center of the matrix. Some examples:
m.centered_start(); // if m is a 5x4 matrix, the origin will be (-2,-2) m.centered_start(); // if m is a 16x3 matrix, the origin will be (-8,-1)
double IMP::algebra::MultiArray< T, D >::compute_avg | ( | ) | const |
Average of the values in the array.
The returned value is always double, independently of the type of the array.
T IMP::algebra::MultiArray< T, D >::compute_max | ( | T1 & | max_idx | ) | const |
Maximum of the values in the array.
[out] | max_idx | index containing the maximum value |
T IMP::algebra::MultiArray< T, D >::compute_min | ( | T1 & | min_idx | ) | const |
Minimum of the values in the array.
[out] | min_idx | index containing the minimum value |
void IMP::algebra::MultiArray< T, D >::copy | ( | This & | v | ) |
Copies the contents of a MultiArray to this one (no resizing is done). For copying with resizing use operator=
[in] | v | MultiArray whose contents to copy |
double IMP::algebra::MultiArray< T, D >::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.
[in] | v | array to compute the cross_correlation with. |
[in] | apply_threshold | true if a threshold is applied to the elements of v . |
[in] | threshold | minimum value for an element v to consider it in the computation . |
[in] | divide_by_stddev | true if the cross correlation term is divided by the standard deviation to get the cross correlation coefficient (0 <= ccc <= 1). |
[in] | force_recalc_stats | true if the statistics (mean, stddev) for the Multiarrays must be recalculated (default). If the statistics are known from previous computations, you can speed up the next computations setting this variable to false and directly providing the parameters. |
[in] | avg | average of this Multiarray. |
[in] | stddev | standard deviation of this Multiarray. |
[in] | avg_v | average of Multiarray v. |
[in] | stddev_v | standard deviation of Multiarray v. |
int IMP::algebra::MultiArray< T, D >::get_finish | ( | const int | dim | ) | const |
Another way of asking for the final value (logical) for the index of the dimension
int IMP::algebra::MultiArray< T, D >::get_size | ( | const int | dim | ) | const |
Another way of asking for the size of a given dimension. You can always use x.shape()[i] too.
int IMP::algebra::MultiArray< T, D >::get_start | ( | const int | dim | ) | const |
Another way of asking for the initial value (logical) for the index of the dimension. You can always use index_bases()[dim]
bool IMP::algebra::MultiArray< T, D >::is_logical_element | ( | T1 & | v | ) | const |
Returns true if the LOGICAL index belongs to those of the matrix.
[in] | v | Any class able to be accessed with [] |
bool IMP::algebra::MultiArray< T, D >::is_physical_element | ( | T1 & | v | ) | const |
Returns true if the PHYSICAL index belongs to those of the matrix.
[in] | v | Any class able to be accessed with [] |
void IMP::algebra::MultiArray< T, D >::normalize | ( | ) |
Normalize the values of the MultiArray to mean value 0 and standard deviation 1.
void IMP::algebra::MultiArray< T, D >::print_shape | ( | std::ostream & | out = std::cout |
) | const |
Print shape of multidimensional array.
This function shows the size, starting and finishing indexes of the given array. No end of line is printed neither at the beginning nor the end.
void IMP::algebra::MultiArray< T, D >::read | ( | const std::string & | filename | ) |
Read from an ASCII file.
The array must be previously resized to the correct size.
void IMP::algebra::MultiArray< T, D >::read_binary | ( | std::ifstream & | in, | |
bool | reversed = false | |||
) |
Read from a input stream in binary mode.
The array must be previously resized to the correct size.
void IMP::algebra::MultiArray< T, D >::read_binary | ( | const std::string & | filename, | |
bool | reversed = false | |||
) |
Read from a binary file.
The array must be previously resized to the correct size.
bool IMP::algebra::MultiArray< T, D >::same_shape | ( | const MultiArray< T1, D > & | b | ) | const |
Compares the shape of two multidimensional arrays.
bool IMP::algebra::MultiArray< T, D >::same_size | ( | const MultiArray< T1, D > & | b | ) | const |
Compares the size of two multidimensional arrays.
bool IMP::algebra::MultiArray< T, D >::same_start | ( | const MultiArray< T1, D > & | b | ) | const |
Compares the origin of two multidimensional arrays.
void IMP::algebra::MultiArray< T, D >::set_start | ( | const T1 & | v | ) |
Another way setting the initial value (logical) for the index of the dimension.
[in] | v | Any class able to be accessed with [] |
void IMP::algebra::MultiArray< T, D >::set_start | ( | const int | dim, | |
const int | value | |||
) |
Another way setting the initial value (logical) for the index of the dimension. You can always use reindex()
T IMP::algebra::MultiArray< T, D >::squared_difference | ( | const This & | v | ) | const |
Computes the sum of the squared elements of the difference MultiArray obtained from substracting v.
T IMP::algebra::MultiArray< T, D >::sum_squared_elements | ( | ) | const |
Computes the sum of all the squared elements of the array. (Frobenius norm)
MultiArray< T, D > operator* | ( | const T & | X, | |
const MultiArray< T, D > & | a1 | |||
) | [related] |
Multiplication operator for a scalar and an array.
MultiArray< T, D > operator+ | ( | const T & | X, | |
const MultiArray< T, D > & | a1 | |||
) | [related] |
Sum operator for a scalar and an array.
MultiArray< T, D > operator- | ( | const T & | X, | |
const MultiArray< T, D > & | a1 | |||
) | [related] |
Minus operator for a scalar and an array.
MultiArray< T, D > operator/ | ( | const T & | X, | |
const MultiArray< T, D > & | a1 | |||
) | [related] |
Division operator for a scalar and an array.