// -*- C++ -*- #ifndef __multi_array_operation_h__ #define __multi_array_operation_h__ #include #include #include #include #include #include "base_def.h" namespace MultiArrayTools { namespace { using namespace MultiArrayHelper; } /* * OperationBase * MutableOperationBase * * OperationMaster : MutableOperationBase * * OperationTemplate<...> * ConstOperationRoot : OperationBase, OperationTemplate<...> * OperationRoot : MutableOperationBase, * OperationTemplate<...> * */ void seekIndexInst(std::shared_ptr i, std::vector >& ivec); // typedef std::pair BTSS; BTSS getBlockType(std::shared_ptr i, std::shared_ptr j, bool first, size_t higherStepSize = 1); template std::shared_ptr > makeBlock(const std::vector& vec, size_t stepSize, size_t blockSize); template std::shared_ptr > makeBlock(std::vector& vec, size_t stepSize, size_t blockSize); size_t getBTNum(const std::vector& mp, BlockType bt); void minimizeAppearanceOfType(std::map, std::vector >& mp, BlockType bt); template std::shared_ptr seekBlockIndex(std::shared_ptr ownIdx, const OpClass& second); /* template class OperationBase { public: typedef T value_type; OperationBase() = default; virtual ~OperationBase() = default; // init block, return resulting type (BLOCK, VALUE, SPLIT) virtual std::vector block(const std::shared_ptr blockIndex) const = 0; virtual const OperationBase& block() const = 0; // update block //virtual size_t argNum() const = 0; virtual const Block& get() const = 0; }; template class MutableOperationBase : public OperationBase { public: typedef T value_type; MutableOperationBase() = default; virtual MBlock& get() = 0; }; */ template class OperationTemplate { public: OperationTemplate(OperationClass* oc); template auto operator+(const Second& in) const -> Operation,OperationClass,Second>; template auto operator-(const Second& in) const -> Operation,OperationClass,Second>; template auto operator*(const Second& in) const -> Operation,OperationClass,Second>; template auto operator/(const Second& in) const -> Operation,OperationClass,Second>; private: OperationClass* mOc; }; template class OperationMaster/* : public MutableOperationBase*/ { public: typedef T value_type; typedef OperationBase OB; typedef ContainerRange CRange; typedef typename MultiRange::IndexType IndexType; OperationMaster(MutableMultiArrayBase& ma, const OpClass& second, std::shared_ptr& index); MBlock& get(); const Block& get() const; std::vector block(const std::shared_ptr blockIndex) const; const OperationMaster& block() const; protected: //void performAssignment(const OperationBase& in); OpClass const& mSecond; MutableMultiArrayBase& mArrayRef; std::shared_ptr mIndex; mutable std::shared_ptr > mBlockPtr; }; template class ConstOperationRoot : /*public OperationBase,*/ public OperationTemplate > { public: typedef T value_type; typedef OperationBase OB; typedef OperationTemplate > OT; typedef ContainerRange CRange; typedef typename CRange::IndexType IndexType; ConstOperationRoot(const MultiArrayBase& ma, const std::shared_ptr&... indices); const Block& get() const; std::vector block(const std::shared_ptr blockIndex) const; const ConstOperationRoot& block() const; protected: MultiArrayBase const& mArrayRef; std::shared_ptr mIndex; mutable std::shared_ptr > mBlockPtr; }; template class OperationRoot : /*public MutableOperationBase,*/ public OperationTemplate > { public: typedef T value_type; typedef OperationBase OB; typedef OperationTemplate > OT; typedef ContainerRange CRange; typedef typename CRange::IndexType IndexType; OperationRoot(MutableMultiArrayBase& ma, const std::shared_ptr&... indices); template OperationMaster operator=(const OpClass& in); const MBlock& get() const; MBlock& get(); std::vector block(const std::shared_ptr blockIndex) const; const OperationRoot& block() const; protected: MutableMultiArrayBase& mArrayRef; std::shared_ptr mIndex; mutable std::shared_ptr > mBlockPtr; }; template class Operation : /*public OperationBase,*/ public OperationTemplate > { public: typedef T value_type; typedef OperationBase OB; typedef OperationTemplate > OT; typedef OpFunction F; Operation(const Ops&... ops); const BlockResult& get() const; std::vector block(const std::shared_ptr blockIndex) const; const Operation& block() const; protected: std::tuple mOps; mutable BlockResult mRes; }; } #include "multi_array_operation.cc" #endif