8#include <kernel/lafem/power_vector.hpp> 
    9#include <kernel/lafem/vector_mirror.hpp> 
   20      struct PowerMirrorHelper
 
   22        template<
typename SM_, 
typename BV_, 
typename PV_>
 
   23        static void gather(
const SM_& sm, BV_& bv, 
const PV_& pv, 
const Index bo)
 
   25          sm.gather(bv, pv.first(), bo);
 
   26          PowerMirrorHelper<i_-1>::gather(sm, bv, pv.rest(), bo + sm.buffer_size(pv.first()));
 
   28        template<
typename SM_, 
typename PV_, 
typename BV_, 
typename AT_>
 
   29        static void scatter_axpy(
const SM_& sm, PV_& pv, 
const BV_& bv, 
const AT_ a, 
const Index bo)
 
   31          sm.scatter_axpy(pv.first(), bv, a, bo);
 
   32          PowerMirrorHelper<i_-1>::scatter_axpy(sm, pv.rest(), bv, a, bo + sm.buffer_size(pv.first()));
 
   34        template<
typename SM_, 
typename PV_>
 
   35        static Index buffer_size(
const SM_& sm, PV_& pv)
 
   37          return sm.buffer_size(pv.first()) + PowerMirrorHelper<i_-1>::buffer_size(sm, pv.rest());
 
   39        template<Perspective perspective_, 
typename SM_, 
typename Pv_>
 
   40        static Index mask_scatter(
const SM_& sm, 
const Pv_& pv, std::vector<int>& mask, 
const int value, 
const Index offset)
 
   42          Index nf = sm.template mask_scatter<perspective_>(pv.first(), mask, value, offset);
 
   43          Index nr = PowerMirrorHelper<i_-1>::template mask_scatter<perspective_>(sm, pv.rest(), mask, value, offset + nf);
 
   49      struct PowerMirrorHelper<1>
 
   51        template<
typename SM_, 
typename BV_, 
typename PV_>
 
   52        static void gather(
const SM_& sm, BV_& bv, 
const PV_& pv, 
const Index bo)
 
   54          sm.gather(bv, pv.first(), bo);
 
   56        template<
typename SM_, 
typename PV_, 
typename BV_, 
typename AT_>
 
   57        static void scatter_axpy(
const SM_& sm, PV_& pv, 
const BV_& bv, 
const AT_ a, 
const Index bo)
 
   59          sm.scatter_axpy(pv.first(), bv, a, bo);
 
   61        template<
typename SM_, 
typename PV_>
 
   62        static Index buffer_size(
const SM_& sm, PV_& pv)
 
   64          return sm.buffer_size(pv.first());
 
   66        template<Perspective perspective_, 
typename SM_, 
typename Pv_>
 
   67        static Index mask_scatter(
const SM_& sm, 
const Pv_& pv, std::vector<int>& mask, 
const int value, 
const Index offset)
 
   69          return sm.template mask_scatter<perspective_>(pv.first(), mask, value, offset);
 
   92    template<
typename SubMirror_, 
int count_>
 
   96      static_assert(count_ > 0, 
"invalid block size");
 
  109      template <
typename DT2_ = DataType, 
typename IT2_ = IndexType>
 
  113      template <
typename DataType2_, 
typename IndexType2_>
 
  162      template<
typename SubMirror2_>
 
  165        this->_sub_mirror.convert(other._sub_mirror);
 
  176      template<
typename SubVector_>
 
  179        return PowerMirror(SubMirrorType::make_empty(tmpl_vec.first()));
 
  195        return this->_sub_mirror.empty();
 
  204      template<
typename SubVector_>
 
  207        return Intern::PowerMirrorHelper<count_>::buffer_size(
_sub_mirror, vector);
 
  216      template<
typename SubVector_>
 
  234        static_assert((0 <= i_) && (i_ < count_), 
"invalid sub-mirror index");
 
  242        static_assert((0 <= i_) && (i_ < count_), 
"invalid sub-mirror index");
 
  257        XASSERTM((0 <= i) && (i < count_), 
"invalid sub-mirror index");
 
  264        XASSERTM((0 <= i) && (i < count_), 
"invalid sub-mirror index");
 
  269      template<
typename Tv_>
 
  275        Intern::PowerMirrorHelper<count_>::gather(
_sub_mirror, buffer, vector, buffer_offset);
 
  279      template<
typename Tv_>
 
  286        Intern::PowerMirrorHelper<count_>::scatter_axpy(
_sub_mirror, vector, buffer, alpha, buffer_offset);
 
  290      template<Perspective perspective_, 
typename Tv_>
 
  294        return Intern::PowerMirrorHelper<count_>::template mask_scatter<perspective_>(
_sub_mirror, vector, mask, 
value, offset);
 
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Dense data vector class template.
PowerVector meta-mirror class template.
const SubMirrorType & at() const
Returns a sub-mirror block.
Index mask_scatter(const LAFEM::PowerVector< Tv_, count_ > &vector, std::vector< int > &mask, const int value, const Index offset=Index(0)) const
Updates a scatter mask vector for this mirror.
PowerMirror & operator=(PowerMirror &&other)
move-assign operator
PowerMirror(SubMirrorType &&sub_mirror)
sub-mirror move-ctor
void gather(LAFEM::DenseVector< DataType, IndexType > &buffer, const LAFEM::PowerVector< Tv_, count_ > &vector, const Index buffer_offset=Index(0)) const
Gathers the buffer entries from a DenseVector.
PowerMirror(PowerMirror &&other)
move-ctor
DenseVector< DataType, IndexType > create_buffer(const PowerVector< SubVector_, count_ > &vector) const
Creates a new buffer vector for a PowerVector.
Index buffer_size(const PowerVector< SubVector_, count_ > &vector) const
Computes the required buffer size for a PowerVector.
SubMirrorType::IndexType IndexType
sub-mirror index-type
SubMirrorType & at()
Returns a sub-mirror block.
SubMirrorType::DataType DataType
sub-mirror data-type
PowerMirror clone(CloneMode clone_mode=CloneMode::Weak) const
Clone operation.
std::size_t bytes() const
Returns the total amount of bytes allocated.
static PowerMirror make_empty(const PowerVector< SubVector_, count_ > &tmpl_vec)
Creates and returns an empty mirror.
SubMirrorType & get(int i)
Returns a sub-mirror block.
bool empty() const
Checks whether the mirror is empty.
SubMirrorType _sub_mirror
the one and only sub-mirror object
const SubMirrorType & get(int i) const
Returns a sub-mirror block.
void convert(const PowerMirror< SubMirror2_, count_ > &other)
Conversion method.
PowerMirror()
default ctor
SubMirror_ SubMirrorType
sub-mirror type
void scatter_axpy(LAFEM::PowerVector< Tv_, count_ > &vector, const LAFEM::DenseVector< DataType, IndexType > &buffer, const DataType alpha=DataType(1), const Index buffer_offset=Index(0)) const
Scatters the buffer entries onto a DenseVector.
static constexpr int num_blocks
total number of sub-mirror blocks
Power-Vector meta class template.
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.