LAL  7.5.0.1-b72065a
LALMathematica.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007 Chad Hanna, Jolien Creighton, Benjamin Owen
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19 
20 #ifndef _LALMATHEMATICA_H
21 #define _LALMATHEMATICA_H
22 
23 #include <math.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <lal/LALStdlib.h>
27 
28 #if defined(__cplusplus)
29 extern "C" {
30 #elif 0
31 } /* so that editors will match preceding brace */
32 #endif
33 
34 
35 /**
36  * \defgroup LALMathematica_h Header LALMathematica.h
37  * \ingroup lal_support
38  * \author Hanna, C. R.
39  *
40  * \brief Provides structures, functions and macro definitions for modules that
41  * generate MATHEMATICA notebooks.
42  *
43  * Currently, the only modules using this
44  * header file are <tt>LALMath3DPlot()</tt>, which generates 3D animated
45  * plots of template banks having three parameters and
46  * <tt>LALMathNDPlot()</tt> which plots the 3-dimensional projections of a
47  * bank that is N-dimensional.
48  *
49  * ### Synopsis ###
50  *
51  * \code
52  * #include <lal/LALMathematica.h>
53  * \endcode
54  *
55  * This header file defines macros containing MATHEMATICA syntax that is
56  * otherwise messy to implement into C source files. Here is how to use
57  * these macros to make your own program generate a MATHEMATICA notebook.
58  *
59  * <ol>
60  * <li> Open a file with a pointer named &quot;nb&quot; and a file extenstion &quot;.nb&quot;.
61  * </li><li> Use BEG_NOTEBOOK to start the notebook file.
62  * </li><li> Use the appropriate BEG and END macros with fprint(nb, &quot;Your
63  * Text&quot) in between to write your text to the cells of the notebook. If
64  * you are writing MATHEMATICA commands use the INPUT macros; for plain
65  * text, use TEXT Macros.
66  * </li><li> Denote titles and sections with the appropriate macros.
67  * </li><li> Use END_NOTEBOOK to end the notebook and use fclose(nb) to close
68  * the file &quot;nb&quot;.
69  * </li></ol>
70  *
71  * The result is very readable/changeable source similar in style to most
72  * markup languages. An example program might look like:
73  * \code
74  * FILE *nb;
75  * nb = fopen("YourFileName.nb", "rw");
76  * BEG_NOTEBOOK;
77  * BEG_TITLECELL;
78  * fprintf(nb, "Sample Program Title");
79  * END_TITLECELL_;
80  * BEG_SECTIONCELL;
81  * fprintf(nb, "Sample Program Section Name");
82  * END_SECTIONCELL;
83  * END_NOTEBOOK;
84  * fclose(nb);
85  * \endcode
86  *
87  * ### Notes ###
88  *
89  * <ul>
90  * <li> Obviously the definitions and functions associated with this header
91  * are NOT LAL compliant and thus do not belong in any lal routines except
92  * test programs.</li>
93  * <li> There are many more commands to manipulate the structure of
94  * MATHEMATICA notebooks that are not included in this header. The macros
95  * are only what is necessary for a <em>bare minimum</em> interface.</li>
96  * </ul>
97  *
98  */
99 /** @{ */
100 
101 /**\name Error Codes */ /** @{ */
102 #define LALMATHEMATICAH_ENULL 1 /**< NULL pointer to a LALMathematica.h input structure */
103 #define LALMATHEMATICAH_EFILE 2 /**< Could not open file to write a Mathematica Notebook */
104 #define LALMATHEMATICAH_EVAL 3 /**< Invalid parameter value */
105 /** @} */
106 
107 /** \cond DONT_DOXYGEN */
108 #define LALMATHEMATICAH_MSGENULL "NULL pointer to a LALMathematica.h input structure"
109 #define LALMATHEMATICAH_MSGEFILE "Could not open file to write a Mathematica Notebook"
110 #define LALMATHEMATICAH_MSGEVAL "Invalid parameter value"
111 /** \endcond */
112 
113 /**
114  * \name Macros
115  * See the source file \ref LALMath3DPlot.c for an example of how to use
116  * these macros to generate a MATHEMATICA notebook in your own program.
117  *
118  * <dl>
119  * <dt>NOTEBOOK</dt><dd>Denotes the beginning and ending of the notebook file. A
120  * BEG_NOTEBOOK tag must start the file and an END_NOTEBOOK tag must end
121  * it.</dd>
122  * <dt>TITLE</dt><dd>Placing an fprint(nb, &quot;Your Title&quot;) between BEG and END
123  * tags will place a <em>title font</em> cell in the notebook.</dd>
124  * <dt>GROUP</dt><dd>Cells placed in between these tags will be grouped together</dd>
125  * <dt>SECTION</dt><dd>Same as title except the text printed will be in
126  * <em>section font</em>. Subsequent input and text cells following the
127  * END_SECTIONCELL tag will be grouped with that section until a new
128  * BEG_SECTIONCELL tag is encountered.</dd>
129  * <dt>INPUT</dt><dd>provides cells to input MATHEMATICA commands.</dd>
130  * <dt>TEXT</dt><dd>provides cells to input plain text.</dd>
131  * </dl>
132  *
133  * Notice that the file pointer must be named &quot;nb&quot; in order to use the
134  * macros defined in this header. When grouping several cell objects
135  * together the last object in the list should have an underscored END tag
136  * instead of an END tag without an underscore. Although the notebook will
137  * compile (usually) if you use the tags without an ending underscore, the
138  * dangling comma is taken as a null member of the list of grouped cells.
139  * Therefore, when you view the notebook in MATHEMATICA you may see the
140  * word &quot;NULL&quot; printed on a line. That is an indication that you should
141  * use the underscore version of the tag which preceeded the &quot;NULL&quot;
142  * statement.
143  */
144 /** @{ */
145 #define BEG_NOTEBOOK fprintf(nb, "Notebook[{\n")
146 #define END_NOTEBOOK fprintf(nb, "}]\n")
147 #define BEG_TITLECELL fprintf(nb, "Cell[\"")
148 #define END_TITLECELL fprintf(nb, "\", \"Title\"],\n")
149 #define END_TITLECELL_ fprintf(nb, "\", \"Title\"]\n")
150 #define BEG_GROUPCELL fprintf(nb, "Cell[CellGroupData[{\n")
151 #define END_GROUPCELLC fprintf(nb, "}, Closed ]],\n")
152 #define END_GROUPCELLC_ fprintf(nb, "}, Closed ]]\n")
153 #define BEG_SECTIONCELL fprintf(nb, "Cell[\"")
154 #define END_SECTIONCELL fprintf(nb, "\", \"Section\"],\n")
155 #define END_SECTIONCELL_ fprintf(nb, "\", \"Section\"]\n")
156 #define BEG_INPUTCELL fprintf(nb, "Cell[BoxData[\\(")
157 #define END_INPUTCELL fprintf(nb, "\\)], \"Input\"],\n")
158 #define END_INPUTCELL_ fprintf(nb, "\\)], \"Input\"]\n")
159 #define BEG_TEXTCELL fprintf(nb, "Cell[\"\\<")
160 #define END_TEXTCELL fprintf(nb, "\\>\", \"Text\"],\n")
161 #define END_TEXTCELL_ fprintf(nb, "\\>\", \"Text\"]\n")
162 /** @} */
163 
164 
165 /**
166  * This type is used by \ref LALMath3DPlot.c as an input structure to plot 3-dimensional template banks.
167  * It is a linked list with
168  * parameters for each coordinate x,y,z and a next pointer. It also has a
169  * parameter called grayLevel which must be \f$\epsilon [0,1]\f$. It specifies
170  * the shading of the point in the final plot with 0 representing black and
171  * 1 representing white. By creatively assigning its value the grayscale
172  * shade of the points may convey additional information.
173  */
174 typedef struct tagMath3DPointList{
175  struct tagMath3DPointList *next;
181 
182 /**
183  * This type is similar to Math3DPointList except the coordinates are
184  * stored as data in the REAL4Vector \c coordinates.
185  */
186 typedef struct tagMathNDPointList{
187  struct tagMathNDPointList *next;
191  } MathNDPointList;
192 
193 void
195  Math3DPointList *first,
196  INT4 *ntiles,
197  REAL4 *pointSize);
198 
199 void
201  MathNDPointList *first,
202  INT4 *ntiles,
203  REAL4 *pointSize );
204 
205 /** @} */
206 
207 #if 0
208 { /* so that editors will match succeeding brace */
209 #elif defined(__cplusplus)
210 }
211 #endif
212 
213 #endif /* _LALMATHEMATICA_H */
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
void LALMath3DPlot(LALStatus *status, Math3DPointList *first, INT4 *ntiles, REAL4 *pointSize)
This function is for plotting 3D template banks by creating a MATHEMATICA notebook.
Definition: LALMath3DPlot.c:59
void LALMathNDPlot(LALStatus *status, MathNDPointList *first, INT4 *ntiles, REAL4 *pointSize)
This function is for plotting N-Dimensional template banks by creating a MATHEMATICA notebook.
Definition: LALMathNDPlot.c:66
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
This type is used by LALMath3DPlot.c as an input structure to plot 3-dimensional template banks.
struct tagMath3DPointList * next
This type is similar to Math3DPointList except the coordinates are stored as data in the REAL4Vector ...
REAL4Vector * coordinates
struct tagMathNDPointList * next
Vector of type REAL4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:145