Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-6c6b863
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SWIGLALOmega.i
Go to the documentation of this file.
1//
2// Copyright (C) 2011--2014 Karl Wette
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/// \defgroup SWIGLALOmega_i Interface SWIGLALOmega.i
22/// \ingroup lal_swig
23/// \brief SWIG code which must appear \e after the LAL headers.
24/// \author Karl Wette
25///
26
27///
28/// # Specialised wrapping of <tt>gsl_rng</tt>
29///
30
31///
32/// Wrap the <tt>gsl_rng</tt> class.
33typedef struct {
34 %extend {
35 /// <ul><li>
36
37 /// Construct a new <tt>gsl_rng</tt> from another <tt>gsl_rng</tt>.
38 gsl_rng(const gsl_rng* rng) {
39 XLAL_CHECK_NULL(rng != NULL, XLAL_EFAULT);
40 return gsl_rng_clone(rng);
41 }
42
43 /// </li><li>
44
45 /// Construct a new <tt>gsl_rng</tt> from a generator name and random seed.
46 gsl_rng(const char* name, unsigned long int seed) {
47 XLAL_CHECK_NULL(name != NULL, XLAL_EFAULT, "Generator name must be non-NULL");
48 gsl_rng_env_setup();
49 const gsl_rng_type* T = NULL;
50 if (strcmp(name, "default") == 0) {
51 T = gsl_rng_default;
52 } else {
53 const gsl_rng_type **types = gsl_rng_types_setup();
54 for (const gsl_rng_type **t = types; *t != NULL; ++t) {
55 if (strcmp(name, (*t)->name) == 0) {
56 T = *t;
57 break;
58 }
59 }
60 }
61 XLAL_CHECK_NULL(T != NULL, XLAL_EINVAL, "Could not find generator named '%s'", name);
62 gsl_rng* rng = gsl_rng_alloc(T);
63 gsl_rng_set(rng, seed);
64 return rng;
65 }
66
67 /// </li><li>
68
69 /// Destroy a <tt>gsl_rng</tt>.
70 ~gsl_rng() {
71 %swiglal_struct_call_dtor(gsl_rng_free, $self);
72 }
73
74 /// </li><li>
75
76 /// Properties and methods of a <tt>gsl_rng</tt>, most of which map to \c
77 /// gsl_rng_...() functions.
78 const char* name();
79 double uniform();
80 double uniform_pos();
81 unsigned long int uniform_int(unsigned long int n);
82 void set_seed(unsigned long int seed) {
83 gsl_rng_set($self, seed);
84 }
85 unsigned long int get_value() {
86 return gsl_rng_get($self);
87 }
88 unsigned long int max_value() {
89 return gsl_rng_max($self);
90 }
91 unsigned long int min_value() {
92 return gsl_rng_min($self);
93 }
94
95 /// </li></ul>
96 }
97} gsl_rng;
98///
99
100///
101/// # Specialised wrapping of <tt>LIGOTimeGPS</tt>
102///
103
104///
105/// Extend the <tt>LIGOTimeGPS</tt> class.
106%extend tagLIGOTimeGPS {
107 /// <ul><li>
108
109 /// Construct a new <tt>LIGOTimeGPS</tt> from a real number.
110 tagLIGOTimeGPS(REAL8 t) {
111 return XLALGPSSetREAL8(%swiglal_new_instance(LIGOTimeGPS), t);
112 }
113
114 /// </li><li>
115
116 /// Construct a new <tt>LIGOTimeGPS</tt> from integer seconds and nanoseconds.
117 tagLIGOTimeGPS(INT4 gpssec) {
118 return XLALGPSSet(%swiglal_new_instance(LIGOTimeGPS), gpssec, 0);
119 }
120 tagLIGOTimeGPS(INT4 gpssec, INT8 gpsnan) {
121 return XLALGPSSet(%swiglal_new_instance(LIGOTimeGPS), gpssec, gpsnan);
122 }
123
124 /// </li><li>
125
126 /// Construct a new <tt>LIGOTimeGPS</tt> from a string
127 tagLIGOTimeGPS(const char *str) {
128 XLAL_CHECK_NULL(str != NULL, XLAL_EFAULT);
129 LIGOTimeGPS *gps = %swiglal_new_instance(LIGOTimeGPS);
130 char *end = NULL;
131 if (XLALStrToGPS(gps, str, &end) < 0 || *end != '\0') {
132 XLALFree(gps);
133 XLAL_ERROR_NULL(XLAL_EINVAL, "'%s' is not a valid LIGOTimeGPS", str);
134 }
135 return gps;
136 }
137
138 /// </li><li>
139
140 /// Operators are implemented by defining Python-style <tt>__operator__</tt> methods (since LAL is
141 /// C99, we don't have C++ operators available). Many SWIG language modules will automatically
142 /// map these functions to scripting-language operations in their runtime code. In some cases
143 /// (ironically, Python itself when using <tt>-builtin</tt>!) additional directives are needed in
144 /// the scripting-language-specific interface. Note that although C LIGOTimeGPS objects are
145 /// naturally mutable, the SWIG version is exported as an immutable type to emulate other numeric
146 /// types like floats and ints (we do not implement <tt>.__iadd__()</tt> and other in-place
147 /// operators). In Python this allows LIGOTimeGPS objects to be used as dictionary keys, just as
148 /// other numbers can be.
149
150 /// </li><li>
151
152 /// Return new <tt>LIGOTimeGPS</tt> which are the positive and negative values of
153 /// <tt>$self</tt>.
154 LIGOTimeGPS* __pos__() {
155 return XLALINT8NSToGPS(%swiglal_new_instance(LIGOTimeGPS), +XLALGPSToINT8NS($self));
156 }
157 LIGOTimeGPS* __neg__() {
158 return XLALINT8NSToGPS(%swiglal_new_instance(LIGOTimeGPS), -XLALGPSToINT8NS($self));
159 }
160
161 /// </li><li>
162
163 /// Return a new <tt>LIGOTimeGPS</tt> which is the absolute value of <tt>$self</tt>.
164 LIGOTimeGPS* __abs__() {
165 return XLALINT8NSToGPS(%swiglal_new_instance(LIGOTimeGPS), llabs(XLALGPSToINT8NS($self)));
166 }
167
168 /// </li><li>
169
170 /// Return whether a <tt>LIGOTimeGPS</tt> is non-zero.
171 bool __nonzero__() {
172 return $self->gpsSeconds || $self->gpsNanoSeconds;
173 }
174
175 /// </li><li>
176
177 /// Return integer representations of the <tt>LIGOTimeGPS</tt> seconds.
178 int __int__() {
179 return $self->gpsSeconds;
180 }
181 long __long__() {
182 return $self->gpsSeconds;
183 }
184
185 /// </li><li>
186
187 /// Return a floating-point representation of a <tt>LIGOTimeGPS</tt>.
188 double __float__() {
189 return XLALGPSGetREAL8($self);
190 }
191
192 /// </li><li>
193
194 /// Return a string representation of a <tt>LIGOTimeGPS</tt>. Because XLALGPSToStr() allocates a new
195 /// string using LAL memory, %newobject is used to make SWIG use a 'newfree' typemap, where the
196 /// string is freed; SWIG will have already copied it to a native scripting-language string to
197 /// return as output.
198 %newobject __str__;
199 %typemap(newfree) char* __str__ "XLALFree($1);";
200 char* __str__() {
201 return XLALGPSToStr(NULL, $self);
202 }
203 %newobject __repr__;
204 %typemap(newfree) char* __repr__ "XLALFree($1);";
205 char* __repr__() {
206 return XLALStringAppendFmt(NULL, "LIGOTimeGPS(%d, %d)", $self->gpsSeconds, $self->gpsNanoSeconds);
207 }
208 %newobject asutcstr;
209 %typemap(newfree) char* asutcstr "XLALFree($1);";
210 char* asutcstr() {
211 LIGOTimeGPS gps;
212 /* use XLALGPSSet() to normalize the nanoseconds */
213 XLALGPSSet(&gps, $self->gpsSeconds, $self->gpsNanoSeconds);
214 if (gps.gpsNanoSeconds < 0) {
215 gps.gpsSeconds -= 1;
217 }
218 struct tm utc;
220 char datebuf[256] = {0};
221 const size_t datelen = strftime(datebuf, sizeof(datebuf), "%a, %d %b %Y %H:%M:%S", &utc);
222 XLAL_CHECK_NULL(datelen > 0, XLAL_ESYS);
223 XLAL_CHECK_NULL(datelen < sizeof(datebuf), XLAL_ESYS);
224 char nsbuf[256] = {0};
225 if (gps.gpsNanoSeconds != 0) {
226 const int nslen = snprintf(nsbuf, sizeof(nsbuf), ".%09ld", (long) gps.gpsNanoSeconds);
227 XLAL_CHECK_NULL(nslen > 0, XLAL_ESYS);
228 XLAL_CHECK_NULL(nslen < (int)sizeof(nsbuf), XLAL_ESYS);
229 char *end = nsbuf + nslen;
230 while (*(--end) == '0') {
231 *end = 0;
232 }
233 }
234 return XLALStringAppendFmt(NULL, "%s%s +0000", datebuf, nsbuf);
235 }
236
237 /// </li><li>
238
239 /// Return the hash value of a <tt>LIGOTimeGPS</tt>.
240 long __hash__() {
241 long hash = (long)$self->gpsSeconds ^ (long)$self->gpsNanoSeconds;
242 return hash == -1 ? -2 : hash;
243 }
244
245 /// </li><li>
246
247 /// Binary operators need only be implemented for two <tt>LIGOTimeGPS</tt> arguments; the specialised
248 /// input typemaps defined above will then allow other suitable types to be substituted as
249 /// arguments. In some cases, however, we do implement special cases for some types to avoid
250 /// loss of precision.
251
252 /// </li><li>
253
254 /// Return the addition of two <tt>LIGOTimeGPS</tt>.
255 LIGOTimeGPS* __add__(LIGOTimeGPS* gps) {
256 LIGOTimeGPS* retn = %swiglal_new_copy(*$self, LIGOTimeGPS);
257 return XLALGPSAddGPS(retn, gps);
258 }
259 LIGOTimeGPS* __radd__(LIGOTimeGPS* gps) {
260 LIGOTimeGPS* retn = %swiglal_new_copy(*gps, LIGOTimeGPS);
261 return XLALGPSAddGPS(retn, $self);
262 }
263
264 /// </li><li>
265
266 /// Return the subtraction of two <tt>LIGOTimeGPS</tt>.
267 LIGOTimeGPS* __sub__(LIGOTimeGPS* gps) {
268 LIGOTimeGPS* retn = %swiglal_new_copy(*$self, LIGOTimeGPS);
269 return XLALGPSSubGPS(retn, gps);
270 }
271 LIGOTimeGPS* __rsub__(LIGOTimeGPS* gps) {
272 LIGOTimeGPS* retn = %swiglal_new_copy(*gps, LIGOTimeGPS);
273 return XLALGPSSubGPS(retn, $self);
274 }
275
276 /// </li><li>
277
278 /// Return the multiplication of a <tt>LIGOTimeGPS</tt> by a number or another <tt>LIGOTimeGPS</tt>. A special
279 /// typemap is needed for Python: since built-in types call the same function for both normal and
280 /// reverse operators, so the function must support (LIGOTimeGPS, LIGOTimeGPS), (LIGOTimeGPS,
281 /// double), and (double, LIGOTimeGPS) as inputs.
282 %typemap(in, noblock=1, fragment=SWIG_AsVal_frag(double)) struct tagLIGOTimeGPS* self (LIGOTimeGPS tmp, void *argp = 0, int res = 0, int self_set = 0, int factor_set = 0) {
283 res = SWIG_ConvertPtr($input, &argp, $descriptor, $disown | %convertptr_flags);
284 if (SWIG_IsOK(res)) {
285 arg1 = %reinterpret_cast(argp, $ltype);
286 self_set = 1;
287 } else {
288 res = SWIG_AsVal(double)($input, &arg2);
289 if (SWIG_IsOK(res)) {
290 factor_set = 1;
291 } else {
292 res = swiglal_specialised_tagLIGOTimeGPS($input, &tmp);
293 if (SWIG_IsOK(res)) {
294 arg1 = &tmp;
295 self_set = 1;
296 } else {
297 %argument_fail(res, "$type", $symname, $argnum);
298 }
299 }
300 }
301 }
302 %typemap(in, noblock=1, fragment=SWIG_AsVal_frag(double)) double factor (LIGOTimeGPS tmp, void *argp = 0, int res = 0) {
303 if (!self_set1) {
304 res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_tagLIGOTimeGPS, $disown | %convertptr_flags);
305 if (SWIG_IsOK(res)) {
306 arg1 = %reinterpret_cast(argp, LIGOTimeGPS*);
307 self_set1 = 1;
308 }
309 }
310 if (!factor_set1) {
311 res = SWIG_AsVal(double)($input, &arg2);
312 if (SWIG_IsOK(res)) {
313 factor_set1 = 1;
314 } else {
315 res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_tagLIGOTimeGPS, $disown | %convertptr_flags);
316 if (SWIG_IsOK(res)) {
317 arg2 = XLALGPSGetREAL8(%reinterpret_cast(argp, LIGOTimeGPS*));
318 factor_set1 = 1;
319 } else {
320 res = swiglal_specialised_tagLIGOTimeGPS($input, &tmp);
321 if (SWIG_IsOK(res)) {
322 arg2 = XLALGPSGetREAL8(&tmp);
323 factor_set1 = 1;
324 }
325 }
326 }
327 }
328 if (!self_set1 || !factor_set1) {
329 %argument_fail(res, "$type", $symname, $argnum);
330 }
331 }
332 LIGOTimeGPS* __mul__(double factor) {
333 LIGOTimeGPS* retn = %swiglal_new_copy(*$self, LIGOTimeGPS);
334 return XLALGPSMultiply(retn, factor);
335 }
336 LIGOTimeGPS* __rmul__(double factor) {
337 LIGOTimeGPS* retn = %swiglal_new_copy(*$self, LIGOTimeGPS);
338 return XLALGPSMultiply(retn, factor);
339 }
340 %clear struct tagLIGOTimeGPS* self;
341 %clear double factor;
342
343 /// </li><li>
344
345 /// Return the floating-point division of a <tt>LIGOTimeGPS</tt> by a number.
346 LIGOTimeGPS* __div__(double divisor) {
347 LIGOTimeGPS* retn = %swiglal_new_copy(*$self, LIGOTimeGPS);
348 return XLALGPSDivide(retn, divisor);
349 }
350 LIGOTimeGPS* __div__(LIGOTimeGPS* gps) {
351 LIGOTimeGPS* retn = %swiglal_new_copy(*$self, LIGOTimeGPS);
352 return XLALGPSDivide(retn, XLALGPSGetREAL8(gps));
353 }
354 LIGOTimeGPS* __rdiv__(LIGOTimeGPS* gps) {
355 LIGOTimeGPS* retn = %swiglal_new_copy(*gps, LIGOTimeGPS);
356 return XLALGPSDivide(retn, XLALGPSGetREAL8($self));
357 }
358
359 /// </li><li>
360
361 /// Return the integer division of two <tt>LIGOTimeGPS</tt>.
362 LIGOTimeGPS* __floordiv__(LIGOTimeGPS* gps) {
363 LIGOTimeGPS* retn = %swiglal_new_copy(*$self, LIGOTimeGPS);
364 return XLALGPSSetREAL8(retn, floor(XLALGPSGetREAL8(XLALGPSDivide(retn, XLALGPSGetREAL8(gps)))));
365 }
366 LIGOTimeGPS* __rfloordiv__(LIGOTimeGPS* gps) {
367 LIGOTimeGPS* retn = %swiglal_new_copy(*gps, LIGOTimeGPS);
368 return XLALGPSSetREAL8(retn, floor(XLALGPSGetREAL8(XLALGPSDivide(retn, XLALGPSGetREAL8($self)))));
369 }
370
371 /// </li><li>
372
373 /// Return the modulus of two <tt>LIGOTimeGPS</tt>.
374 LIGOTimeGPS* __mod__(LIGOTimeGPS* gps) {
375 LIGOTimeGPS* retn = %swiglal_new_copy(*$self, LIGOTimeGPS);
376 return XLALGPSSetREAL8(retn, fmod(XLALGPSGetREAL8(retn), XLALGPSGetREAL8(gps)));
377 }
378 LIGOTimeGPS* __rmod__(LIGOTimeGPS* gps) {
379 LIGOTimeGPS* retn = %swiglal_new_copy(*gps, LIGOTimeGPS);
380 return XLALGPSSetREAL8(retn, fmod(XLALGPSGetREAL8(retn), XLALGPSGetREAL8($self)));
381 }
382
383 /// </li><li>
384
385 /// Comparison operators between two <tt>LIGOTimeGPS</tt> are generated by the following SWIG macro. NAME
386 /// is the name of the Python operator and OP is the C operator. The correct comparison NAME is
387 /// obtained by comparing the result of XLALGPSCmp() against zero using OP.
388 %define %swiglal_LIGOTimeGPS_comparison_operator(NAME, OP)
389 bool __##NAME##__(LIGOTimeGPS *gps, int SWIGLAL_CMP_OP_RETN_HACK) {
390 return XLALGPSCmp($self, gps) OP 0;
391 }
392 %enddef
393 %swiglal_LIGOTimeGPS_comparison_operator(lt, < );
394 %swiglal_LIGOTimeGPS_comparison_operator(le, <=);
395 %swiglal_LIGOTimeGPS_comparison_operator(eq, ==);
396 %swiglal_LIGOTimeGPS_comparison_operator(ne, !=);
397 %swiglal_LIGOTimeGPS_comparison_operator(gt, > );
398 %swiglal_LIGOTimeGPS_comparison_operator(ge, >=);
399
400 /// </li><li>
401
402 /// Return the number of nanoseconds in a <tt>LIGOTimeGPS</tt>.
403 INT8 ns() {
404 return XLALGPSToINT8NS($self);
405 }
406
407 /// </li></ul>
408}
409///
410
411///
412/// # Specialised wrapping of <tt>LALUnit</tt>
413///
414
415///
416/// Extend the <tt>LALUnit</tt> class.
417%extend tagLALUnit {
418 /// <ul><li>
419
420 /// Construct a new <tt>LALUnit</tt> class from a string.
421 tagLALUnit(const char* str) {
422 LALUnit* unit = %swiglal_new_instance(LALUnit);
423 if (XLALParseUnitString(unit, str) == NULL) {
424 XLALFree(unit);
425 XLALSetErrno(XLAL_EFUNC); /* Silently signal an error to wrapper function */
426 return NULL;
427 }
428 return unit;
429 }
430
431 /// </li><li>
432
433 /// Return whether a <tt>LALUnit</tt> is non-zero, i.e. dimensionless.
434 bool __nonzero__() {
435 return !XLALUnitIsDimensionless($self);
436 }
437
438 /// </li><li>
439
440 /// Return integer representations of a <tt>LALUnit</tt>.
441 int __int__() {
442 return (int)XLALUnitPrefactor($self);
443 }
444 long __long__() {
445 return (long)XLALUnitPrefactor($self);
446 }
447
448 /// </li><li>
449
450 /// Return a floating-point representation of a <tt>LALUnit</tt>.
451 double __float__() {
452 return XLALUnitPrefactor($self);
453 }
454
455 /// </li><li>
456
457 /// Return a string representation of a <tt>LALUnit</tt>. Because XLALUnitToString() allocates a new
458 /// string using LAL memory, %newobject is used to make SWIG use a 'newfree' typemap, where the
459 /// string is freed; SWIG will have already copied it to a native scripting-language string to
460 /// return as output.
461 %newobject __str__;
462 %typemap(newfree) char* __str__ "XLALFree($1);";
463 char* __str__() {
464 LALUnit norm = *$self;
465 assert(XLALUnitNormalize(&norm) == XLAL_SUCCESS);
466 return XLALUnitToString(&norm);
467 }
468 %newobject __repr__;
469 %typemap(newfree) char* __repr__ "XLALFree($1);";
470 char* __repr__() {
471 LALUnit norm = *$self;
472 assert(XLALUnitNormalize(&norm) == XLAL_SUCCESS);
473 return XLALUnitToString(&norm);
474 }
475
476 /// </li><li>
477
478 /// Return the hash value of a <tt>LALUnit</tt>.
479 long __hash__() {
480 long hash = (long)$self->powerOfTen;
481 for (size_t i = 0; i < LALNumUnits; ++i) {
482 hash ^= (long)$self->unitNumerator;
483 hash ^= (long)$self->unitDenominatorMinusOne;
484 }
485 return hash == -1 ? -2 : hash;
486 }
487
488 /// </li><li>
489
490 /// Return the integer exponentiation of a <tt>LALUnit</tt>.
491 LALUnit* __pow__(INT2 n, void* SWIGLAL_OP_POW_3RDARG) {
492 LALUnit* retn = %swiglal_new_instance(LALUnit);
493 return XLALUnitRaiseINT2(retn, $self, n);
494 }
495
496 /// </li><li>
497
498 /// Return the rational exponentiation of a <tt>LALUnit</tt>.
499 LALUnit* __pow__(INT2 r[2], void* SWIGLAL_OP_POW_3RDARG) {
500 if (r[1] == 0) {
501 XLALSetErrno(XLAL_EDOM); /* Silently signal an error to wrapper function */
502 return NULL;
503 }
504 RAT4 rat;
505 rat.numerator = (r[1] < 0) ? -r[0] : r[0];
506 rat.denominatorMinusOne = abs(r[1]) - 1;
507 LALUnit* retn = %swiglal_new_instance(LALUnit);
508 return XLALUnitRaiseRAT4(retn, $self, &rat);
509 }
510
511 /// </li><li>
512
513 /// Return the multiplication of two <tt>LALUnit</tt>.
514 LALUnit* __mul__(LALUnit* unit) {
515 LALUnit* retn = %swiglal_new_instance(LALUnit);
516 return XLALUnitMultiply(retn, $self, unit);
517 }
518 LALUnit* __rmul__(LALUnit* unit) {
519 LALUnit* retn = %swiglal_new_instance(LALUnit);
520 return XLALUnitMultiply(retn, unit, $self);
521 }
522
523 /// </li><li>
524
525 /// Return the division of two <tt>LALUnit</tt>.
526 LALUnit* __div__(LALUnit* unit) {
527 LALUnit* retn = %swiglal_new_instance(LALUnit);
528 return XLALUnitDivide(retn, $self, unit);
529 }
530 LALUnit* __rdiv__(LALUnit* unit) {
531 LALUnit* retn = %swiglal_new_instance(LALUnit);
532 return XLALUnitDivide(retn, unit, $self);
533 }
534
535 /// </li><li>
536
537 /// Comparison operators between two <tt>LALUnit</tt>.
538 bool __eq__(LALUnit* unit, int SWIGLAL_CMP_OP_RETN_HACK) {
539 return XLALUnitCompare($self, unit) == 0;
540 }
541 bool __ne__(LALUnit* unit, int SWIGLAL_CMP_OP_RETN_HACK) {
542 return XLALUnitCompare($self, unit) != 0;
543 }
544
545 /// </li><li>
546
547 /// Return a normalised <tt>LALUnit</tt>.
548 %newobject norm;
549 LALUnit* norm() {
550 LALUnit* retn = %swiglal_new_instance(LALUnit);
551 *retn = *$self;
552 assert(XLALUnitNormalize(retn) == XLAL_SUCCESS);
553 return retn;
554 }
555
556 /// </li></ul>
557}
558///
559
560// Local Variables:
561// mode: c
562// End:
#define XLAL_BILLION_INT4
Definition: Date.h:39
int XLALStrToGPS(LIGOTimeGPS *t, const char *nptr, char **endptr)
Parse an ASCII string into a LIGOTimeGPS structure.
Definition: StrToGPS.c:91
static size_t hash(const char *s)
Definition: LALDict.c:51
char * XLALStringAppendFmt(char *s, const char *fmt,...)
Append the formatted string 'fmt' to the string 's', which is reallocated with XLALRealloc() to the r...
Definition: LALString.c:69
static _LAL_INLINE_ int lt(void *params, const void *a, const void *b, int(*compar)(void *, const void *, const void *))
Definition: SearchSorted.c:7
const char *const name
type name
Definition: UserInput.c:193
char * XLALGPSToStr(char *, const LIGOTimeGPS *t)
Return a string containing the ASCII base 10 representation of a LIGOTimeGPS.
Definition: StrToGPS.c:274
double REAL8
Double precision real floating-point number (8 bytes).
int16_t INT2
Two-byte signed integer.
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
int32_t INT4
Four-byte signed integer.
@ LALNumUnits
The number of units.
Definition: LALDatatypes.h:480
#define XLALFree(p)
Definition: LALMalloc.h:47
static const INT4 r
Definition: Random.c:82
int XLALUnitIsDimensionless(const LALUnit *unit)
Return 1 if a unit is dimensionless, 0 otherwise.
Definition: UnitCompare.c:36
int XLALUnitCompare(const LALUnit *unit1, const LALUnit *unit2)
Returns 0 if the the normal form of the two unit structures are the same or > 0 if they are different...
Definition: UnitCompare.c:90
REAL8 XLALUnitPrefactor(const LALUnit *unit)
Return the unit's prefactor.
Definition: UnitCompare.c:51
LALUnit * XLALParseUnitString(LALUnit *output, const char *string)
Returns the pointer output upon return or a pointer to newly allocated memory if output was NULL; on ...
Definition: UnitDefs.c:354
char * XLALUnitToString(const LALUnit *input)
Allocates and returns a new string, which is populated with the unit string.
Definition: UnitDefs.c:332
LALUnit * XLALUnitDivide(LALUnit *output, const LALUnit *unit1, const LALUnit *unit2)
UNDOCUMENTED.
Definition: UnitMultiply.c:108
LALUnit * XLALUnitMultiply(LALUnit *output, const LALUnit *unit1, const LALUnit *unit2)
This function multiplies together the LALUnit structures *(input->unitOne) and *(input->unitTwo),...
Definition: UnitMultiply.c:64
int XLALUnitNormalize(LALUnit *unit)
Returns 0 upon success or XLAL_FAILURE if the input pointer is NULL, in which case xlalErrno is set t...
Definition: UnitNormalize.c:72
LALUnit * XLALUnitRaiseRAT4(LALUnit *output, const LALUnit *input, const RAT4 *power)
Raises a LALUnit structure to a rational power given by the RAT4 structure power.
Definition: UnitRaise.c:56
LALUnit * XLALUnitRaiseINT2(LALUnit *output, const LALUnit *input, INT2 power)
Raises a LALUnit structure to an integer power power.
Definition: UnitRaise.c:106
struct tm * XLALGPSToUTC(struct tm *utc, INT4 gpssec)
Returns a pointer to a tm structure representing the time specified in seconds since the GPS epoch.
#define XLAL_ERROR_NULL(...)
Macro to invoke a failure from a XLAL routine returning a pointer.
Definition: XLALError.h:713
int XLALSetErrno(int errnum)
Sets the XLAL error number to errnum, returns the new value.
Definition: XLALError.c:327
#define XLAL_CHECK_NULL(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns a pointe...
Definition: XLALError.h:825
@ XLAL_SUCCESS
Success return value (not an error number)
Definition: XLALError.h:401
@ XLAL_EFAULT
Invalid pointer.
Definition: XLALError.h:408
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
Definition: XLALError.h:462
@ XLAL_EDOM
Input domain error.
Definition: XLALError.h:410
@ XLAL_ESYS
System error.
Definition: XLALError.h:442
@ XLAL_EINVAL
Invalid argument.
Definition: XLALError.h:409
LIGOTimeGPS * XLALGPSDivide(LIGOTimeGPS *gps, REAL8 x)
Divide a GPS time by a number.
Definition: XLALTime.c:290
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
Sets GPS time given GPS seconds as a REAL8.
Definition: XLALTime.c:73
LIGOTimeGPS * XLALGPSSet(LIGOTimeGPS *epoch, INT4 gpssec, INT8 gpsnan)
Sets GPS time given GPS integer seconds and residual nanoseconds.
Definition: XLALTime.c:63
LIGOTimeGPS * XLALGPSSubGPS(LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
Difference between two GPS times.
Definition: XLALTime.c:144
int XLALGPSCmp(const LIGOTimeGPS *t0, const LIGOTimeGPS *t1)
Compares two GPS times.
Definition: XLALTime.c:174
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
Returns the GPS time as a REAL8.
Definition: XLALTime.c:91
LIGOTimeGPS * XLALGPSAddGPS(LIGOTimeGPS *epoch, const LIGOTimeGPS *dt)
Adds two GPS times.
Definition: XLALTime.c:117
LIGOTimeGPS * XLALGPSMultiply(LIGOTimeGPS *gps, REAL8 x)
Multiply a GPS time by a number.
Definition: XLALTime.c:228
LIGOTimeGPS * XLALINT8NSToGPS(LIGOTimeGPS *epoch, INT8 ns)
Converts nano seconds stored as an INT8 to GPS time.
Definition: XLALTime.c:46
INT8 XLALGPSToINT8NS(const LIGOTimeGPS *epoch)
Converts GPS time to nano seconds stored as an INT8.
Definition: XLALTime.c:36
This structure stores units in the mksA system (plus Kelvin, Strain, and ADC Count).
Definition: LALDatatypes.h:498
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
Definition: LALDatatypes.h:458
INT4 gpsSeconds
Seconds since 0h UTC 6 Jan 1980.
Definition: LALDatatypes.h:459
INT4 gpsNanoSeconds
Residual nanoseconds.
Definition: LALDatatypes.h:460
A four-byte rational number, used as a parameter structure for XLALUnitRaiseRAT4().
Definition: Units.h:144
INT2 numerator
The numerator.
Definition: Units.h:145
UINT2 denominatorMinusOne
One less than the denominator.
Definition: Units.h:146