X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fexcompiler.h;h=7122fef4da699fdb696092eead997961f6ae0d41;hp=0c1ca3a843bc657727e0a4253ba7ed4ee2662859;hb=7d7131d3af3de5425b7fe80b1f587740294371bc;hpb=541c2950a84f2e0a19edae0da44ad2d317824ec4 diff --git a/ginac/excompiler.h b/ginac/excompiler.h index 0c1ca3a8..7122fef4 100644 --- a/ginac/excompiler.h +++ b/ginac/excompiler.h @@ -1,10 +1,12 @@ /** @file excompiler.h * - * Class to facilitate the conversion of a ex to a function pointer suited for - * fast numerical integration. */ + * Functions to facilitate the conversion of a ex to a function pointer suited for + * fast numerical integration. + * + */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,23 +26,102 @@ #ifndef __GINAC_EXCOMPILER_H__ #define __GINAC_EXCOMPILER_H__ -#include "basic.h" -#include "config.h" -#include "ex.h" +#include + +#include "lst.h" namespace GiNaC { -#ifdef HAVE_LIBDL +class ex; +class symbol; -typedef double (*FP_dim1) (double); +/** + * Function pointer with one function parameter. + */ +typedef double (*FUNCP_1P) (double); -FP_dim1 compile(const ex& expr, const symbol& sym); +/** + * Function pointer with two function parameters. + */ +typedef double (*FUNCP_2P) (double, double); -typedef void (*FP_cuba) (const int*, const double[], const int*, double[]); +/** + * Function pointer for use with the CUBA library (http://www.feynarts.de/cuba). + */ +typedef void (*FUNCP_CUBA) (const int*, const double[], const int*, double[]); -FP_cuba compile(const lst& exprs, const lst& syms); +/** + * Takes an expression and produces a function pointer to the compiled and linked + * C code equivalent in double precision. The function pointer has type FUNCP_1P. + * + * @param expr Expression to be compiled + * @param sym Symbol from the expression to become the function parameter + * @param fp Returned function pointer + * @param filename Name of the intermediate source code and so-file. If + * supplied, these intermediate files will not be deleted + */ +void compile_ex(const ex& expr, const symbol& sym, FUNCP_1P& fp, const std::string filename = ""); + +/** + * Takes an expression and produces a function pointer to the compiled and linked + * C code equivalent in double precision. The function pointer has type FUNCP_2P. + * + * @param expr Expression to be compiled + * @param sym Symbol from the expression to become the function parameter + * @param fp Returned function pointer + * @param filename Name of the intermediate source code and so-file. If + * supplied, these intermediate files will not be deleted + */ +void compile_ex(const ex& expr, const symbol& sym1, const symbol& sym2, FUNCP_2P& fp, const std::string filename = ""); -#endif +/** + * Takes an expression and produces a function pointer to the compiled and linked + * C code equivalent in double precision. The function pointer has type FUNCP_CUBA. + * + * @param expr Expression to be compiled + * @param sym Symbol from the expression to become the function parameter + * @param fp Returned function pointer + * @param filename Name of the intermediate source code and so-file. If + * supplied, these intermediate files will not be deleted + */ +void compile_ex(const lst& exprs, const lst& syms, FUNCP_CUBA& fp, const std::string filename = ""); + +/** + * Opens an existing so-file and returns a function pointer of type FUNCP_1P to + * the contained function. The so-file has to be generated by compile_ex in + * advance. + * + * @param filename Name of the so-file to open and link + * @param fp Returned function pointer + */ +void link_ex(const std::string filename, FUNCP_1P& fp); + +/** + * Opens an existing so-file and returns a function pointer of type FUNCP_2P to + * the contained function. The so-file has to be generated by compile_ex in + * advance. + * + * @param filename Name of the so-file to open and link + * @param fp Returned function pointer + */ +void link_ex(const std::string filename, FUNCP_2P& fp); + +/** + * Opens an existing so-file and returns a function pointer of type FUNCP_CUBA to + * the contained function. The so-file has to be generated by compile_ex in + * advance. + * + * @param filename Name of the so-file to open and link + * @param fp Returned function pointer + */ +void link_ex(const std::string filename, FUNCP_CUBA& fp); + +/** + * Closes all linked .so files that have the supplied filename. + * + * @param filename Name of the so-file to close + */ +void unlink_ex(const std::string filename); } // namespace GiNaC