]> www.ginac.de Git - ginac.git/blob - ginac/excompiler.h
inifscn_nstdsums: make functions handling Li/G transformations reentrant.
[ginac.git] / ginac / excompiler.h
1 /** @file excompiler.h
2  *
3  *  Functions to facilitate the conversion of a ex to a function pointer suited for
4  *  fast numerical integration.
5  *
6  */
7
8 /*
9  *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  */
25
26 #ifndef __GINAC_EXCOMPILER_H__
27 #define __GINAC_EXCOMPILER_H__
28
29 #include <string>
30
31 #include "lst.h"
32
33 namespace GiNaC {
34
35 class ex;
36 class symbol;
37
38 /**
39  * Function pointer with one function parameter.
40  */
41 typedef double (*FUNCP_1P) (double);
42
43 /**
44  * Function pointer with two function parameters.
45  */
46 typedef double (*FUNCP_2P) (double, double);
47
48 /**
49  * Function pointer for use with the CUBA library (http://www.feynarts.de/cuba).
50  */
51 typedef void (*FUNCP_CUBA) (const int*, const double[], const int*, double[]);
52
53 /**
54  * Takes an expression and produces a function pointer to the compiled and linked
55  * C code equivalent in double precision. The function pointer has type FUNCP_1P.
56  *
57  * @param expr Expression to be compiled
58  * @param sym Symbol from the expression to become the function parameter
59  * @param fp Returned function pointer
60  * @param filename Name of the intermediate source code and so-file. If
61  * supplied, these intermediate files will not be deleted
62  */
63 void compile_ex(const ex& expr, const symbol& sym, FUNCP_1P& fp, const std::string filename = "");
64
65 /**
66  * Takes an expression and produces a function pointer to the compiled and linked
67  * C code equivalent in double precision. The function pointer has type FUNCP_2P.
68  *
69  * @param expr Expression to be compiled
70  * @param sym Symbol from the expression to become the function parameter
71  * @param fp Returned function pointer
72  * @param filename Name of the intermediate source code and so-file. If
73  * supplied, these intermediate files will not be deleted
74  */
75 void compile_ex(const ex& expr, const symbol& sym1, const symbol& sym2, FUNCP_2P& fp, const std::string filename = "");
76
77 /**
78  * Takes an expression and produces a function pointer to the compiled and linked
79  * C code equivalent in double precision. The function pointer has type FUNCP_CUBA.
80  *
81  * @param expr Expression to be compiled
82  * @param sym Symbol from the expression to become the function parameter
83  * @param fp Returned function pointer
84  * @param filename Name of the intermediate source code and so-file. If
85  * supplied, these intermediate files will not be deleted
86  */
87 void compile_ex(const lst& exprs, const lst& syms, FUNCP_CUBA& fp, const std::string filename = "");
88
89 /** 
90  * Opens an existing so-file and returns a function pointer of type FUNCP_1P to
91  * the contained function. The so-file has to be generated by compile_ex in
92  * advance.
93  *
94  * @param filename Name of the so-file to open and link
95  * @param fp Returned function pointer
96  */
97 void link_ex(const std::string filename, FUNCP_1P& fp);
98
99 /** 
100  * Opens an existing so-file and returns a function pointer of type FUNCP_2P to
101  * the contained function. The so-file has to be generated by compile_ex in
102  * advance.
103  *
104  * @param filename Name of the so-file to open and link
105  * @param fp Returned function pointer
106  */
107 void link_ex(const std::string filename, FUNCP_2P& fp);
108
109 /** 
110  * Opens an existing so-file and returns a function pointer of type FUNCP_CUBA to
111  * the contained function. The so-file has to be generated by compile_ex in
112  * advance.
113  *
114  * @param filename Name of the so-file to open and link
115  * @param fp Returned function pointer
116  */
117 void link_ex(const std::string filename, FUNCP_CUBA& fp);
118
119 /**
120  * Closes all linked .so files that have the supplied filename.
121  *
122  * @param filename Name of the so-file to close
123  */
124 void unlink_ex(const std::string filename);
125
126 } // namespace GiNaC
127
128 #endif // ndef __GINAC_EXCOMPILER_H__