disarray_store.h
Go to the documentation of this file.
#ifndef _RHEOLEF_ARRAY_STORE_H
#define _RHEOLEF_ARRAY_STORE_H
namespace rheolef {
//
// implementation for dense disarray
//
template <class OutputRandomIterator, class SetOp, class Size, class IsContainer = std::false_type>
struct disarray_store {};
// dense disarray of simple type, i.e. T is a mpi_datatype
template <class OutputRandomIterator, class SetOp, class Size>
struct disarray_store<OutputRandomIterator, SetOp, Size, std::false_type> {
typedef typename std::iterator_traits<OutputRandomIterator>::value_type T;
typedef typename std::pair<Size,T> data_type;
void operator()(const std::pair<Size,T>& val) { _op(_x [val.first], val.second); }
Size n_new_entry() const { return 0; }
disarray_store(OutputRandomIterator x, SetOp op) : _x(x), _op(op) {}
OutputRandomIterator _x;
SetOp _op;
};
// dense disarray of more complex type, i.e. T is a container of mpi_datatype
template <class OutputRandomIterator, class SetOp, class Size>
struct disarray_store<OutputRandomIterator, SetOp, Size, std::true_type> {
typedef typename std::iterator_traits<OutputRandomIterator>::value_type T;
typedef typename T::value_type U;
typedef typename std::pair<Size,U> data_type;
void operator()(const std::pair<Size,U>& val) {
#ifdef TO_CLEAN
// TODO: assume here that op is set_add_op; how to implement set_op ?
// and that T=set, because we use T::insert() and T::value_type
_x [val.first].insert (val.second);
#endif // TO_CLEAN
_op (_x [val.first], val.second);
}
Size n_new_entry() const { return 0; }
disarray_store(OutputRandomIterator x, SetOp op) : _x(x), _op(op) {}
OutputRandomIterator _x;
SetOp _op;
};
// a simple wrapper, for convenience:
template <class OutputRandomIterator, class SetOp, class Size, class IsContainer>
inline
disarray_store<OutputRandomIterator, SetOp, Size, IsContainer>
disarray_make_store(OutputRandomIterator x, SetOp op, Size, IsContainer)
{
return disarray_store<OutputRandomIterator, SetOp, Size, IsContainer>(x,op);
}
} // namespace rheolef
#endif // _RHEOLEF_ARRAY_STORE_H
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::true_type >::n_new_entry
Size n_new_entry() const
Definition: disarray_store.h:55
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::false_type >::operator()
void operator()(const std::pair< Size, T > &val)
Definition: disarray_store.h:35
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::true_type >::T
std::iterator_traits< OutputRandomIterator >::value_type T
Definition: disarray_store.h:44
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::false_type >::_op
SetOp _op
Definition: disarray_store.h:39
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::false_type >::n_new_entry
Size n_new_entry() const
Definition: disarray_store.h:36
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::true_type >::operator()
void operator()(const std::pair< Size, U > &val)
Definition: disarray_store.h:47
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::false_type >::data_type
std::pair< Size, T > data_type
Definition: disarray_store.h:34
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::true_type >::_op
SetOp _op
Definition: disarray_store.h:58
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::true_type >::U
T::value_type U
Definition: disarray_store.h:45
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::true_type >::data_type
std::pair< Size, U > data_type
Definition: disarray_store.h:46
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::true_type >::_x
OutputRandomIterator _x
Definition: disarray_store.h:57
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::false_type >::T
std::iterator_traits< OutputRandomIterator >::value_type T
Definition: disarray_store.h:33
rheolef::disarray_make_store
disarray_store< OutputRandomIterator, SetOp, Size, IsContainer > disarray_make_store(OutputRandomIterator x, SetOp op, Size, IsContainer)
Definition: disarray_store.h:65
rheolef::disarray_store
Definition: disarray_store.h:28
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::true_type >::disarray_store
disarray_store(OutputRandomIterator x, SetOp op)
Definition: disarray_store.h:56
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::false_type >::_x
OutputRandomIterator _x
Definition: disarray_store.h:38
rheolef::disarray_store< OutputRandomIterator, SetOp, Size, std::false_type >::disarray_store
disarray_store(OutputRandomIterator x, SetOp op)
Definition: disarray_store.h:37
rheolef::std
Definition: vec_expr_v2.h:391