1 #ifndef MPQC_CI_SUBSPACE_HPP
2 #define MPQC_CI_SUBSPACE_HPP
4 #include <util/misc/formio.h>
5 #include "mpqc/ci/string.hpp"
6 #include "mpqc/math/matrix.hpp"
7 #include "mpqc/mpi.hpp"
8 #include "mpqc/file.hpp"
10 #include <boost/foreach.hpp>
11 #include "mpqc/utility/check.hpp"
12 #include "mpqc/utility/exception.hpp"
14 #include <boost/mpl/int.hpp>
24 struct Spin : boost::mpl::int_<S> {};
33 explicit Space(
int rank) : rank_(rank) {}
34 int rank()
const {
return rank_; }
35 bool operator==(
const Space &s)
const {
36 return this->rank_ == s.rank_;
45 return (a.rank() < b.rank());
64 return ((*mpqc::range::begin() <= idx) && (idx < *mpqc::range::end()));
67 std::vector<Subspace>
split(
size_t block)
const {
68 std::vector<Subspace> s;
91 std::vector< Subspace<Spin> >
split(
const std::vector< Subspace<Spin> > &V,
size_t block) {
92 std::vector< Subspace<Spin> > S;
93 BOOST_FOREACH (
auto v, V) {
94 BOOST_FOREACH (
auto s, v.split(block)) {
112 : alpha_(A), beta_(B), mask_(mask)
114 verify(alpha_, this->mask_.rows());
115 verify(beta_, this->mask_.cols());
118 for (
int i = 0; i < mask_.rows(); ++i) {
119 for (
int j = 0; j < mask_.cols(); ++j) {
121 this->dets_ += this->
alpha(i).size()*this->
beta(j).size();
124 std::vector< Subspace<Any> > a(alpha_.begin(), alpha_.end());
125 std::vector< Subspace<Any> > b(beta_.begin(), beta_.end());
144 const std::vector< Subspace<Alpha> >&
alpha()
const {
149 const std::vector< Subspace<Beta> >&
beta()
const {
169 std::vector< Subspace<Alpha> > alpha_;
170 std::vector< Subspace<Beta> > beta_;
179 static void verify(
const std::vector<
Subspace<Spin> > &V,
int N) {
182 throw MPQC_EXCEPTION(
"Subspace vector size must be equal to %i", N);
183 BOOST_FOREACH (
auto r, V) {
184 if (begin != *r.begin())
195 const std::vector< Subspace<Alpha> > &A;
196 const std::vector< Subspace<Beta> > &B;
203 return (A.at(i.alpha).size()*B.at(i.beta).size() <
204 A.at(j.alpha).size()*B.at(j.beta).size());
209 inline std::vector<SubspaceBlock> blocks(
const std::vector<
Subspace<Alpha> > &A,
212 std::vector<SubspaceBlock> blocks;
213 for (
int b = 0; b < B.size(); ++b) {
214 for (
int a = 0; a < A.size(); ++a) {
216 blocks.push_back(block);
219 std::sort(blocks.begin(), blocks.end(), SubspaceBlock::Sort(A,B));
220 std::reverse(blocks.begin(), blocks.end());
233 #endif // MPQC_CI_SUBSPACE_HPP
Subspace(Space s, mpqc::range r)
Constructs subspace.
Definition: subspace.hpp:56
Grid of subspaces, represented as blocks of determinants defined by alpha/beta pair,...
Definition: subspace.hpp:103
Contains new MPQC code since version 3.
Definition: integralenginepool.hpp:37
Definition: subspace.hpp:192
bool operator==(const Subspace &a) const
Compares two subspaces by their range and space.
Definition: subspace.hpp:59
SubspaceGrid(const std::vector< Subspace< Alpha > > &A, const std::vector< Subspace< Beta > > &B, const mpqc::matrix< bool > &mask)
Construct subspace grid from alpha and beta subspace vectors and sparsity matrix.
Definition: subspace.hpp:109
size_t dets() const
Returns number of determinants in the grid.
Definition: subspace.hpp:164
#define MPQC_EXCEPTION(...)
Definition: exception.hpp:51
std::vector< range > balanced_split(const range &r, size_t N)
Split range into roughly equal blocks of size N or less.
Definition: range.hpp:105
bool allowed(int a, int b) const
Returns whenever a subspace alpha/beta block is allowed.
Definition: subspace.hpp:139
bool test(int idx) const
test if index is in subspace range
Definition: subspace.hpp:63
const std::vector< Subspace< Beta > > & beta() const
Returns all beta subspaces.
Definition: subspace.hpp:149
bool operator==(const Subspace &b) const
Compares two subspaces by their range and space.
Definition: subspace.hpp:85
const std::vector< Subspace< Alpha > > & alpha() const
Returns all alpha subspaces.
Definition: subspace.hpp:144
A range of a space where all objects in the subspace range are assumed to have the same space rank.
Definition: subspace.hpp:51
Subspace< Beta > beta(int i) const
Returns i-th beta subspace.
Definition: subspace.hpp:159
SubspaceGrid()
Construct empty subspace grid.
Definition: subspace.hpp:106
std::vector< Subspace > split(size_t block) const
Split the subspace into a vector of subspaces.
Definition: subspace.hpp:67
Electron spin.
Definition: subspace.hpp:24
A CI space, marked by Spin S and rank.
Definition: subspace.hpp:32
std::vector< range > split(range r, size_t N)
Split range into blocks of size N.
Definition: range.hpp:94
bool operator<(const Space< Spin > &a, const Space< Spin > &b)
Compare two spaces by their rank.
Definition: subspace.hpp:44
Definition: subspace.hpp:194
Subspace(const Subspace< Spin > &s)
Copies subspace while discarding the Spin parameter.
Definition: subspace.hpp:82
Subspace< Alpha > alpha(int i) const
Returns i-th alpha subspace.
Definition: subspace.hpp:154
Generated at Sun Jan 26 2020 23:24:01 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.