blitzpp / blitz

Blitz++ Multi-Dimensional Array Library for C++
https://github.com/blitzpp/blitz/wiki
Other
405 stars 84 forks source link

WIP: Add boost::multiprecision::float128 support #45

Open Ablinne opened 6 years ago

Ablinne commented 6 years ago

Hi folks,

I have hacked this modification a few years ago while blitz development seemed quite dead to add support for the boost::multiprecision::float128 datatype.

The changes were since then sitting around in my own copy if the old hg repo on github (https://github.com/Ablinne/blitz.old). I used this for a while, but did not look into it for years. I don't even use blitz in any of my current projects...

I have now only rebased them from the hg copy onto the corresponding commit in this repository, but did not even check if it compiles. So please view this MR just as a pitch and try to see if it's worth investing more time into this enhancement.

If you do not think that blitz would benefit from something like this, just close the MR.

Best, Alex

slayoo commented 6 years ago

Thank you! For the record, here is also a relevant post from Blitz++ Sourceforge tracker:

(by https://sourceforge.net/u/sunday87 created: 2013-11-21)

Hello everyone

I am using boost::multiprecision datatypes within blitz++ arrays. In order to do so, I have modified blitz++. I hope it might be possible to incorporate support for boost::multiprecision into blitz++ so others can benefit from multiprecision in blitz++.

I have attached my patch, but it is rather hard coded and is not suitable for the main distribution. The changes would have to be made configurable (in order to still be able to use blitz without multiprecision). My experience with library packaging is not sufficient to supply an appropriate patch. Perhaps someone is willing to do this at some time.

Greetings
diff -Naur -x Makefile -x config.h blitz-0.10/blitz/compiler.h blitz-0.10-bmp/blitz/compiler.h
--- blitz-0.10/blitz/compiler.h 2012-05-11 22:11:13.000000000 +0200
+++ blitz-0.10-bmp/blitz/compiler.h 2013-11-21 15:53:17.910333000 +0100
@@ -120,13 +120,7 @@
     #error In <blitz/config.h>: Your compiler does not support enum computations.  You may have to rerun compiler/bzconfig.
 #endif

-#if defined(BZ_MATH_FN_IN_NAMESPACE_STD)
-  #define BZ_MATHFN_SCOPE(x) std::x
-#elif defined(BZ_HAVE_NAMESPACES)
-  #define BZ_MATHFN_SCOPE(x) ::x
-#else
-  #define BZ_MATHFN_SCOPE(x) x
-#endif
+#define BZ_MATHFN_SCOPE(x) x

 #if defined(BZ_MATH_ABSINT_IN_NAMESPACE_STD)
 #include <cstdlib>
@@ -134,21 +128,9 @@
 #include <stdlib.h>
 #endif

-#if defined(BZ_MATH_ABSINT_IN_NAMESPACE_STD)
-  #define BZ_MATHABSINT_SCOPE(x) std::x
-#elif defined(BZ_HAVE_NAMESPACES)
-  #define BZ_MATHABSINT_SCOPE(x) ::x
-#else
-  #define BZ_MATHABSINT_SCOPE(x) x
-#endif
+#define BZ_MATHABSINT_SCOPE(x) x

-#if defined(BZ_HAVE_COMPLEX_MATH_IN_NAMESPACE_STD)
-  #define BZ_CMATHFN_SCOPE(x) std::x
-#elif defined(BZ_HAVE_NAMESPACES)
-  #define BZ_CMATHFN_SCOPE(x) ::x
-#else
-  #define BZ_CMATHFN_SCOPE(x) x
-#endif
+#define BZ_CMATHFN_SCOPE(x) x

 #if defined(BZ_HAVE_NAMESPACES)
   #define BZ_IEEEMATHFN_SCOPE(x) ::x
diff -Naur -x Makefile -x config.h blitz-0.10/blitz/funcs.h blitz-0.10-bmp/blitz/funcs.h
--- blitz-0.10/blitz/funcs.h    2012-05-11 22:11:13.000000000 +0200
+++ blitz-0.10-bmp/blitz/funcs.h    2013-11-21 15:39:37.254381000 +0100
@@ -37,6 +37,11 @@
 #include <blitz/prettyprint.h>

 #include <cstdlib>
+#include <boost/multiprecision/float128.hpp>
+#include <boost/multiprecision/mpfr.hpp>
+
+using namespace std;
+using namespace boost::multiprecision;

 BZ_NAMESPACE(blitz)
Ablinne commented 6 years ago

Actually I am sunday87 over at sourceforge.net. I did not remember that I posted this already there almost 5 years ago...