3 * Functions to facilitate the conversion of a ex to a function pointer suited for
4 * fast numerical integration.
9 * GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany
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.
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.
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
26 #ifndef __GINAC_EXCOMPILER_H__
27 #define __GINAC_EXCOMPILER_H__
39 * Function pointer with one function parameter.
41 typedef double (*FUNCP_1P) (double);
44 * Function pointer with two function parameters.
46 typedef double (*FUNCP_2P) (double, double);
49 * Function pointer for use with the CUBA library (http://www.feynarts.de/cuba).
51 typedef void (*FUNCP_CUBA) (const int*, const double[], const int*, double[]);
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.
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
63 void compile_ex(const ex& expr, const symbol& sym, FUNCP_1P& fp, const std::string filename = "");
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.
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
75 void compile_ex(const ex& expr, const symbol& sym1, const symbol& sym2, FUNCP_2P& fp, const std::string filename = "");
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.
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
87 void compile_ex(const lst& exprs, const lst& syms, FUNCP_CUBA& fp, const std::string filename = "");
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
94 * @param filename Name of the so-file to open and link
95 * @param fp Returned function pointer
97 void link_ex(const std::string filename, FUNCP_1P& fp);
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
104 * @param filename Name of the so-file to open and link
105 * @param fp Returned function pointer
107 void link_ex(const std::string filename, FUNCP_2P& fp);
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
114 * @param filename Name of the so-file to open and link
115 * @param fp Returned function pointer
117 void link_ex(const std::string filename, FUNCP_CUBA& fp);
120 * Closes all linked .so files that have the supplied filename.
122 * @param filename Name of the so-file to close
124 void unlink_ex(const std::string filename);
128 #endif // ndef __GINAC_EXCOMPILER_H__