diff --git a/src/include/dynamic_operation.cc.h b/src/include/dynamic_operation.cc.h new file mode 100644 index 0000000..b2353a5 --- /dev/null +++ b/src/include/dynamic_operation.cc.h @@ -0,0 +1,37 @@ + +#include "dynamic_operation.h" + +namespace MultiArrayTools +{ + template + const T& DynamicOperation::get(const DExt& pos) const + { + return mOp.get(pos.expl()); + } + + template + DynamicOperationBase& DynamicOperation::set(const DExt& pos) + { + mOp.set(pos.expl()); + return *this; + } + + template + DExt DynamicOperation::rootSteps(std::intptr_t iPtrNum = 0) const + { + return mOp.rootSteps(iPtrNum); + } + + template + DynamicExpression DynamicOperation::loop(const DynamicExpression& exp) const + { + return mOp.loop(exp); + } + + template + const T* DynamicOperation::data() const + { + return mOp.data(); + } + +} // namespace MultiArrayTools diff --git a/src/include/dynamic_operation.h b/src/include/dynamic_operation.h new file mode 100644 index 0000000..f8cab39 --- /dev/null +++ b/src/include/dynamic_operation.h @@ -0,0 +1,60 @@ + +#ifndef __dynamic_operation_h__ +#define __dynamic_operation_h__ + +#include "base_def.h" +#include "multi_array_operation.h" + +namespace MultiArrayTools +{ + + template + class DynamicOperationBase : public OperationTemplate> + { + public: + typedef T value_type; + typedef OperationBase> OT; + + static constexpr size_t SIZE = 1; + static constexpr bool CONT = true; + + DynamicOperationBase() = default; + DynamicOperationBase(const DynamicOperationBase& in) = default; + DynamicOperationBase(DynamicOperationBase&& in) = default; + DynamicOperationBase& operator=(const DynamicOperationBase& in) = default; + DynamicOperationBase& operator=(DynamicOperationBase&& in) = default; + + virtual const T& get(const DExt& pos) const = 0; + virtual DynamicOperationBase& set(const DExt& pos) = 0; + virtual DExt rootSteps(std::intptr_t iPtrNum = 0) const = 0; + virtual DynamicExpression loop(const DynamicExpression& exp) const = 0; + virtual const T* data() const = 0; + + }; + + template + class DynamicOperation : public DynamicOperationBase + { + private: + Operation mOp; + public: + typedef decltype(std::declval().rootSteps()) ET; + + DynamicOperation() = default; + DynamicOperation(const DynamicOperation& in) = default; + DynamicOperation(DynamicOperation&& in) = default; + DynamicOperation& operator=(const DynamicOperation& in) = default; + DynamicOperation& operator=(DynamicOperation&& in) = default; + + DynamicOperation(const Operation& op) : mOp(op) {} + + virtual const T& get(const DExt& pos) const override final; + virtual DynamicOperationBase& set(const DExt& pos) override final; + virtual DExt rootSteps(std::intptr_t iPtrNum = 0) const override final; + virtual DynamicExpression loop(const DynamicExpression& exp) const override final; + virtual const T* data() const override final; + }; + +} // namespace MultiArrayTools + +#endif diff --git a/src/include/operation_helper.h b/src/include/operation_helper.h new file mode 100644 index 0000000..4b4b002 --- /dev/null +++ b/src/include/operation_helper.h @@ -0,0 +1,46 @@ + +#ifndef __operation_helper_h__ +#define __operation_helper_h__ + +#include "multi_array_operation.h" + +namespace MultiArrayTools +{ + + template + class PseudoArray + { + size_t mThreadNum; + Slice<> mSl; + mutable ConstOperationRoot mOp; + + public: + + template + const SrcHolder> operator[](ET pos) const; + }; + + template + class SrcHolder + { + + TempHolder operator+(SrcHolder in) const; + // aso + }; + + template + class TempHolder + { + TempHolder operator+(SrcHolder in) const; + TempHolder operator+(TempHolder in) const; + }; + + template + class TarHolder + { + TarHolder& operator=(TempHolder in); + }; + +} // namespace MultiArrayTools + +#endif diff --git a/src/include/xfor/xfor.h b/src/include/xfor/xfor.h index 2689ca3..d4fb92f 100644 --- a/src/include/xfor/xfor.h +++ b/src/include/xfor/xfor.h @@ -36,6 +36,9 @@ namespace MultiArrayHelper //virtual size_t rootSteps() const = 0; virtual std::shared_ptr operator+(const ExtBase& in) const = 0; virtual std::shared_ptr operator*(size_t in) const = 0; + + template + const ExtType& expl() const { return dynamic_cast*>(this)->ext(); } }; typedef std::shared_ptr DExt; @@ -444,6 +447,11 @@ namespace MultiArrayHelper namespace MultiArrayHelper { + template + const ExtType& ExtBase::expl() const + { + return dynamic_cast*>(this)->ext(); + } /***************** * F o r *