Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56511 - sandbox/numeric_adaptor/boost/numeric_adaptor
From: barend.gehrels_at_[hidden]
Date: 2009-10-02 10:22:24


Author: barendgehrels
Date: 2009-10-02 10:22:23 EDT (Fri, 02 Oct 2009)
New Revision: 56511
URL: http://svn.boost.org/trac/boost/changeset/56511

Log:
Added define NUMERIC_ADAPTOR_INCLUDED for working with GGL
Added std::string constructors
Bugfix in GMP streaming
Text files modified:
   sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp | 9 +++++++++
   sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp | 29 +++++++++++++++++++++++------
   sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp | 3 +++
   3 files changed, 35 insertions(+), 6 deletions(-)

Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/cln_value_type.hpp 2009-10-02 10:22:23 EDT (Fri, 02 Oct 2009)
@@ -12,7 +12,11 @@
 
 // CLN can be downloaded from http://www.ginac.de/CLN/
 
+#define NUMERIC_ADAPTOR_INCLUDED
+
+
 #include <ostream>
+#include <string>
 
 #include <cln/cln.h>
 #include <cln/float.h>
@@ -48,6 +52,11 @@
         m_value = s;
     }
 
+ cln_value_type(std::string const& s)
+ : cln_value_type(s.c_str())
+ {
+ }
+
 
     cln_value_type(cln::cl_F const& v)
         : m_value(v)

Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/gmp_value_type.hpp 2009-10-02 10:22:23 EDT (Fri, 02 Oct 2009)
@@ -11,6 +11,13 @@
 #define BOOST_NUMERIC_ADAPTOR_GMP_VALUE_TYPE_HPP
 
 
+#define NUMERIC_ADAPTOR_INCLUDED
+
+
+#include <cmath>
+#include <ostream>
+#include <string>
+
 #include <gmp.h>
 
 
@@ -36,6 +43,12 @@
         mpf_set_str(m_value, s, 10);
     }
 
+ gmp_value_type(std::string const& s)
+ {
+ mpf_init(m_value);
+ mpf_set_str(m_value, s.c_str(), 10);
+ }
+
 
     gmp_value_type(mpf_t& v)
     {
@@ -143,17 +156,21 @@
     {
         mp_exp_t exponent;
 
- char* s = mpf_get_str(NULL, &exponent, 10, 0, v.m_value);
+ char s[256];
+ mpf_get_str(s, &exponent, 10, 0, v.m_value);
 
- if (exponent != 0)
+ char* p = s;
+ if (*p == '-')
         {
- os << "0." << s << "e" << exponent;
+ os << "-";
+ p++;
         }
- else
+
+ os << "0." << p;
+ if (exponent != 0)
         {
- os << s;
+ os << "e" << exponent;
         }
- free(s);
         return os;
     }
 

Modified: sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp
==============================================================================
--- sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp (original)
+++ sandbox/numeric_adaptor/boost/numeric_adaptor/numeric_adaptor.hpp 2009-10-02 10:22:23 EDT (Fri, 02 Oct 2009)
@@ -11,6 +11,9 @@
 #define BOOST_NUMERIC_ADAPTOR_NUMERIC_ADAPTOR_HPP
 
 
+#define NUMERIC_ADAPTOR_INCLUDED
+
+
 #include <cmath>
 #include <boost/static_assert.hpp>
 #include <boost/math/special_functions/hypot.hpp>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk