14 #include <initializer_list> 16 #include <Eigen/Dense> 20 namespace alps {
namespace alea {
60 view() : data_(nullptr), size_(0) { }
64 : data_(data), size_(size)
68 T *
data() {
return data_; }
71 const T *
data()
const {
return data_; }
74 size_t size()
const {
return size_; }
101 ndview(T *data,
const size_t *shape,
size_t ndim)
102 :
view<T>(data, compute_size(shape, ndim))
108 ndview(T *data,
size_t size,
const size_t *shape,
size_t ndim)
109 :
view<T>(data, size)
113 assert(size == compute_size(shape, ndim));
117 const size_t *
shape()
const {
return shape_; }
120 size_t ndim()
const {
return ndim_; }
126 for (
size_t d = 0; d != ndim; ++d)
132 const size_t *shape_;
156 template <
typename T>
162 virtual size_t size()
const = 0;
165 virtual std::vector<size_t>
shape()
const {
return std::vector<size_t>(1,
size()); }
174 virtual void add_to(
view<T> out)
const = 0;
186 template <
typename T>
188 :
public Eigen::Matrix<T, Eigen::Dynamic, 1>
198 this->Eigen::Matrix<T,Eigen::Dynamic,1>::operator()(i) = x;
203 template <
typename OtherDerived>
204 column(
const Eigen::MatrixBase<OtherDerived>& other)
205 :
Eigen::Matrix<T,
Eigen::Dynamic, 1>(other) { }
207 template<
typename OtherDerived>
210 this->Eigen::Matrix<T, Eigen::Dynamic, 1>::operator=(other);
220 size_t size()
const {
return this->rows(); }
222 operator std::vector<T>()
const 224 return std::vector<T>(this->data(), this->data() + this->rows());
271 virtual long get_max(
long value)
const = 0;
277 virtual void reduce(
view<long> data)
const = 0;
280 virtual void commit()
const = 0;
313 virtual void enter(
const std::string &group) = 0;
316 virtual void exit() = 0;
322 virtual void write(
const std::string &key,
ndview<
const std::complex<double>>) = 0;
355 virtual void enter(
const std::string &group) = 0;
358 virtual void exit() = 0;
361 virtual std::vector<size_t> get_shape(
const std::string &key) = 0;
367 virtual void read(
const std::string &key,
ndview<std::complex<double>>) = 0;
373 virtual void read(
const std::string &key,
ndview<long>) = 0;
394 template <
typename T>
401 virtual size_t in_size()
const = 0;
404 virtual size_t out_size()
const = 0;
const size_t * shape() const
std::enable_if<!is_sequence< T >::value, std::size_t >::type size(T const &)
void reduce(view< unsigned long > data) const
column(const Eigen::MatrixBase< OtherDerived > &other)
column & operator=(const Eigen::MatrixBase< OtherDerived > &other)
static size_t compute_size(const size_t *shape, size_t ndim)
void reduce(view< complex_op< double > > data) const
ndview(T *data, const size_t *shape, size_t ndim)
virtual computed * clone()
virtual std::vector< size_t > shape() const
column(std::initializer_list< T > l)
traits< Acc >::result_type result(const Acc &acc)
virtual serializer * clone()
virtual deserializer * clone()
view(T *data, size_t size)
virtual reducer * clone()
ndview(T *data, size_t size, const size_t *shape, size_t ndim)
void reduce(view< std::complex< double > > data) const