4#include "mpqc/range.hpp"
5#include "mpqc/range/operator.hpp"
8#include "mpqc/array/core.hpp"
9#include "mpqc/array/file.hpp"
11#include "mpqc/array/parallel.hpp"
14#include "mpqc/utility/check.hpp"
15#include <boost/foreach.hpp>
16#include "mpqc/utility/exception.hpp"
32 template<
typename Extent>
34 const std::vector<Extent> &extents,
37 initialize(name, extents, ARRAY_CORE, comm);
41 template<
typename Extent,
class Driver>
43 const std::vector<Extent> &extents,
47 initialize(name, extents, driver, comm);
61 void put(
const T *buffer) {
62 impl_->put(this->range_, buffer);
67 void get(T *buffer)
const {
68 impl_->get(this->range_, buffer);
75 const std::vector<size_t>& dims()
const {
83 operator vector<T>()
const {
84 vector<T> p(range_[0].size());
89 operator matrix<T>()
const {
90 matrix<T> p(range_[0].size(), range_[1].size());
95 Array operator()(
const std::vector<range> &r) {
96 MPQC_CHECK(this->rank() == r.size());
97 return Array(*
this, r);
100 Array operator()(
const std::vector<range> &r)
const {
101 MPQC_CHECK(this->rank() == r.size());
102 return Array(*
this, r);
114 template<
class R, ...>
119 return this->operator()(std::vector<range>(t));
123 return this->operator()(std::vector<range>(t));
131 template<
class Extent,
class Driver>
132 void initialize(
const std::string &name,
133 const std::vector<Extent> &extents,
134 Driver driver, MPI::Comm comm) {
136 BOOST_FOREACH (
auto e, extents) {
137 range_.push_back(detail::ArrayBase::extent(e));
138 dims_.push_back(range_.back().size());
142 detail::ArrayBase *impl = NULL;
143 if (comm == MPI::Comm::Self()) {
144 impl =
new detail::array_impl<T, Driver>(name, dims_);
148 impl =
new detail::array_parallel_impl<T, Driver>(name, dims_, comm);
151 "library was compiled without proper MPI support");
155 this->impl_.reset(impl);
158 Array(
const Array &A,
const std::vector<range> &r)
160 MPQC_CHECK(A.rank() == r.size());
162 BOOST_FOREACH (range r, range_) {
164 dims_.push_back(r.size());
170 size_t block()
const {
171 MPQC_ASSERT(this->rank() == 2);
172 range ri = range_[0];
173 return std::max<size_t>((8 << 20)/(
sizeof(T)*ri.size()), 1);
177 std::vector<range> range_;
178 std::vector<size_t> dims_;
179 std::shared_ptr<detail::ArrayBase> impl_;
190 template<
typename T,
class V>
203 template<
typename T,
class V>
#define MPQC_EXCEPTION(...)
Constructs mpqc::Exception with file, line information and an optional printf-style format and argume...
Definition exception.hpp:51
void operator<<(Array< T > A, const V &v)
Write to Array from a generic vector V.
Definition array.hpp:191
void operator>>(Array< T > A, V &v)
Read from Array to a generic vector V.
Definition array.hpp:204
#define MPQC_RANGE_OPERATORS(N, Type, Function)
Generates operators()(const R1 r1, ...) of arity 1 to N.
Definition operator.hpp:41
#define MPQC_RANGE_CONST_OPERATORS(N, Type, Function)
Generates const version of MPQC_RANGE_OPERATORS.
Definition operator.hpp:45
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37
Array implementation.
Definition forward.hpp:10
Array(const std::string &name, const std::vector< Extent > &extents, MPI::Comm comm=MPI::Comm::Self())
Create new array using CORE driver (in-memory)
Definition array.hpp:33
Array(const std::string &name, const std::vector< Extent > &extents, Driver driver, MPI::Comm comm=MPI::Comm(MPI::Comm::Self()))
Create new array using an arbitrary driver.
Definition array.hpp:42
Array()
Create new empty array.
Definition array.hpp:29
Array(const Array &a)
Shallow copy constructor.
Definition array.hpp:52
void get(T *buffer) const
Get array data into buffer.
Definition array.hpp:67
void put(const T *buffer)
Put buffer data into array.
Definition array.hpp:61
Array operator()(const R &r,...)
N-ary sub-array access operators.
MPI_Comm object wrapper/stub.
Definition comm.hpp:14
boost::tuple tie wrapper
Definition tie.hpp:15