From 9938d43f9c5809f78a9604485712ed6bc6ee0c00 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Tue, 6 Dec 2022 14:48:44 +0100 Subject: [PATCH] rename darray_base -> carray_base, mdarray_base -> array_base, darray -> marray + rename corresponding files/tests --- src/include/array/array.cc.h | 4 +- src/include/array/array.h | 4 +- .../{darray_base.cc.h => array_base.cc.h} | 44 ++++++------- .../array/{darray_base.h => array_base.h} | 42 ++++++------ src/include/array/darray.cc.h | 66 ------------------- src/include/array/marray.cc.h | 66 +++++++++++++++++++ src/include/array/{darray.h => marray.h} | 22 +++---- src/include/operation/op_types.cc.h | 4 +- src/include/operation/op_types.h | 6 +- src/tests/CMakeLists.txt | 8 +-- ...array_unit_test.cc => marray_unit_test.cc} | 16 ++--- 11 files changed, 141 insertions(+), 141 deletions(-) rename src/include/array/{darray_base.cc.h => array_base.cc.h} (61%) rename src/include/array/{darray_base.h => array_base.h} (69%) delete mode 100644 src/include/array/darray.cc.h create mode 100644 src/include/array/marray.cc.h rename src/include/array/{darray.h => marray.h} (53%) rename src/tests/{darray_unit_test.cc => marray_unit_test.cc} (85%) diff --git a/src/include/array/array.cc.h b/src/include/array/array.cc.h index ce33281..1da0edb 100644 --- a/src/include/array/array.cc.h +++ b/src/include/array/array.cc.h @@ -1,6 +1,6 @@ //#include "access.cc.h" -#include "darray_base.cc.h" -#include "darray.cc.h" +#include "array_base.cc.h" +#include "marray.cc.h" #include "aindex.cc.h" //#include "functional_array.cc.h" diff --git a/src/include/array/array.h b/src/include/array/array.h index 8f07d26..53aa197 100644 --- a/src/include/array/array.h +++ b/src/include/array/array.h @@ -1,7 +1,7 @@ //#include "access.h" -#include "darray_base.h" -#include "darray.h" +#include "array_base.h" +#include "marray.h" #include "aindex.h" //#include "functional_array.h" diff --git a/src/include/array/darray_base.cc.h b/src/include/array/array_base.cc.h similarity index 61% rename from src/include/array/darray_base.cc.h rename to src/include/array/array_base.cc.h index 5a390eb..666460f 100644 --- a/src/include/array/darray_base.cc.h +++ b/src/include/array/array_base.cc.h @@ -1,23 +1,23 @@ -#ifndef __cxz_darray_base_cc_h__ -#define __cxz_darray_base_cc_h__ +#ifndef __cxz_array_base_cc_h__ +#define __cxz_array_base_cc_h__ -#include "darray_base.h" +#include "array_base.h" namespace CNORXZ { /****************** - * DArrayBase * + * CArrayBase * ******************/ template - DArrayBase::DArrayBase(const RangePtr& range) : + CArrayBase::CArrayBase(const RangePtr& range) : mRange(rangeCast(range)) {} template template - const T& DArrayBase::operator[](const IndexInterface& i) const + const T& CArrayBase::operator[](const IndexInterface& i) const { auto ai = this->begin() + i.lex(); return *ai; @@ -25,7 +25,7 @@ namespace CNORXZ template template - const T& DArrayBase::at(const IndexInterface& i) const + const T& CArrayBase::at(const IndexInterface& i) const { CXZ_ASSERT(i.lex() < this->size(), "index out of range"); // check further compatibility of index/range format!!! @@ -34,25 +34,25 @@ namespace CNORXZ } template - SizeT DArrayBase::size() const + SizeT CArrayBase::size() const { return mRange->size(); } template - RangePtr DArrayBase::range() const + RangePtr CArrayBase::range() const { return mRange; } template - typename DArrayBase::const_iterator DArrayBase::begin() const + typename CArrayBase::const_iterator CArrayBase::begin() const { return this->cbegin(); } template - typename DArrayBase::const_iterator DArrayBase::end() const + typename CArrayBase::const_iterator CArrayBase::end() const { return this->cend(); } @@ -60,24 +60,24 @@ namespace CNORXZ /* template template - ConstOperationRoot DArrayBase::operator()(const IndexPtr& i) const + ConstOperationRoot CArrayBase::operator()(const IndexPtr& i) const { return ConstOperationRoot(); } */ - /******************* - * MDArrayBase * - *******************/ + /***************** + * ArrayBase * + *****************/ template - MDArrayBase::MDArrayBase(const RangePtr& range) : - DArrayBase(range) + ArrayBase::ArrayBase(const RangePtr& range) : + CArrayBase(range) {} template template - T& MDArrayBase::operator[](const IndexInterface& i) + T& ArrayBase::operator[](const IndexInterface& i) { auto ai = this->begin() + i.lex(); return *ai; @@ -85,7 +85,7 @@ namespace CNORXZ template template - T& MDArrayBase::at(const IndexInterface& i) + T& ArrayBase::at(const IndexInterface& i) { CXZ_ASSERT(i.pos() < this->pmax(), "index out of range"); // check further compatibility of index/range format!!! @@ -94,13 +94,13 @@ namespace CNORXZ } template - typename MDArrayBase::iterator MDArrayBase::begin() + typename ArrayBase::iterator ArrayBase::begin() { return iterator(this->data(), this->cbegin()); } template - typename MDArrayBase::iterator MDArrayBase::end() + typename ArrayBase::iterator ArrayBase::end() { return iterator(this->data(), this->cend()); } @@ -108,7 +108,7 @@ namespace CNORXZ /* template template - OperationRoot MDArrayBase::operator()(const IndexPtr& i) + OperationRoot ArrayBase::operator()(const IndexPtr& i) { return OperationRoot(); } diff --git a/src/include/array/darray_base.h b/src/include/array/array_base.h similarity index 69% rename from src/include/array/darray_base.h rename to src/include/array/array_base.h index bf6ca02..24a9510 100644 --- a/src/include/array/darray_base.h +++ b/src/include/array/array_base.h @@ -1,6 +1,6 @@ -#ifndef __cxz_darray_base_h__ -#define __cxz_darray_base_h__ +#ifndef __cxz_array_base_h__ +#define __cxz_array_base_h__ #include #include @@ -14,7 +14,7 @@ namespace CNORXZ { template - class DArrayBase + class CArrayBase { public: typedef AIndex const_iterator; @@ -24,10 +24,10 @@ namespace CNORXZ public: - DArrayBase(const RangePtr& range); - DEFAULT_MEMBERS(DArrayBase); + CArrayBase(const RangePtr& range); + DEFAULT_MEMBERS(CArrayBase); - virtual ~DArrayBase() = default; + virtual ~CArrayBase() = default; template const T& operator[](const IndexInterface& i) const; @@ -36,7 +36,7 @@ namespace CNORXZ const T& at(const IndexInterface& i) const; template - Sptr> sl(const IndexInterface& i) const; + Sptr> sl(const IndexInterface& i) const; virtual const T* data() const = 0; virtual SizeT pmax() const = 0; // max allocated postion of data() (exclusive!) @@ -55,24 +55,24 @@ namespace CNORXZ }; template - class MDArrayBase : public DArrayBase + class ArrayBase : public CArrayBase { public: - typedef DArrayBase DAB; - typedef typename DAB::const_iterator const_iterator; + typedef CArrayBase CAB; + typedef typename CAB::const_iterator const_iterator; typedef BIndex iterator; - using DAB::operator[]; - using DAB::at; - using DAB::data; - using DAB::begin; - using DAB::end; - using DAB::cbegin; - using DAB::cend; - //using DAB::operator(); + using CAB::operator[]; + using CAB::at; + using CAB::data; + using CAB::begin; + using CAB::end; + using CAB::cbegin; + using CAB::cend; + //using CAB::operator(); - MDArrayBase(const RangePtr& range); - DEFAULT_MEMBERS(MDArrayBase); + ArrayBase(const RangePtr& range); + DEFAULT_MEMBERS(ArrayBase); template T& operator[](const IndexInterface& i); @@ -81,7 +81,7 @@ namespace CNORXZ T& at(const IndexInterface& i); template - Sptr> sl(const IndexInterface& i); + Sptr> sl(const IndexInterface& i); virtual T* data() = 0; diff --git a/src/include/array/darray.cc.h b/src/include/array/darray.cc.h deleted file mode 100644 index 54af068..0000000 --- a/src/include/array/darray.cc.h +++ /dev/null @@ -1,66 +0,0 @@ - -#ifndef __cxz_darray_cc_h__ -#define __cxz_darray_cc_h__ - -#include "darray.h" - -namespace CNORXZ -{ - /**************** - * DArray * - ***************/ - - template - DArray::DArray(const RangePtr& range) : - MDArrayBase(range), mCont(range->size()) - {} - - template - DArray::DArray(const RangePtr& range, const Vector& vec) : - MDArrayBase(range), mCont(vec) - {} - - template - DArray::DArray(const RangePtr& range, Vector&& vec) : - MDArrayBase(range), mCont(vec) - {} - - template - SizeT DArray::pmax() const - { - return mCont.size(); - } - - template - const T* DArray::data() const - { - return mCont.data(); - } - - template - T* DArray::data() - { - return mCont.data(); - } - - template - typename DArray::const_iterator DArray::cbegin() const - { - return const_iterator(mCont.data(), AB::mRange); - } - - template - typename DArray::const_iterator DArray::cend() const - { - return const_iterator(mCont.data(), AB::mRange, mCont.size()); - } - - template - bool DArray::isView() const - { - return false; - } - -} - -#endif diff --git a/src/include/array/marray.cc.h b/src/include/array/marray.cc.h new file mode 100644 index 0000000..ad60d53 --- /dev/null +++ b/src/include/array/marray.cc.h @@ -0,0 +1,66 @@ + +#ifndef __cxz_marray_cc_h__ +#define __cxz_marray_cc_h__ + +#include "marray.h" + +namespace CNORXZ +{ + /**************** + * MArray * + ***************/ + + template + MArray::MArray(const RangePtr& range) : + ArrayBase(range), mCont(range->size()) + {} + + template + MArray::MArray(const RangePtr& range, const Vector& vec) : + ArrayBase(range), mCont(vec) + {} + + template + MArray::MArray(const RangePtr& range, Vector&& vec) : + ArrayBase(range), mCont(vec) + {} + + template + SizeT MArray::pmax() const + { + return mCont.size(); + } + + template + const T* MArray::data() const + { + return mCont.data(); + } + + template + T* MArray::data() + { + return mCont.data(); + } + + template + typename MArray::const_iterator MArray::cbegin() const + { + return const_iterator(mCont.data(), AB::mRange); + } + + template + typename MArray::const_iterator MArray::cend() const + { + return const_iterator(mCont.data(), AB::mRange, mCont.size()); + } + + template + bool MArray::isView() const + { + return false; + } + +} + +#endif diff --git a/src/include/array/darray.h b/src/include/array/marray.h similarity index 53% rename from src/include/array/darray.h rename to src/include/array/marray.h index 10ba083..67be01d 100644 --- a/src/include/array/darray.h +++ b/src/include/array/marray.h @@ -1,26 +1,26 @@ -#ifndef __cxz_darray_h__ -#define __cxz_darray_h__ +#ifndef __cxz_marray_h__ +#define __cxz_marray_h__ -#include "darray_base.h" +#include "array_base.h" namespace CNORXZ { template - class DArray : public MDArrayBase + class MArray : public ArrayBase { public: - typedef DArrayBase AB; + typedef CArrayBase AB; typedef typename AB::const_iterator const_iterator; - using DArrayBase::operator[]; - using MDArrayBase::operator[]; + using CArrayBase::operator[]; + using ArrayBase::operator[]; - DEFAULT_MEMBERS(DArray); - DArray(const RangePtr& range); - DArray(const RangePtr& range, const Vector& vec); - DArray(const RangePtr& range, Vector&& vec); + DEFAULT_MEMBERS(MArray); + MArray(const RangePtr& range); + MArray(const RangePtr& range, const Vector& vec); + MArray(const RangePtr& range, Vector&& vec); virtual SizeT pmax() const override; virtual const T* data() const override; diff --git a/src/include/operation/op_types.cc.h b/src/include/operation/op_types.cc.h index 01a1ac9..d641f8d 100644 --- a/src/include/operation/op_types.cc.h +++ b/src/include/operation/op_types.cc.h @@ -61,7 +61,7 @@ namespace CNORXZ ***************/ template - constexpr COpRoot::COpRoot(const DArrayBase& a, const Sptr& ind) : + constexpr COpRoot::COpRoot(const CArrayBase& a, const Sptr& ind) : mData(a.data()), mIndex(ind) {} @@ -227,7 +227,7 @@ namespace CNORXZ ****************/ template - constexpr OpRoot::OpRoot(MDArrayBase& a, const Sptr& ind) : + constexpr OpRoot::OpRoot(ArrayBase& a, const Sptr& ind) : mData(a.data()), mIndex(ind) {} diff --git a/src/include/operation/op_types.h b/src/include/operation/op_types.h index b622c80..bc6607c 100644 --- a/src/include/operation/op_types.h +++ b/src/include/operation/op_types.h @@ -5,7 +5,7 @@ #include "base/base.h" #include "xpr/xpr_base.h" -#include "array/darray_base.h" +#include "array/array_base.h" namespace CNORXZ { @@ -72,7 +72,7 @@ namespace CNORXZ constexpr COpRoot() = default; - constexpr COpRoot(const DArrayBase& a, const Sptr& ind); + constexpr COpRoot(const CArrayBase& a, const Sptr& ind); constexpr COpRoot(const T* data, const Sptr& ind); constexpr COpRoot& init(const T* data, const Sptr& ind); @@ -141,7 +141,7 @@ namespace CNORXZ constexpr OpRoot() = default; - constexpr OpRoot(MDArrayBase& a, const Sptr& ind); + constexpr OpRoot(ArrayBase& a, const Sptr& ind); constexpr OpRoot(T* data, const Sptr& ind); constexpr OpRoot& init(T* data, const Sptr& ind); diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 99c276a..47cb4f9 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -17,10 +17,10 @@ add_dependencies(rutest cnorxz) target_link_libraries(rutest ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cnorxz test_lib) add_test(NAME rutest COMMAND rutest) -add_executable(dautest darray_unit_test.cc) -add_dependencies(dautest cnorxz) -target_link_libraries(dautest ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cnorxz test_lib) -add_test(NAME dautest COMMAND dautest) +add_executable(mautest marray_unit_test.cc) +add_dependencies(mautest cnorxz) +target_link_libraries(mautest ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cnorxz test_lib) +add_test(NAME mautest COMMAND mautest) add_executable(oputest operation_unit_test.cc) add_dependencies(oputest cnorxz) diff --git a/src/tests/darray_unit_test.cc b/src/tests/marray_unit_test.cc similarity index 85% rename from src/tests/darray_unit_test.cc rename to src/tests/marray_unit_test.cc index 08333a9..9ceac8e 100644 --- a/src/tests/darray_unit_test.cc +++ b/src/tests/marray_unit_test.cc @@ -13,11 +13,11 @@ namespace using namespace CNORXZ; using Test::Numbers; - class DA_1D_Test : public ::testing::Test + class MA_1D_Test : public ::testing::Test { protected: - DA_1D_Test() + MA_1D_Test() { mSize = 7; mCR1 = CRangeFactory(mSize).create(); @@ -27,11 +27,11 @@ namespace RangePtr mCR1; }; - class DA_2D_Test : public ::testing::Test + class MA_2D_Test : public ::testing::Test { protected: - DA_2D_Test() + MA_2D_Test() { mSize = 5; mStrMeta = { "another", "test", "string", "vector", "for", "this", "Test" }; @@ -45,9 +45,9 @@ namespace RangePtr mUR1; }; - TEST_F(DA_1D_Test, Basics) + TEST_F(MA_1D_Test, Basics) { - const DArray a(mCR1, Numbers::get(0,mSize)); + const MArray a(mCR1, Numbers::get(0,mSize)); auto crx = std::dynamic_pointer_cast(mCR1); EXPECT_EQ(a.size(), mSize); EXPECT_FALSE(a.isView()); @@ -62,11 +62,11 @@ namespace EXPECT_THROW({a.at(ei);}, std::runtime_error); } - TEST_F(DA_2D_Test, Basics) + TEST_F(MA_2D_Test, Basics) { const SizeT ssize = mStrMeta.size(); const SizeT size = mSize * ssize; - const DArray a(mCR1*mUR1, Numbers::get(0,size)); + const MArray a(mCR1*mUR1, Numbers::get(0,size)); EXPECT_EQ(a.range()->dim(), 2u); EXPECT_EQ(a.size(), size); EXPECT_EQ(a.pmax(), size);