1#ifndef MPQC_CI_VECTOR_HPP
2#define MPQC_CI_VECTOR_HPP
4#include "mpqc/ci/subspace.hpp"
5#include "mpqc/math/matrix.hpp"
6#include "mpqc/array.hpp"
9#include "mpqc/utility/profile.hpp"
26 blocks_.resize(G.
alpha().size(), G.
beta().size());
28 for (
size_t j = 0; j < G.
beta().size(); ++j) {
29 for (
size_t i = 0; i < G.
alpha().size(); ++i) {
31 b.rows = G.
alpha().at(i).size();
32 b.cols = G.
beta().at(j).size();
36 dets += b.rows*b.cols;
41 MPQC_CHECK(dets == G.
dets());
42 BOOST_FOREACH (
const auto &s, G.
alpha())
43 this->alpha_.push_back(s);
44 BOOST_FOREACH (
const auto &s, G.
beta())
45 this->beta_.push_back(s);
46 std::vector<size_t> extents;
47 extents.push_back(dets);
48 this->array_ = (incore)
68 return Block1d(this->array_(r));
76 MPQC_CHECK(m.rows() == this->rows_);
77 MPQC_CHECK(m.cols() == this->cols_);
82 m.resize(this->rows_, this->cols_);
88 : array_(array), rows_(rows), cols_(cols) {}
96 Block b = this->block(A,B);
97 return Block2d(this->array_(b.range()), b.rows, b.cols);
115 std::vector<mpqc::range> alpha_;
116 std::vector<mpqc::range> beta_;
124 size_t i = range_to_block(A, this->alpha_);
125 size_t j = range_to_block(B, this->beta_);
126 Block b = this->blocks_(i,j);
128 throw MPQC_EXCEPTION(
"ci::Vector: block (%s,%s) is not allowed\n",
135 static size_t range_to_block(
mpqc::range r,
const std::vector<mpqc::range> &R) {
136 auto it = std::find(R.begin(), R.end(), r);
138 throw MPQC_EXCEPTION(
"ci::Vector: range r=(%s) does not map an exact block",
161 const std::vector<mpqc::range> &local,
164 BOOST_FOREACH (
auto r, local) {
181 const std::vector<mpqc::range> &local,
186#pragma omp parallel for reduction(+:db)
187 for (
int j = 0; j < local.size(); ++j) {
198#pragma omp parallel for reduction(+:dd)
199 for (
int j = 0; j < local.size(); ++j) {
212#pragma omp parallel for
213 for (
int j = 0; j < local.size(); ++j) {
double orthonormalize(ci::Vector &b, ci::Vector &D, const std::vector< mpqc::range > &local, const MPI::Comm &comm)
Schmidt orthogonalization d' = normalized(d - <d,b>*b)
Definition vector.hpp:180
void operator>>(Vector::Block1d block, mpqc::Vector &v)
Get vector block into v.
Definition vector.hpp:152
double norm(ci::Vector &V, const std::vector< mpqc::range > &local, const MPI::Comm &comm)
Compute CI vector norm.
Definition vector.hpp:160
std::string string_cast(const T &value)
cast type T to string
Definition string.hpp:14
#define MPQC_EXCEPTION(...)
Constructs mpqc::Exception with file, line information and an optional printf-style format and argume...
Definition exception.hpp:51
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37
Array implementation.
Definition forward.hpp:10
MPI_Comm object wrapper/stub.
Definition comm.hpp:14
Grid of subspaces, represented as blocks of determinants defined by alpha/beta pair,...
Definition subspace.hpp:103
bool allowed(int a, int b) const
Returns whenever a subspace alpha/beta block is allowed.
Definition subspace.hpp:139
const std::vector< Subspace< Alpha > > & alpha() const
Returns all alpha subspaces.
Definition subspace.hpp:144
const std::vector< Subspace< Beta > > & beta() const
Returns all beta subspaces.
Definition subspace.hpp:149
size_t dets() const
Returns number of determinants in the grid.
Definition subspace.hpp:164
1-d vector sub-block
Definition vector.hpp:55
friend void operator>>(Vector::Block1d block, mpqc::Vector &v)
Get vector block into v.
Definition vector.hpp:152
friend void operator<<(Vector::Block1d block, const mpqc::Vector &v)
Set vector block to v.
Definition vector.hpp:147
2-d vector sub-block
Definition vector.hpp:73
void operator=(const mpqc::Matrix &m) const
Assign matrix to this sub-block.
Definition vector.hpp:75
void assign_to(mpqc::Matrix &m) const
mpqc::Matrix::Assignable::assign_to implementation
Definition vector.hpp:81
Block CI Vector, with 1-d (vector) and 2-d (matrix) access.
Definition vector.hpp:18
Block1d operator()(range r)
Returns 1-d sub-block of vector.
Definition vector.hpp:67
Block2d operator()(mpqc::range A, mpqc::range B)
Returns 2-d sub-block of vector.
Definition vector.hpp:95
Vector(std::string name, const SubspaceGrid &G, MPI::Comm comm, bool incore)
Construct vector.
Definition vector.hpp:25
An interface to enable matrix assignment from other containers.
Definition matrix.hpp:54
Matrix class derived from Eigen::Matrix with additional MPQC integration.
Definition matrix.hpp:23
Vector class derived from Eigen::Matrix with additional MPQC integration.
Definition matrix.hpp:133