1 /*****************************************************************************
2  *                                                                           *
3  *          UNURAN -- Universal Non-Uniform Random number generator          *
4  *                                                                           *
5  *****************************************************************************
6  *                                                                           *
7  *   FILE: functparser_source.h                                              *
8  *                                                                           *
9  *   PURPOSE:                                                                *
10  *         declares prototypes for function parser                           *
11  *                                                                           *
12  *****************************************************************************
13  *                                                                           *
14  *   Copyright (c) 2000-2006 Wolfgang Hoermann and Josef Leydold             *
15  *   Department of Statistics and Mathematics, WU Wien, Austria              *
16  *                                                                           *
17  *   This program is free software; you can redistribute it and/or modify    *
18  *   it under the terms of the GNU General Public License as published by    *
19  *   the Free Software Foundation; either version 2 of the License, or       *
20  *   (at your option) any later version.                                     *
21  *                                                                           *
22  *   This program is distributed in the hope that it will be useful,         *
23  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
24  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
25  *   GNU General Public License for more details.                            *
26  *                                                                           *
27  *   You should have received a copy of the GNU General Public License       *
28  *   along with this program; if not, write to the                           *
29  *   Free Software Foundation, Inc.,                                         *
30  *   59 Temple Place, Suite 330, Boston, MA 02111-1307, USA                  *
31  *                                                                           *
32  *****************************************************************************/
33 
34 /*---------------------------------------------------------------------------*/
35 #ifndef FUNCTPARSER_SOURCE_H_SEEN
36 #define FUNCTPARSER_SOURCE_H_SEEN
37 
38 /*---------------------------------------------------------------------------*/
39 /* Function prototypes for function string parser                            */
40 /*---------------------------------------------------------------------------*/
41 
42 struct ftreenode *_unur_fstr2tree ( const char *functstring );
43 /*---------------------------------------------------------------------------*/
44 /* Compute funtion tree from string.                                         */
45 /*---------------------------------------------------------------------------*/
46 
47 struct ftreenode *_unur_fstr2tree_DefFunct ( const char *functstring );
48 /*---------------------------------------------------------------------------*/
49 /* Compute funtion tree from string.                                         */
50 /* (Same as _unur_fstr2tree() but string must start with "f(x)=".            */
51 /*---------------------------------------------------------------------------*/
52 
53 double _unur_fstr_eval_tree ( const struct ftreenode *functtree_root, double x );
54 /*---------------------------------------------------------------------------*/
55 /* Evalutes function given by a function tree at x.                          */
56 /*---------------------------------------------------------------------------*/
57 
58 struct ftreenode *_unur_fstr_dup_tree (const struct ftreenode *functtree_root);
59 /*---------------------------------------------------------------------------*/
60 /* Duplicate function tree rooted at root.                                   */
61 /*---------------------------------------------------------------------------*/
62 
63 void _unur_fstr_free ( struct ftreenode *functtree_root );
64 /*---------------------------------------------------------------------------*/
65 /* Destroys function tree and frees memory.                                  */
66 /*---------------------------------------------------------------------------*/
67 
68 char *_unur_fstr_tree2string ( const struct ftreenode *functtree_root,
69 			       const char *variable, const char *function, int spaces );
70 /*---------------------------------------------------------------------------*/
71 /* Produce string from function tree.                                        */
72 /* It returns a pointer to the resulting string. This should be freed when   */
73 /* it is not used any more.                                                  */
74 /*---------------------------------------------------------------------------*/
75 
76 struct ftreenode *_unur_fstr_make_derivative ( const struct ftreenode *functtree_root );
77 /*---------------------------------------------------------------------------*/
78 /* Make function tree for derivate of given function (tree).                 */
79 /*---------------------------------------------------------------------------*/
80 
81 /*---------------------------------------------------------------------------*/
82 #endif   /* FUNCTPARSER_SOURCE_H_SEEN */
83 /*---------------------------------------------------------------------------*/
84 
85