Skip to content

Instantly share code, notes, and snippets.

@coyotte508
Last active December 18, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coyotte508/5737059 to your computer and use it in GitHub Desktop.
Save coyotte508/5737059 to your computer and use it in GitHub Desktop.
diff --git a/pythran/pythonic++/modules/math.h b/pythran/pythonic++/modules/math.h
index 1701f47..df1f189 100644
--- a/pythran/pythonic++/modules/math.h
+++ b/pythran/pythonic++/modules/math.h
@@ -1,6 +1,8 @@
#ifndef PYTHONIC_MODULE_MATH_H
#define PYTHONIC_MODULE_MATH_H
+#include <gmpxx.h>
+
namespace pythonic {
namespace math {
using std::acos;
@@ -74,6 +76,14 @@ namespace pythonic {
template<class T>
double radians(T x) { return (x * 2. * pi) / 360.; }
+ /* sqrt(mpz_class) returns an int, while a square of a long in python
+ * returns a floating point number.
+ *
+ * So even if it's ugly we have to convert the number to a float, */
+ double sqrt(const mpz_class &mpz) {
+ return std::sqrt(mpz.get_d());
+ }
+
PROXY(pythonic::math,isinf);
PROXY(pythonic::math,modf);
PROXY(pythonic::math,frexp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment