From 7083ae7ca48bec343986b4b95b5a4716a3c208fa Mon Sep 17 00:00:00 2001 From: Paul Lamb Date: Sat, 8 Sep 2018 15:14:14 -0500 Subject: [PATCH 1/2] Fix bindings test on 32bit Linux --- src/nupic/bindings/engine_internal.i | 4 +++- src/nupic/ntypes/Dimensions.cpp | 12 ++++++++++++ src/nupic/ntypes/Dimensions.hpp | 14 +++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/nupic/bindings/engine_internal.i b/src/nupic/bindings/engine_internal.i index cff72d3256..c361f680fb 100644 --- a/src/nupic/bindings/engine_internal.i +++ b/src/nupic/bindings/engine_internal.i @@ -149,7 +149,9 @@ class IterablePair(object): //32bit fix - Already seen by swig on linux32 where size_t is the same size as unsigned int -#if !(defined(NTA_ARCH_32) && defined(NTA_OS_LINUX)) +#if (defined(NTA_ARCH_32) && defined(NTA_OS_LINUX)) +%template(Dimset) std::vector; +#else %template(Dimset) std::vector; #endif diff --git a/src/nupic/ntypes/Dimensions.cpp b/src/nupic/ntypes/Dimensions.cpp index 3332298b63..75af4099ae 100644 --- a/src/nupic/ntypes/Dimensions.cpp +++ b/src/nupic/ntypes/Dimensions.cpp @@ -25,6 +25,10 @@ #include #include +#if (defined(NTA_ARCH_32) && defined(NTA_OS_LINUX)) +#include +#endif + using namespace nupic; Dimensions::Dimensions(){}; @@ -32,6 +36,14 @@ Dimensions::Dimensions(){}; Dimensions::Dimensions(std::vector v) : std::vector(std::move(v)){}; +#if (defined(NTA_ARCH_32) && defined(NTA_OS_LINUX)) +Dimensions::Dimensions(std::vector v) { + for (size_t i = 0; i < v.size(); i++) { + push_back(v[i] & UINT_MAX); + } +} +#endif + Dimensions::Dimensions(size_t x) { push_back(x); } Dimensions::Dimensions(size_t x, size_t y) { diff --git a/src/nupic/ntypes/Dimensions.hpp b/src/nupic/ntypes/Dimensions.hpp index 944c8d141c..d4264278cf 100644 --- a/src/nupic/ntypes/Dimensions.hpp +++ b/src/nupic/ntypes/Dimensions.hpp @@ -98,8 +98,20 @@ class Dimensions : public std::vector { */ Dimensions(std::vector v); - /** Create a new 1-dimension Dimensions object. +#if (defined(NTA_ARCH_32) && defined(NTA_OS_LINUX)) + /** + * Create a new Dimensions object from a @c std::vector. + * + * @param v + * A @c std::vector of @c unsigned long, the value with the index of @a n + * is the size of the @a n th dimension + * + */ + Dimensions(std::vector v); +#endif + /** Create a new 1-dimension Dimensions object. + * * @param x * The size of the 1st dimension * From 4e24c7a316fcf07cf93cb6e8c9f0b4fd806e8a7b Mon Sep 17 00:00:00 2001 From: Paul Lamb Date: Thu, 13 Sep 2018 11:37:17 -0500 Subject: [PATCH 2/2] Improve comment formatting --- src/nupic/ntypes/Dimensions.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nupic/ntypes/Dimensions.hpp b/src/nupic/ntypes/Dimensions.hpp index d4264278cf..d6ef48958f 100644 --- a/src/nupic/ntypes/Dimensions.hpp +++ b/src/nupic/ntypes/Dimensions.hpp @@ -103,8 +103,8 @@ class Dimensions : public std::vector { * Create a new Dimensions object from a @c std::vector. * * @param v - * A @c std::vector of @c unsigned long, the value with the index of @a n - * is the size of the @a n th dimension + * A @c std::vector of @c unsigned long, the value with the index + * of @a n is the size of the @a n th dimension * */ Dimensions(std::vector v);