MADNESS 0.10.1
|
Manages data associated with a row/column/block distributed array. More...
#include <distributed_matrix.h>
Public Member Functions | |
DistributedMatrix () | |
Default constructor makes an empty matrix that cannot be used except as a target for assignemnt. | |
DistributedMatrix (const DistributedMatrix< T > &A, bool deepcopy=false) | |
Copy constructor copies dimensions, distribution, and shallow copy of content (unless deepcopy=true) | |
DistributedMatrix (const DistributedMatrixDistribution &d) | |
Constructs a distributed matrix with given distribution info. | |
virtual | ~DistributedMatrix () |
void | clear () |
Frees memory and resets state to same as default constructor. | |
void | copy_from_replicated (const Tensor< T > &s) |
Copy from the replicated (m,n) matrix into the distributed matrix. | |
void | copy_from_replicated_patch (int64_t ilow, int64_t ihigh, int64_t jlow, int64_t jhigh, const Tensor< T > &s) |
Copy from replicated patch (inclusive index range) into the distributed matrix. | |
void | copy_to_replicated (Tensor< T > &s) const |
Copy from the distributed (m,n) matrix into the replicated matrix (collective call) | |
void | copy_to_replicated_patch (int64_t ilow, int64_t ihigh, int64_t jlow, int64_t jhigh, Tensor< T > &s) const |
Copy from distributed matrix into replicated patch (inclusive index range; collective call) | |
Tensor< T > & | data () |
Returns reference to the local data. | |
const Tensor< T > & | data () const |
Returns const reference to data. | |
void | extract_columns (int64_t jlow, int64_t jhigh, DistributedMatrix< T > &U) const |
template<typename funcT > | |
void | fill (const funcT &f) |
Fills the matrix with the provided function of the indices. | |
void | fill (T value) |
Fills the matrix with a scalar. | |
void | fill_identity () |
T | get (int64_t i, int64_t j) const |
Gets element (i,j) if (i,j) is local, otherwise throws MadnessException. | |
template<typename R > | |
bool | has_same_dimension_and_distribution (const DistributedMatrix< R > &A) |
DistributedMatrix< T > & | operator*= (const T s) |
Inplace scale by a constant. | |
DistributedMatrix< T > | operator+ (const DistributedMatrix< T > &A) const |
Out of place addition — dimensions and distribution must be identical. | |
DistributedMatrix< T > & | operator+= (const DistributedMatrix< T > &A) |
Inplace addition — dimensions and distribution must be identical. | |
DistributedMatrix< T > & | operator= (const DistributedMatrix< T > &A) |
Assigment copies dimensions, distribution, and shallow copy of content. | |
void | set (int64_t i, int64_t j, const T x) |
Sets element (i,j) to v if (i,j) is local, otherwise throws MadnessException. | |
Public Member Functions inherited from madness::DistributedMatrixDistribution | |
DistributedMatrixDistribution () | |
Default constructor makes an invalid distribution. | |
virtual | ~DistributedMatrixDistribution () |
void | clear () |
Resets state to same as default constructor. | |
int64_t | coldim () const |
Returns the column dimension of the matrix ... i.e., n for A(n,m) | |
int64_t | coltile () const |
Returns the column tile size. | |
const DistributedMatrixDistribution & | distribution () const |
Returns the distribution (aka *this) | |
void | get_colrange (int p, int64_t &ilow, int64_t &ihigh) const |
Returns the inclusive range of column indices on processor p. | |
void | get_range (int p, int64_t &ilow, int64_t &ihigh, int64_t &jlow, int64_t &jhigh) const |
Returns the inclusive ranges of column and row indicies on processor p. | |
void | get_rowrange (int p, int64_t &jlow, int64_t &jhigh) const |
Returns the inclusive range of row indices on processor p. | |
World & | get_world () const |
Returns the associated world. | |
bool | is_column_distributed () const |
Returns true if the matrix is column distributed (i.e., row dimension not distributed) | |
bool | is_row_distributed () const |
Returns true if the matrix is row distributed (i.e., column dimension not distributed) | |
int64_t | local_coldim () const |
Returns the no. of column elements stored on this processor. | |
void | local_colrange (int64_t &ilow, int64_t &ihigh) const |
Returns the inclusive range of column indices on this processor. | |
int64_t | local_ihigh () const |
Returns the last column index on this processor (-1 if no data present) | |
int64_t | local_ilow () const |
Returns the first column index on this processor (0 if no data present) | |
int64_t | local_jhigh () const |
Returns the last row index on this processor (0 if no data present) | |
int64_t | local_jlow () const |
Returns the first row index on this processor (0 if no data present) | |
int64_t | local_rowdim () const |
Returns the no. of row elements stored on this processor. | |
void | local_rowrange (int64_t &jlow, int64_t &jhigh) const |
Returns the inclusive range of row indices on this processor. | |
int64_t | local_size () const |
Returns the total no. of elements stored on this processor. | |
bool | operator== (const DistributedMatrixDistribution &d) const |
ProcessID | owner (int64_t i, int64_t j) const |
Returns the number of the process that owns element (i,j) | |
int64_t | process_coldim () const |
Returns the no. of processors in the column dimension. | |
int64_t | process_rowdim () const |
Returns the no. of processors in the row dimension. | |
int64_t | rowdim () const |
Returns the row dimension of the matrix ... i.e., m for A(n,m) | |
int64_t | rowtile () const |
Returns the row tile size. | |
Protected Member Functions | |
DistributedMatrix (World &world, int64_t n, int64_t m, int64_t coltile, int64_t rowtile) | |
Constructs a distributed matrix dimension (n,m) with specified tile sizes and initialized to zero. | |
Protected Member Functions inherited from madness::DistributedMatrixDistribution | |
DistributedMatrixDistribution (World &world, int64_t n, int64_t m, int64_t coltile, int64_t rowtile) | |
Constructs distribution and size info for a matrix (for use by factory functions only) | |
Static Private Member Functions | |
static T | idij (const int64_t i, const int64_t j) |
Private Attributes | |
Tensor< T > | t |
The data. | |
Friends | |
DistributedMatrix< T > | concatenate_rows (const DistributedMatrix< T > &a, const DistributedMatrix< T > &b) |
Generates a column-distributed matrix with rows of a and b contatenated. | |
DistributedMatrix< T > | interleave_rows (const DistributedMatrix< T > &a, const DistributedMatrix< T > &b) |
Generates a distributed matrix with rows of a and b interleaved. | |
Additional Inherited Members | |
Protected Attributes inherited from madness::DistributedMatrixDistribution | |
int64_t | idim |
int64_t | ihi |
Range of column indices on this processor. | |
int64_t | ilo |
int64_t | jdim |
Dimension of data on this processor. | |
int64_t | jhi |
Range of row indices on this processor. | |
int64_t | jlo |
int64_t | m |
Row dimension of A(n,m) | |
int64_t | n |
Column dimension of A(n,m) | |
int64_t | P |
No. of processors. | |
int64_t | Pcol |
Column of processor grid for this processor. | |
int64_t | Pcoldim |
Column dimension of processor grid. | |
int64_t | Prow |
Row of processor grid for this processor. | |
int64_t | Prowdim |
Row dimension of processor grid. | |
World * | pworld |
ProcessID | rank |
My processor rank. | |
int64_t | tilem |
Tile size for row. | |
int64_t | tilen |
Tile size for column. | |
Manages data associated with a row/column/block distributed array.
The class itself provides limited functionality for accessing the data and is primarily intended to provide base functionality for use by matrix algorithms and other matrix classes.
The constructor is deliberately simple. Factory functions are expected to be the main construction tool.
Assignment and copy are shallow just like for tensor and for the same reasons.
To get a deep copy use the copy function (again just like for tensors).
|
inlineprotected |
Constructs a distributed matrix dimension (n,m) with specified tile sizes and initialized to zero.
[deprecated ... use factory functions instead]
The matrix is tiled over a grid of processes as specified by the tile sizes.
[in] | world | The world |
[in] | n | The matrix column dimension |
[in] | m | The matrix row dimension |
[in] | coltile | Tile size for the columns |
[in] | rowtile | Tile size for the rows |
References madness::DistributedMatrixDistribution::idim, madness::DistributedMatrixDistribution::jdim, and madness::DistributedMatrix< T >::t.
|
inline |
Default constructor makes an empty matrix that cannot be used except as a target for assignemnt.
|
inline |
Constructs a distributed matrix with given distribution info.
References madness::DistributedMatrixDistribution::idim, madness::DistributedMatrixDistribution::jdim, and madness::DistributedMatrix< T >::t.
|
inline |
Copy constructor copies dimensions, distribution, and shallow copy of content (unless deepcopy=true)
|
inlinevirtual |
|
inline |
Frees memory and resets state to same as default constructor.
References madness::DistributedMatrixDistribution::clear(), and madness::DistributedMatrix< T >::t.
|
inline |
Copy from the replicated (m,n) matrix into the distributed matrix.
[in] | s | The input tensor |
References madness::___, madness::DistributedMatrixDistribution::ihi, madness::DistributedMatrixDistribution::ilo, madness::DistributedMatrixDistribution::jhi, madness::DistributedMatrixDistribution::jlo, madness::DistributedMatrixDistribution::local_size(), and madness::DistributedMatrix< T >::t.
Referenced by madness::Localizer::localize_boys(), and madness::Localizer::localize_new().
|
inline |
Copy from replicated patch (inclusive index range) into the distributed matrix.
[in] | ilow | First i index in patch |
[in] | ihigh | Last i index in patch |
[in] | jlow | First j index in patch |
[in] | jhigh | Last j index in patch |
References madness::DistributedMatrixDistribution::ihi, madness::DistributedMatrixDistribution::ilo, madness::DistributedMatrixDistribution::jhi, madness::DistributedMatrixDistribution::jlo, and madness::DistributedMatrix< T >::t.
|
inline |
Copy from the distributed (m,n) matrix into the replicated matrix (collective call)
The entire output tensor is zeroed, the local data copied into it, and then a global sum performed to replicate the data.
[out] | s | The output tensor (assumed already allocated to be at least large enough in both dimensions) |
References madness::___, madness::DistributedMatrixDistribution::get_world(), madness::World::gop, madness::DistributedMatrixDistribution::ihi, madness::DistributedMatrixDistribution::ilo, madness::DistributedMatrixDistribution::jhi, madness::DistributedMatrixDistribution::jlo, madness::DistributedMatrixDistribution::local_size(), MADNESS_CHECK, madness::WorldGopInterface::sum(), and madness::DistributedMatrix< T >::t.
Referenced by madness::Localizer::compute_localization_matrix(), and madness::SCF::initial_guess().
|
inline |
Copy from distributed matrix into replicated patch (inclusive index range; collective call)
The entire output tensor is zeroed, relevant local data copied into it, and then a global sum performed to replicate the data.
[in] | ilow | First i index in patch |
[in] | ihigh | Last i index in patch |
[in] | jlow | First j index in patch |
[in] | jhigh | Last j index in patch |
References madness::DistributedMatrixDistribution::get_world(), madness::World::gop, madness::DistributedMatrixDistribution::ihi, madness::DistributedMatrixDistribution::ilo, madness::DistributedMatrixDistribution::jhi, madness::DistributedMatrixDistribution::jlo, MADNESS_CHECK, madness::WorldGopInterface::sum(), and madness::DistributedMatrix< T >::t.
Returns reference to the local data.
The local data is a tensor dimension (local_coldim,local_rowdim) and if either of the dimensions are zero there is no data. A natural way to loop thru the data that gives you the actual row and column indices is
References madness::DistributedMatrix< T >::t.
Referenced by madness::concatenate_rows(), and madness::DistributedMatrix< T >::extract_columns().
Returns const reference to data.
The local data is a tensor dimension (local_coldim,local_rowdim) and if either of the dimensions are zero there is no data. A natural way to loop thru the data that gives you the actual row and column indices is
References madness::DistributedMatrix< T >::t.
|
inline |
References madness::___, madness::DistributedMatrixDistribution::coldim(), madness::DistributedMatrixDistribution::coltile(), madness::DistributedMatrix< T >::data(), madness::DistributedMatrixDistribution::ihi, madness::DistributedMatrixDistribution::ilo, madness::DistributedMatrixDistribution::is_column_distributed(), madness::DistributedMatrixDistribution::jhi, madness::DistributedMatrixDistribution::jlo, MADNESS_CHECK, madness::DistributedMatrixDistribution::rowdim(), and madness::DistributedMatrix< T >::t.
Referenced by madness::distributed_localize_PM().
|
inline |
Fills the matrix with the provided function of the indices.
[in] | f | The matrix is filled using a [i,j]=f(i,j) |
References madness::f, madness::DistributedMatrixDistribution::ihi, madness::DistributedMatrixDistribution::ilo, madness::DistributedMatrixDistribution::jhi, madness::DistributedMatrixDistribution::jlo, and madness::DistributedMatrix< T >::t.
Referenced by madness::DistributedMatrix< T >::fill_identity().
|
inline |
Fills the matrix with a scalar.
[in] | value | The matrix is filled using a [i,j]=value |
References madness::DistributedMatrix< T >::t.
|
inline |
References madness::DistributedMatrix< T >::fill().
Referenced by madness::distributed_localize_PM().
|
inline |
Gets element (i,j) if (i,j) is local, otherwise throws MadnessException.
References madness::DistributedMatrixDistribution::ilo, madness::DistributedMatrixDistribution::jhi, madness::DistributedMatrixDistribution::jlo, MADNESS_CHECK, and madness::DistributedMatrix< T >::t.
|
inline |
|
inlinestaticprivate |
References T().
|
inline |
Inplace scale by a constant.
[in] | s | The scaling factor |
References madness::DistributedMatrix< T >::t.
|
inline |
Out of place addition — dimensions and distribution must be identical.
[in] | A | The matrix to add to the current matrix |
References madness::copy(), madness::DistributedMatrix< T >::has_same_dimension_and_distribution(), and MADNESS_CHECK.
|
inline |
Inplace addition — dimensions and distribution must be identical.
[in] | A | The matrix to add to the current matrix |
References madness::DistributedMatrix< T >::has_same_dimension_and_distribution(), MADNESS_CHECK, and madness::DistributedMatrix< T >::t.
|
inline |
Assigment copies dimensions, distribution, and shallow copy of content.
References madness::DistributedMatrix< T >::t.
|
inline |
Sets element (i,j) to v if (i,j) is local, otherwise throws MadnessException.
References madness::DistributedMatrixDistribution::ilo, madness::DistributedMatrixDistribution::jhi, madness::DistributedMatrixDistribution::jlo, MADNESS_CHECK, and madness::DistributedMatrix< T >::t.
|
friend |
Generates a column-distributed matrix with rows of a
and b
contatenated.
I.e., c[i,j] = a[i,j] if j<na or b[i,j-na] if j>=na
The matrices a and b must have the same column size (i.e., the same number of rows) and be column distributed with the same column tilesze. The result is also column distributed with the same column tilesize as the input matrices.
[in] | a | The first matrix |
[in] | b | The second matrix |
|
friend |
Generates a distributed matrix with rows of a
and b
interleaved.
I.e., the even rows of the result will be rows of a
, and the odd rows those of b
.
The matrices a and b must have the same dimensions and be identically distributed. The result will have a doubled column dimension and column tile size. The row dimension is unchanged.
[in] | a | The matrix providing even rows of the result |
[in] | b | The matrix providing odd rows of the result |
|
private |
The data.
Referenced by madness::DistributedMatrix< T >::DistributedMatrix(), madness::DistributedMatrix< T >::DistributedMatrix(), madness::DistributedMatrix< T >::clear(), madness::DistributedMatrix< T >::copy_from_replicated(), madness::DistributedMatrix< T >::copy_from_replicated_patch(), madness::DistributedMatrix< T >::copy_to_replicated(), madness::DistributedMatrix< T >::copy_to_replicated_patch(), madness::DistributedMatrix< T >::data(), madness::DistributedMatrix< T >::data(), madness::DistributedMatrix< T >::extract_columns(), madness::DistributedMatrix< T >::fill(), madness::DistributedMatrix< T >::fill(), madness::DistributedMatrix< T >::get(), madness::DistributedMatrix< T >::operator*=(), madness::DistributedMatrix< T >::operator+=(), madness::DistributedMatrix< T >::operator=(), and madness::DistributedMatrix< T >::set().