Adding a C or C++ Code to The SageMath

162 views
Skip to first unread message

Hosein Hadipour

unread,
Jun 5, 2020, 2:17:38 PM6/5/20
to sage-devel
Dear all,

I am going to add an open source tool implemented by C, and C++ languages to one of the SageMath modules. In order to linking it to the Sage, I am going to use Cython. However, I don't know in which sage directory should I place the C or C++ source codes., if I want to add it to the Sage? I would be most grateful if someone helps me regarding this question. Thank you in advance for your helps.

Kind regards, 
Hosein

Dima Pasechnik

unread,
Jun 5, 2020, 5:01:21 PM6/5/20
to sage-devel
On Fri, Jun 5, 2020 at 7:17 PM Hosein Hadipour <hsn.ha...@gmail.com> wrote:
>
> Dear all,
>
> I am going to add an open source tool implemented by C, and C++ languages to one of the SageMath modules. In order to linking it to the Sage, I am going to use Cython. However, I don't know in which sage directory should I place the C or C++ source codes., if I want to add it to the Sage? I would be most grateful if someone helps me regarding this question. Thank you in advance for your helps.
>

if this tool is an executable or a library, it doesn't need to have
its source in SageMath at all.
It stays separate, only the interface makes it into SageMath modules.

HTH
Dima

> Kind regards,
> Hosein
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/d7ab8146-7f8f-4a03-9335-3ba5337bd487o%40googlegroups.com.

Hosein Hadipour

unread,
Jun 7, 2020, 10:38:42 AM6/7/20
to sage-devel
Thanks for your reply. What I actually want to do, is implementing the body of the following function inside the [SymbolicLogic](https://github.com/sagemath/sage/blob/develop/src/sage/logic/logic.py) class :


    def simplify(self, table):
       """
       Call a C++ implementation of the ESPRESSO algorithm to simplify the
       given truth table.
       .. TODO::
           Implement this method.
       EXAMPLES::
           sage: log = SymbolicLogic()
           sage: s = log.statement("a&b|!(c|a)")
           sage: t = log.truthtable(s)
           sage: log.simplify(t)
           Traceback (most recent call last):
           ...
           NotImplementedError
       """
       raise NotImplementedError

FYI: The Espresso has been already implemented by C++ language, and I want to add it to the Sage. I have access to both the source code and it's binary object file. However this is the first time I want to add something to the Sage, and I would be most grateful if you let me know how, and where can I start this contribution. Thank you in advance for your time, and efforts. 

Cheers, 
Hosein



On Saturday, June 6, 2020 at 1:31:21 AM UTC+4:30, Dima Pasechnik wrote:
On Fri, Jun 5, 2020 at 7:17 PM Hosein Hadipour <hsn.h...@gmail.com> wrote:
>
> Dear all,
>
> I am going to add an open source tool implemented by C, and C++ languages to one of the SageMath modules. In order to linking it to the Sage, I am going to use Cython. However, I don't know in which sage directory should I place the C or C++ source codes., if I want to add it to the Sage? I would be most grateful if someone helps me regarding this question. Thank you in advance for your helps.
>

if this tool is an executable or a library, it doesn't need to have
its source in SageMath at all.
It stays separate, only the interface makes it into SageMath modules.

HTH
Dima

> Kind regards,
> Hosein
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-...@googlegroups.com.
Message has been deleted

Hosein Hadipour

unread,
Jun 13, 2020, 2:17:51 PM6/13/20
to sage-devel
Hello all!

I would be most grateful if someone let me know how I should start. It would be fine if you introduced to me, a simple example which has been already implented in Sage, so thst I could review it. Thanks for your time.

Cheers,
Hosein

Matthias Koeppe

unread,
Jun 13, 2020, 8:50:00 PM6/13/20
to sage-devel

friedri...@gmail.com

unread,
Jul 9, 2022, 10:24:11 AM7/9/22
to sage-devel
Hi all,

I just stumbled across this thread :) and am curious, what the best way would be to add ESPRESSO to sage.
Judging the package type for ESPRESSO from the sage packaging doc referenced by Matthias, I'd say its definitly not a pip package ;) however I'm not sure I understand the difference between a "normal" and a "script" package. It says, a normal package comes from a tarball, so we'd need a source of that for ESPRESSO, i.e. a tar archive containing the source code as well as a build environment - should this be based on autotools? But I assume an equivalent build environment needs to be available for a script package, too?

So far I'm not aware of any ESPRESSO distribution that would provide, e.g., an autotools based build (https://github.com/Gigantua/Espresso/tree/main/src gives for example only a Visual Studio project which will not help for including it in sage, I assume?).

Thus, first step would be to write an autotools build for ESPRESSO, is that right?

Vincent Delecroix

unread,
Jul 9, 2022, 2:00:40 PM7/9/22
to sage-devel
Autotools is convenient but definitely not mandatory. cmake does a
similar job. Some projects (eg flint, PARI/GP) have a home made build
system that works fine.

What is required is:
* a configuration step that let us specify the build directory,
install directory, compilers, static versus dynamic library, etc. This
is typically done via a configure script.
* a build step, typically a target of the Makefile, eg "make build"
* an installation step, typically a target of the Makefile, eg "make install"
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/447c823c-80ec-4613-9568-1185d4b9b0b0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages