Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALMathNDPlotTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Chad Hanna, 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/* ______________________________________________________________________________________
21 * File name: LALMathNDPlotTest.c
22 *
23 * Author: Hanna C. R.
24 * ______________________________________________________________________________________
25 */
26
27/**
28 * \author Hanna, C.R.
29 * \file
30 * \ingroup LALMathematica_h
31 *
32 * \brief Tests LALMathNDPlot().
33 *
34 * \code
35 * LALMathNDPlotTest
36 * \endcode
37 *
38 * ### Description ###
39 *
40 * This program generates a set of points simulating a 4-D template bank and calls
41 * LALMathNDPlot() to generate a MATHEMATICA notebook to display the permutations of
42 * 3D projections of the template bank. Instructions on how to evaluate the notebook
43 * appear when it is opened.
44 *
45 */
46
47#include <math.h>
48#include <stdio.h>
49#include <stdlib.h>
50#include <string.h>
51#include <sys/types.h>
52#include <sys/stat.h>
53#include <lal/AVFactories.h>
54#include <lal/LALConfig.h>
55#include <lal/LALMalloc.h>
56#include <lal/LALStatusMacros.h>
57#include <lal/LALStdlib.h>
58#include <lal/LALMathematica.h>
59
60/**\name Error Codes */ /** @{ */
61#define LALMATHNDPLOTTESTC_ENORM 0 /**< Normal exit */
62#define LALMATHNDPLOTTESTC_EMEM 1 /**< Memory allocation error */
63#define LALMATHNDPLOTTESTC_ESUB 2 /**< Subroutine error */
64/** @} */
65
66/** \cond DONT_DOXYGEN */
67
68#define LALMATHNDPLOTTESTC_MSGENORM "Normal exit"
69#define LALMATHNDPLOTTESTC_MSGEMEM "Memory allocation error"
70#define LALMATHNDPLOTTESTC_MSGESUB "Subroutine error"
71
72
73int main(void){
74 static LALStatus status;
75 INT4 loopx = 0; /* loop counters */
76 INT4 loopy = 0;
77 INT4 loopz = 0;
78 INT4 loopw = 0;
79 INT4 ntiles = 0;
80 MathNDPointList *list = NULL; /* Pointer to structure for mathematica plot */
81 MathNDPointList *first = NULL;
82 UINT4 dim = 4;
83
84 if ((list = (MathNDPointList *) LALCalloc(1, sizeof(MathNDPointList))) == NULL){
85 LALError(&status, LALMATHNDPLOTTESTC_MSGEMEM);
86 printf(LALMATHNDPLOTTESTC_MSGEMEM);
88 }
89 first=list;
90
91 for(loopx=1; loopx <= 20; loopx++){
92 for(loopy=1; loopy <= 20; loopy++){
93 for(loopz=0; loopz <= 1; loopz++){
94 for(loopw=0; loopw <= 1; loopw++){
95 LALSCreateVector(&status, &list->coordinates, dim);
96 list->coordinates->data[0] = loopx;
97 list->coordinates->data[1] = loopy;
98 list->coordinates->data[2] = loopz;
99 list->coordinates->data[3] = loopw;
100 list->grayLevel = 0.0;
101 ntiles++;
102 if ((list = list->next = (MathNDPointList *) LALCalloc(1, sizeof(MathNDPointList))) == NULL){
103 LALError(&status, LALMATHNDPLOTTESTC_MSGEMEM);
104 printf(LALMATHNDPLOTTESTC_MSGEMEM);
106 }
107 }
108 }
109 }
110 }
111
112 for(loopx=1; loopx <= 20; loopx++){
113 for(loopy=1; loopy <= 20; loopy++){
114 for(loopw=0; loopw <= 1; loopw++){
115 LALSCreateVector(&status, &list->coordinates, dim);
116 list->coordinates->data[0] = loopx;
117 list->coordinates->data[1] = loopy;
118 list->coordinates->data[2] = 2;
119 list->coordinates->data[3] = loopw;
120 list->grayLevel = 1.0;
121 ntiles++;
122 if ((list = list->next = (MathNDPointList *) LALCalloc(1, sizeof(MathNDPointList))) == NULL){
123 LALError(&status, LALMATHNDPLOTTESTC_MSGEMEM);
124 printf(LALMATHNDPLOTTESTC_MSGEMEM);
126 }
127 }
128 }
129 }
130
131 /* LAL!!! */
132 for(loopx=1; loopx <= 20; loopx++){
133 for(loopy=1; loopy <= 20; loopy++){
134 for(loopz=3; loopz <= 4; loopz++){
135 for(loopw=0; loopw <=1; loopw++){
136 if( ((loopx==6)||(loopx==19)) && (loopy<16) && (loopy>5)) continue;
137 if((loopy==15)&&(((loopx<20)&&(loopx>14))||((loopx<7)&&(loopx>1)))) continue;
138 if((loopx>9)&&(loopx<12)&&(((loopy>6)&&(loopy<10))||(loopy==12))) continue;
139 if(((loopx==9)||(loopx==12)) && ((loopy>9)&&(loopy<13))) continue;
140 if(((loopx==8)||(loopx==13)) && ((loopy>12)&&(loopy<16))) continue;
141 LALSCreateVector(&status, &list->coordinates, dim);
142 if (status.statusCode){
143 LALError(&status, LALMATHNDPLOTTESTC_MSGESUB);
144 printf(LALMATHNDPLOTTESTC_MSGESUB);
146 }
147 list->coordinates->data[0] = loopx;
148 list->coordinates->data[1] = loopy;
149 list->coordinates->data[2] = loopz;
150 list->coordinates->data[3] = loopw;
151 list->grayLevel = 0.0;
152 ntiles++;
153 if ((list = list->next = (MathNDPointList *) LALCalloc(1, sizeof(MathNDPointList))) == NULL){
154 LALError(&status, LALMATHNDPLOTTESTC_MSGEMEM);
155 printf(LALMATHNDPLOTTESTC_MSGEMEM);
157 }
158 }
159 }
160 }
161 }
162
163
164 list->next = NULL;
165 printf("\nCalling LALMathNDPlot()......\n");
166 LALMathNDPlot(&status, first, &ntiles, NULL);
168 if (status.statusCode){
169 LALError(&status, LALMATHNDPLOTTESTC_MSGESUB);
170 printf(LALMATHNDPLOTTESTC_MSGESUB);
172 }
173
174
175 /* Clean Up the memory from the MathPlot3D structure */
176 list = first;
177 while(list->next){
178 first = list->next;
179 if (list->coordinates)
181 if (status.statusCode){
182 LALError(&status, LALMATHNDPLOTTESTC_MSGESUB);
183 printf(LALMATHNDPLOTTESTC_MSGESUB);
185 }
186 LALFree(list);
187 if (status.statusCode){
188 LALError(&status, LALMATHNDPLOTTESTC_MSGEMEM);
189 printf(LALMATHNDPLOTTESTC_MSGEMEM);
191 }
192 list = first;
193 }
194
195
196 /* free the last (first?) memory allocated for Math3DPlot. */
197 if(list) LALFree(list);
198
199 if (status.statusCode)
201 else
203
204}
205/** \endcond */
void REPORTSTATUS(LALStatus *status)
Definition: LALError.c:322
#define LALError(statusptr, statement)
Definition: LALError.h:95
#define LALCalloc(m, n)
Definition: LALMalloc.h:94
#define LALFree(p)
Definition: LALMalloc.h:96
#define LALMATHNDPLOTTESTC_ENORM
Normal exit.
#define LALMATHNDPLOTTESTC_ESUB
Subroutine error.
#define LALMATHNDPLOTTESTC_EMEM
Memory allocation error.
int main(int argc, char *argv[])
Definition: cache.c:25
uint32_t UINT4
Four-byte unsigned integer.
int32_t INT4
Four-byte signed integer.
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
void LALSDestroyVector(LALStatus *, REAL4Vector **)
void LALSCreateVector(LALStatus *, REAL4Vector **, UINT4)
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
This type is similar to Math3DPointList except the coordinates are stored as data in the REAL4Vector ...
REAL4Vector * coordinates
struct tagMathNDPointList * next
REAL4 * data
Pointer to the data array.
Definition: LALDatatypes.h:150