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. More... | |
DistributedMatrix (const DistributedMatrix< T > &A, bool deepcopy=false) | |
Copy constructor copies dimensions, distribution, and shallow copy of content (unless deepcopy=true) More... | |
DistributedMatrix (const DistributedMatrixDistribution &d) | |
Constructs a distributed matrix with given distribution info. More... | |
virtual | ~DistributedMatrix () |
void | clear () |
Frees memory and resets state to same as default constructor. More... | |
void | copy_from_replicated (const Tensor< T > &s) |
Copy from the replicated (m,n) matrix into the distributed matrix. More... | |
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. More... | |
void | copy_to_replicated (Tensor< T > &s) const |
Copy from the distributed (m,n) matrix into the replicated matrix (collective call) More... | |
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) More... | |
Tensor< T > & | data () |
Returns reference to the local data. More... | |
const Tensor< T > & | data () const |
Returns const reference to data. More... | |
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. More... | |
void | fill (T value) |
Fills the matrix with a scalar. More... | |
void | fill_identity () |
T | get (int64_t i, int64_t j) const |
Gets element (i,j) if (i,j) is local, otherwise throws MadnessException. More... | |
template<typename R > | |
bool | has_same_dimension_and_distribution (const DistributedMatrix< R > &A) |
DistributedMatrix< T > & | operator*= (const T s) |
Inplace scale by a constant. More... | |
DistributedMatrix< T > | operator+ (const DistributedMatrix< T > &A) const |
Out of place addition — dimensions and distribution must be identical. More... | |
DistributedMatrix< T > & | operator+= (const DistributedMatrix< T > &A) |
Inplace addition — dimensions and distribution must be identical. More... | |
DistributedMatrix< T > & | operator= (const DistributedMatrix< T > &A) |
Assigment copies dimensions, distribution, and shallow copy of content. More... | |
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. More... | |
Public Member Functions inherited from madness::DistributedMatrixDistribution | |
DistributedMatrixDistribution () | |
Default constructor makes an invalid distribution. More... | |
virtual | ~DistributedMatrixDistribution () |
void | clear () |
Resets state to same as default constructor. More... | |
int64_t | coldim () const |
Returns the column dimension of the matrix ... i.e., n for A(n,m) More... | |
int64_t | coltile () const |
Returns the column tile size. More... | |
const DistributedMatrixDistribution & | distribution () const |
Returns the distribution (aka *this) More... | |
void | get_colrange (int p, int64_t &ilow, int64_t &ihigh) const |
Returns the inclusive range of column indices on processor p. More... | |
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. More... | |
void | get_rowrange (int p, int64_t &jlow, int64_t &jhigh) const |
Returns the inclusive range of row indices on processor p. More... | |
World & | get_world () const |
Returns the associated world. More... | |
bool | is_column_distributed () const |
Returns true if the matrix is column distributed (i.e., row dimension not distributed) More... | |
bool | is_row_distributed () const |
Returns true if the matrix is row distributed (i.e., column dimension not distributed) More... | |
int64_t | local_coldim () const |
Returns the no. of column elements stored on this processor. More... | |
void | local_colrange (int64_t &ilow, int64_t &ihigh) const |
Returns the inclusive range of column indices on this processor. More... | |
int64_t | local_ihigh () const |
Returns the last column index on this processor (-1 if no data present) More... | |
int64_t | local_ilow () const |
Returns the first column index on this processor (0 if no data present) More... | |
int64_t | local_jhigh () const |
Returns the last row index on this processor (0 if no data present) More... | |
int64_t | local_jlow () const |
Returns the first row index on this processor (0 if no data present) More... | |
int64_t | local_rowdim () const |
Returns the no. of row elements stored on this processor. More... | |
void | local_rowrange (int64_t &jlow, int64_t &jhigh) const |
Returns the inclusive range of row indices on this processor. More... | |
int64_t | local_size () const |
Returns the total no. of elements stored on this processor. More... | |
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) More... | |
int64_t | process_coldim () const |
Returns the no. of processors in the column dimension. More... | |
int64_t | process_rowdim () const |
Returns the no. of processors in the row dimension. More... | |
int64_t | rowdim () const |
Returns the row dimension of the matrix ... i.e., m for A(n,m) More... | |
int64_t | rowtile () const |
Returns the row tile size. More... | |
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. More... | |
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) More... | |
Static Private Member Functions | |
static T | idij (const int64_t i, const int64_t j) |
Private Attributes | |
Tensor< T > | t |
The data. More... | |
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. More... | |
DistributedMatrix< T > | interleave_rows (const DistributedMatrix< T > &a, const DistributedMatrix< T > &b) |
Generates a distributed matrix with rows of a and b interleaved. More... | |
Additional Inherited Members | |
Protected Attributes inherited from madness::DistributedMatrixDistribution | |
int64_t | idim |
int64_t | ihi |
Range of column indices on this processor. More... | |
int64_t | ilo |
int64_t | jdim |
Dimension of data on this processor. More... | |
int64_t | jhi |
Range of row indices on this processor. More... | |
int64_t | jlo |
int64_t | m |
Row dimension of A(n,m) More... | |
int64_t | n |
Column dimension of A(n,m) More... | |
int64_t | P |
No. of processors. More... | |
int64_t | Pcol |
Column of processor grid for this processor. More... | |
int64_t | Pcoldim |
Column dimension of processor grid. More... | |
int64_t | Prow |
Row of processor grid for this processor. More... | |
int64_t | Prowdim |
Row dimension of processor grid. More... | |
World * | pworld |
ProcessID | rank |
My processor rank. More... | |
int64_t | tilem |
Tile size for row. More... | |
int64_t | tilen |
Tile size for column. More... | |
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, max, 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(), madness::SCF::initial_guess(), and madness::Kinetic< T, NDIM >::operator()().
|
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, max, madness::WorldGopInterface::sum(), and madness::DistributedMatrix< T >::t.
|
inline |
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().
|
inline |
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, max, 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 A(), 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 >::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 >::extract_columns(), 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().