ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 11 Oct 2011 19:17:17 -0500Import GMP libraryhttp://ask.sagemath.org/question/8353/import-gmp-library/I have already installed the GMP library, Now i want to import this library to sage project i tried to put :
import libgmpxx.so.4
libgmpxx.so.4.path.append('usr/local/lib/')
but it does'nt work unfortunately, how can i do that. regardsTue, 11 Oct 2011 13:37:36 -0500http://ask.sagemath.org/question/8353/import-gmp-library/Answer by DSM for <p>I have already installed the GMP library, Now i want to import this library to sage project i tried to put :</p>
<pre><code> import libgmpxx.so.4
libgmpxx.so.4.path.append('usr/local/lib/')
</code></pre>
<p>but it does'nt work unfortunately, how can i do that. regards</p>
http://ask.sagemath.org/question/8353/import-gmp-library/?answer=12748#post-id-12748Hi! You can't simply import C or C++ libraries into Python or Sage the way you're thinking, I'm afraid. Someone needs to write a wrapper first.
With a bit of work you could get gmpy, the Python wrapper for GMP, installed, but the real question is why you would want to. Sage already contains MPIR, which is a GMP equivalent, so the good news is that your arithmetic should be at GMP speed already!
Rather than concentrating on the tool (the GMP library, for which MPIR is a fine substitute), if you describe the problem you want to address we might be able to point you in the right direction.Tue, 11 Oct 2011 15:08:16 -0500http://ask.sagemath.org/question/8353/import-gmp-library/?answer=12748#post-id-12748Answer by Jason Grout for <p>I have already installed the GMP library, Now i want to import this library to sage project i tried to put :</p>
<pre><code> import libgmpxx.so.4
libgmpxx.so.4.path.append('usr/local/lib/')
</code></pre>
<p>but it does'nt work unfortunately, how can i do that. regards</p>
http://ask.sagemath.org/question/8353/import-gmp-library/?answer=12750#post-id-12750What are you trying to do with the library? You can't import it like that, but you can interact with it as a C library using Cython. You'd have to "cimport" a specific function from the gmp header files.
Sage comes with MPIR (a fork of GMP) and uses that to implement the RealNumbers.Tue, 11 Oct 2011 19:17:17 -0500http://ask.sagemath.org/question/8353/import-gmp-library/?answer=12750#post-id-12750