From ebdf3d5128364a5351e64d471c5f8412e46e815e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 17 Jul 2018 09:36:43 +0900 Subject: [PATCH] [nest] Add 'DomainInfo' class (#669) This commit adds 'DomainInfo' class which records dimensionalities of domain. Signed-off-by: Jonghyun Park --- contrib/nest/include/nest/DomainInfo.h | 32 ++++++++++++++++++++++++++++++++ contrib/nest/src/DomainInfo.test.cpp | 14 ++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 contrib/nest/include/nest/DomainInfo.h create mode 100644 contrib/nest/src/DomainInfo.test.cpp diff --git a/contrib/nest/include/nest/DomainInfo.h b/contrib/nest/include/nest/DomainInfo.h new file mode 100644 index 0000000..d4a39fb --- /dev/null +++ b/contrib/nest/include/nest/DomainInfo.h @@ -0,0 +1,32 @@ +#ifndef __NEST_DOMAIN_INFO_H__ +#define __NEST_DOMAIN_INFO_H__ + +#include +#include + +#include + +namespace nest +{ + +class DomainInfo +{ +public: + DomainInfo(std::initializer_list dims) : _dims{dims} + { + // DO NOTHING + } + +public: + uint32_t rank(void) const { return _dims.size(); } + +public: + uint32_t dim(uint32_t axis) const { return _dims.at(axis); } + +private: + std::vector _dims; +}; + +} // namespace nest + +#endif // __NEST_DOMAIN_INFO_H__ diff --git a/contrib/nest/src/DomainInfo.test.cpp b/contrib/nest/src/DomainInfo.test.cpp new file mode 100644 index 0000000..9aed452 --- /dev/null +++ b/contrib/nest/src/DomainInfo.test.cpp @@ -0,0 +1,14 @@ +#include "nest/DomainInfo.h" + +#include + +TEST(DOMAIN_INFO, ctor) +{ + nest::DomainInfo info{1, 2, 3, 4}; + + ASSERT_EQ(info.rank(), 4); + ASSERT_EQ(info.dim(0), 1); + ASSERT_EQ(info.dim(1), 2); + ASSERT_EQ(info.dim(2), 3); + ASSERT_EQ(info.dim(3), 4); +} -- 2.7.4