LALDatatypes.h

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Jolien Creighton, Kipp Cannon, Reinhard Prix
00003 *
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU General Public License as published by
00006 *  the Free Software Foundation; either version 2 of the License, or
00007 *  (at your option) any later version.
00008 *
00009 *  This program is distributed in the hope that it will be useful,
00010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 *  GNU General Public License for more details.
00013 *
00014 *  You should have received a copy of the GNU General Public License
00015 *  along with with program; see the file COPYING. If not, write to the
00016 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00017 *  MA  02111-1307  USA
00018 */
00019 
00020 /** \file
00021  * \ingroup std
00022  * \author Creighton, J. D. E., and Creighton, T. D.
00023  * \date $Id: LALDatatypes.h,v 1.20 2008/02/22 16:11:08 reinhard Exp $
00024  * \brief Provides the basic LAL datatypes.
00025  *
00026  * \noindent This header defines the standard data types and data
00027  * structures that are used throughout LAL.  They fall into three general
00028  * categories: primitive datatypes, aggregates of primitive
00029  * datatypes, and structured datatypes.  The LAL status structure
00030  * is a special case of a structured datatype that is used in every
00031  * standard LAL function.
00032  * 
00033  * This header file is automatically included by the header
00034  * <tt>LALStdlib.h</tt>.  In turn, this header file starts by including the
00035  * header <tt>LALAtomicDatatypes.h</tt>.
00036  *
00037  */
00038 /********************************* <lalVerbatim file="LALDatatypesHV">
00039 Author: J. D. E. Creighton, T. D. Creighton
00040 $Id: LALDatatypes.h,v 1.20 2008/02/22 16:11:08 reinhard Exp $
00041 ********************************** </lalVerbatim> */
00042 
00043 /* <lalLaTeX>
00044 
00045 \section{Header \texttt{LALDatatypes.h}}
00046 \label{s:LALDatatypes.h}
00047 
00048 Provides the basic LAL datatypes.
00049 
00050 \subsection*{Synopsis}
00051 \begin{verbatim}
00052 #include <lal/LALDatatypes.h>
00053 \end{verbatim}
00054 
00055 \noindent This header defines the standard data types and data
00056 structures that are used throughout LAL.  They fall into three general
00057 categories: \emph{primitive} datatypes, \emph{aggregates} of primitive
00058 datatypes, and \emph{structured} datatypes.  The LAL status structure
00059 is a special case of a structured datatype that is used in every
00060 standard LAL function.
00061 
00062 This header file is automatically included by the header
00063 \verb@LALStdlib.h@.  In turn, this header file starts by including the
00064 header \verb@LALAtomicDatatypes.h@, which is discussed in the
00065 following section.
00066 
00067 </lalLaTeX> */
00068 
00069 #ifndef _LALDATATYPES_H
00070 #define _LALDATATYPES_H
00071 
00072 /* <lalLaTeX>
00073 \newpage\input{LALAtomicDatatypesH}
00074 </lalLaTeX> */
00075 #include <lal/LALAtomicDatatypes.h>
00076 
00077 /**** <lalLaTeX>
00078  * \newpage
00079  * \subsection{Atomic datatypes codes}
00080  * \label{ss:atomic-datatype-codes}
00081  * \idx[Constant]{LAL\_1\_BYTE\_TYPE\_SIZE}
00082  * \idx[Constant]{LAL\_2\_BYTE\_TYPE\_SIZE}
00083  * \idx[Constant]{LAL\_4\_BYTE\_TYPE\_SIZE}
00084  * \idx[Constant]{LAL\_8\_BYTE\_TYPE\_SIZE}
00085  * \idx[Constant]{LAL\_16\_BYTE\_TYPE\_SIZE}
00086  * \idx[Constant]{LAL\_TYPE\_SIZE\_MASK}
00087  * \idx[Constant]{LAL\_FLTPT\_TYPE\_FLAG}
00088  * \idx[Constant]{LAL\_CMPLX\_TYPE\_FLAG}
00089  * \idx[Constant]{LAL\_UNSGN\_TYPE\_FLAG}
00090  * \idx[Constant]{LAL\_CHAR\_TYPE\_CODE}
00091  * \idx[Constant]{LAL\_I2\_TYPE\_CODE}
00092  * \idx[Constant]{LAL\_I4\_TYPE\_CODE}
00093  * \idx[Constant]{LAL\_I8\_TYPE\_CODE}
00094  * \idx[Constant]{LAL\_UCHAR\_TYPE\_CODE}
00095  * \idx[Constant]{LAL\_U2\_TYPE\_CODE}
00096  * \idx[Constant]{LAL\_U4\_TYPE\_CODE}
00097  * \idx[Constant]{LAL\_U8\_TYPE\_CODE}
00098  * \idx[Constant]{LAL\_S\_TYPE\_CODE}
00099  * \idx[Constant]{LAL\_D\_TYPE\_CODE}
00100  * \idx[Constant]{LAL\_C\_TYPE\_CODE}
00101  * \idx[Constant]{LAL\_Z\_TYPE\_CODE}
00102  * \idx[Type]{LALTYPECODE}
00103  *
00104  * The following constants specify the size, in bytes, of the atomic datatype.
00105  *
00106  * \begin{center}
00107  * \begin{tabular}{|lcl|}
00108  * \hline
00109  * Name & Octal Value & Description \\
00110  * \hline
00111  * \tt LAL\_1\_BYTE\_TYPE\_SIZE & 000 & 1 byte type \\
00112  * \tt LAL\_2\_BYTE\_TYPE\_SIZE & 001 & 2 byte type \\
00113  * \tt LAL\_4\_BYTE\_TYPE\_SIZE & 002 & 4 byte type \\
00114  * \tt LAL\_8\_BYTE\_TYPE\_SIZE & 003 & 8 byte type \\
00115  * \tt LAL\_16\_BYTE\_TYPE\_SIZE & 004 & 16 byte type \\
00116  * \tt LAL\_TYPE\_SIZE\_MASK & 007 & Mask for byte type size fields \\
00117  * \hline
00118  * \end{tabular}
00119  * \end{center}
00120  *
00121  * \noindent
00122  * The constant \verb+LAL_TYPE_SIZE_MASK+ is useful in extracting the size
00123  * information from other type attributes.  For example, the size, in bytes,
00124  * of an atomic datatype can be found using something like the following:
00125  * \begin{verbatim}
00126  * UINT4 code = LAL_S_TYPE_CODE;
00127  * UINT4 size = 1U << ( code & LAL_TYPE_SIZE_MASK );
00128  * \end{verbatim}
00129  *
00130  * \vspace{3ex}
00131  *
00132  * The following constants are flags describing the type attributes.  A type
00133  * is either an integer or a floating-point, either purely real or complex,
00134  * and, if integer, is either signed or unsigned.
00135  *
00136  * \begin{center}
00137  * \begin{tabular}{|lcl|}
00138  * \hline
00139  * Name & Octal Value & Description \\
00140  * \hline
00141  * \tt LAL\_FLTPT\_TYPE\_FLAG & 010 & Floating-point (not integer) type \\
00142  * \tt LAL\_CMPLX\_TYPE\_FLAG & 020 & Complex (not purely real) type \\
00143  * \tt LAL\_UNSGN\_TYPE\_FLAG & 040 & Unsigned (no sign info) type \\
00144  * \hline
00145  * \end{tabular}
00146  * \end{center}
00147  *
00148  * To get the actual type, these flags are combined together and with the
00149  * type size constants using the bitwise-or operator (\verb+|+).  For example,
00150  * an eight-byte floating point number would be
00151  * \verb+LAL_8_BYTE_TYPE_SIZE | LAL_FLTPT_TYPE_FLAG+.
00152  * Conceivably you could have a complex type made from a pair of unsigned
00153  * one-byte integers that would be specified as
00154  * \verb+LAL_1_BYTE_TYPE_SIZE | LAL_CMPLX_TYPE_FLAG | LAL_UNSGN_TYPE_FLAG+.
00155  * Fortunately, there are none of these in LAL.  Attribues of a particular
00156  * type can be extracted using the bitwise-and operator.  For example:
00157  * \begin{verbatim}
00158  * UINT4 code = LAL_S_TYPE_CODE;
00159  * UINT4 isfloat = ( code & LAL_FLTPT_TYPE_FLAG );
00160  * UINT4 iscmplx = ( code & LAL_CMPLX_TYPE_FLAG );
00161  * \end{verbatim}
00162  *
00163  * \vspace{3ex}
00164  *
00165  * The following constants correspond to the types that actually exist in LAL.
00166  * Their enumeration is the type \verb+LALTYPECODE+.
00167  * \begin{center}
00168  * \begin{tabular}{|lcl|}
00169  * \hline
00170  * Name & Octal Value & Corresponding Type \\
00171  * \hline
00172  * \tt LAL\_CHAR\_TYPE\_CODE & 000 & \tt CHAR \\
00173  * \tt LAL\_I2\_TYPE\_CODE & 001 & \tt INT2 \\
00174  * \tt LAL\_I4\_TYPE\_CODE & 002 & \tt INT4 \\
00175  * \tt LAL\_I8\_TYPE\_CODE & 003 & \tt INT8 \\
00176  * \tt LAL\_UCHAR\_TYPE\_CODE & 040 & \tt UCHAR \\
00177  * \tt LAL\_U2\_TYPE\_CODE & 041 & \tt UINT2 \\
00178  * \tt LAL\_U4\_TYPE\_CODE & 042 & \tt UINT4 \\
00179  * \tt LAL\_U8\_TYPE\_CODE & 043 & \tt UINT8 \\
00180  * \tt LAL\_S\_TYPE\_CODE & 012 & \tt REAL4 \\
00181  * \tt LAL\_D\_TYPE\_CODE & 013 & \tt REAL8 \\
00182  * \tt LAL\_C\_TYPE\_CODE & 033 & \tt COMPLEX8 \\
00183  * \tt LAL\_Z\_TYPE\_CODE & 034 & \tt COMPLEX16 \\
00184  * \hline
00185  * \end{tabular}
00186  * \end{center}
00187  *
00188  **** </lalLaTeX> */
00189 
00190 /* constants */
00191 
00192 /** Type size constants. */
00193 enum
00194 {
00195   LAL_1_BYTE_TYPE_SIZE  = 000,   /**< One byte size 00 = 0 */
00196   LAL_2_BYTE_TYPE_SIZE  = 001,   /**< Two byte size 01 = 1 */
00197   LAL_4_BYTE_TYPE_SIZE  = 002,   /**< Four byte size 010 = 2 */
00198   LAL_8_BYTE_TYPE_SIZE  = 003,   /**< Eight byte size 011 = 3 */
00199   LAL_16_BYTE_TYPE_SIZE = 004,   /**< Sixteen byte size 0100 = 4 */
00200   LAL_TYPE_SIZE_MASK    = 007    /**< Type size mask 0111 = 7 */
00201 };
00202 
00203 /** Type flag constants. */
00204 enum
00205 {
00206   LAL_FLTPT_TYPE_FLAG   = 010,   /**< Floating-point (vs integer) type 01000 =  8 */
00207   LAL_CMPLX_TYPE_FLAG   = 020,   /**< Complex (vs real) type  010000 = 16 */
00208   LAL_UNSGN_TYPE_FLAG   = 040    /**< Unsigned (vs signed) type 0100000 = 32 */
00209 };
00210 
00211 /** Type codes: use these type codes to identify a LAL atomic data type.
00212  */
00213 typedef enum
00214 {
00215   LAL_CHAR_TYPE_CODE    = LAL_1_BYTE_TYPE_SIZE, /**< CHAR type code (0) */
00216   LAL_I2_TYPE_CODE      = LAL_2_BYTE_TYPE_SIZE, /**< INT2 type code (1) */
00217   LAL_I4_TYPE_CODE      = LAL_4_BYTE_TYPE_SIZE, /**< INT4 type code (2) */
00218   LAL_I8_TYPE_CODE      = LAL_8_BYTE_TYPE_SIZE, /**< INT8 type code (3) */
00219   LAL_UCHAR_TYPE_CODE   = LAL_1_BYTE_TYPE_SIZE | LAL_UNSGN_TYPE_FLAG,   /**< UCHAR type code (32) */
00220   LAL_U2_TYPE_CODE      = LAL_2_BYTE_TYPE_SIZE | LAL_UNSGN_TYPE_FLAG,   /**< UINT2 type code (33) */
00221   LAL_U4_TYPE_CODE      = LAL_4_BYTE_TYPE_SIZE | LAL_UNSGN_TYPE_FLAG,   /**< UINT4 type code (34) */
00222   LAL_U8_TYPE_CODE      = LAL_8_BYTE_TYPE_SIZE | LAL_UNSGN_TYPE_FLAG,   /**< UINT8 type code (35) */
00223   LAL_S_TYPE_CODE       = LAL_4_BYTE_TYPE_SIZE | LAL_FLTPT_TYPE_FLAG,   /**< REAL4 type code (18) */
00224   LAL_D_TYPE_CODE       = LAL_8_BYTE_TYPE_SIZE | LAL_FLTPT_TYPE_FLAG,   /**< REAL8 type code (19) */
00225   LAL_C_TYPE_CODE       = LAL_8_BYTE_TYPE_SIZE | LAL_CMPLX_TYPE_FLAG | LAL_FLTPT_TYPE_FLAG,     /**< COMPLEX8 type code (27) */
00226   LAL_Z_TYPE_CODE       = LAL_16_BYTE_TYPE_SIZE | LAL_CMPLX_TYPE_FLAG | LAL_FLTPT_TYPE_FLAG     /**< COMPLEX16 type code (28) */
00227 }
00228 LALTYPECODE;
00229 
00230 
00231 #include <lal/LALRCSID.h>
00232 
00233 #ifdef  __cplusplus
00234 extern "C" {
00235 #endif
00236 
00237 NRCSID (LALDATATYPESH, "$Id: LALDatatypes.h,v 1.20 2008/02/22 16:11:08 reinhard Exp $");
00238 
00239 
00240 /* <lalLaTeX>
00241 \newpage
00242 \subsection{Aggregate datatypes}
00243 \label{ss:aggregate-datatypes}
00244 
00245 These datatypes store arbitrarily large sets or collections of
00246 primitive datatypes.  At this level there is no physical
00247 interpretation assigned to the objects (such as names or units); the
00248 aggregate datatypes simply collect and arrange the primitive
00249 datatypes.  The following types of aggregate datatypes are defines:
00250 vectors, arrays, sequences, vector sequences, and array sequences.
00251 
00252 \vspace{2ex}
00253 \begin{verbatim}
00254 <datatype>Vector
00255 \end{verbatim}
00256 This structure stores an ordered set of $n$ elements of type
00257 \verb@<datatype>@, which can be any primitive datatype.  The data are
00258 to be interpreted as being a point in an $n$-dimensional vector space.
00259 The fields are:
00260 \begin{description}
00261 \item[\texttt{UINT4 length}] The number of data $n$.
00262 \item[\texttt{<datatype> *data}] Pointer to the data array.  The data
00263 are stored sequentially as \verb@data[@$0,\ldots,n-1$\verb@]@.
00264 \end{description}
00265 
00266 </lalLaTeX> */
00267 
00268 /** \name Aggregate datatypes.
00269  *
00270  * These datatypes store arbitrarily large sets or collections of
00271  * primitive datatypes.  At this level there is no physical
00272  * interpretation assigned to the objects (such as names or units); the
00273  * aggregate datatypes simply collect and arrange the primitive
00274  * datatypes.  The following types of aggregate datatypes are defines:
00275  * vectors, arrays, sequences, vector sequences, and array sequences.
00276  *
00277  * \b Vector structures store an ordered set of \a n elements of any
00278  * primative datatype.
00279  *
00280  * \b Sequence structures are synonyms for Vector structures.
00281  *
00282  * \b Array structures store a set of elements of any primative
00283  * datatype, arranged as an \a m dimensional
00284  * array.  That is, each element can be thought of as having \a m
00285  * indecies, \f$A_{i_0\cdots i_{m-1}}\f$, where each index \f$i_k\f$
00286  * runs over its own range \f$0,\ldots,n_k-1\f$.  The total number of
00287  * elements is then \f$N=n_0\times\cdots\times n_{m-1}\f$.  In memory the
00288  * array is flattened so that the elements are stored sequentially in
00289  * a contiguous block.  That is, the array of memory is packed so that
00290  * element \f$A_{i_0\cdots i_{m-1}}\f$ is stored as
00291  * \f$\mathtt{data[}i_{m-1} + n_{m-2}\times(i_{m-2} +
00292  * n_{m-3}\times(\cdots(i_1 + n_0\times i_0)\cdots))\mathtt{]}\f$.
00293  *
00294  * \b VectorSequence structures store an ordered set of \a l elements of type
00295  * \c <datatype>Vector, where \c <datatype> can be any primitive
00296  * datatype.  Mathematically the sequence can be written as
00297  * \f$\{\vec{v}^{(0)},\ldots,\vec{v}^{(l-1)}\}\f$, where each element
00298  * \f$\vec{v}^{(j)}=(v^{(j)}_0,\ldots,v^{(i)}_{n-1})\f$ is a vector of length
00299  * \f$n\f$.  In memory the elements are flattened; that is, they are
00300  * stored sequentially in a contiguous block of memory such that
00301  * element \f$v^{(j)}_i\f$ is stored as
00302  * \f$\mathtt{data[}j\times n + i\mathtt{]}\f$.
00303  *
00304  * \b ArraySequence structures stores an ordered set of \a l elements of type
00305  * \c <datatype>Array where \c <datatype> can be any primitive
00306  * datatype.  The indexing of an array sequence can get quite
00307  * complicated; it helps to read first the documentation for data arrays,
00308  * above.  Mathematically the data can be written as a set
00309  * \f$\{A^{(j)}_{i_0\cdots i_{m-1}}\f$, where the sequence number
00310  * \f$j\f$ runs from 0 to \f$l-1\f$, and each array index \f$i_k\f$ runs over its own
00311  * range \f$0,\ldots,n_k-1\f$.  The total number of data in a given array
00312  * element is then \f$N=n_0\times\cdots\times n_{m-1}\f$, and the total
00313  * number of data in the sequence is \f$N\times l\f$.  In memory the array is
00314  * flattened so that the elements are stored sequentially in a
00315  * contiguous block.
00316  * The element
00317  * \f$A^{(j)}_{i_0\cdots i_{m-1}}\f$ is stored as
00318  * \f$\mathtt{data[}j\times N + i_{m-1} + n_{m-2}\times(i_{m-2} +
00319  * n_{m-3}\times(\cdots(i_1 + n_0\times i_0)\cdots))\mathtt{]}\f$; that is,
00320  * the index of \c data[] runs over the internal indecies of each
00321  * array element before incrementing to the next array element.
00322  *
00323  */
00324 /*@{*/
00325 /** Vector of type CHAR. */
00326 typedef struct
00327 tagCHARVector
00328 {
00329   UINT4  length; /**< Number of elements in array. */
00330   CHAR  *data;   /**< Pointer to the data array. */
00331 }
00332 CHARVector;
00333 
00334 /** Vector of type CHAR*, ie 'strings'  */
00335 typedef struct {
00336   UINT4 length;  /**< Number of elements in array. */
00337   CHAR **data;   /**< Pointer to the data array. */
00338 } LALStringVector;
00339 
00340 /** Vector of type INT2. */
00341 typedef struct
00342 tagINT2Vector
00343 {
00344   UINT4  length; /**< Number of elements in array. */
00345   INT2  *data; /**< Pointer to the data array. */
00346 }
00347 INT2Vector;
00348 
00349 /** Vector of type UINT2. */
00350 typedef struct
00351 tagUINT2Vector
00352 {
00353   UINT4  length; /**< Number of elements in array. */
00354   UINT2 *data; /**< Pointer to the data array. */
00355 }
00356 UINT2Vector;
00357 
00358 /** Vector of type INT4. */
00359 typedef struct
00360 tagINT4Vector
00361 {
00362   UINT4  length; /**< Number of elements in array. */
00363   INT4  *data; /**< Pointer to the data array. */
00364 }
00365 INT4Vector;
00366 
00367 /** Vector of type UINT4. */
00368 typedef struct
00369 tagUINT4Vector
00370 {
00371   UINT4  length; /**< Number of elements in array. */
00372   UINT4  *data; /**< Pointer to the data array. */
00373 }
00374 UINT4Vector;
00375 
00376 /** Vector of type INT8. */
00377 typedef struct
00378 tagINT8Vector
00379 {
00380   UINT4  length; /**< Number of elements in array. */
00381   INT8  *data; /**< Pointer to the data array. */
00382 }
00383 INT8Vector;
00384 
00385 /** Vector of type UINT8. */
00386 typedef struct
00387 tagUINT8Vector
00388 {
00389   UINT4  length; /**< Number of elements in array. */
00390   UINT8 *data; /**< Pointer to the data array. */
00391 }
00392 UINT8Vector;
00393 
00394 /** Vector of type REAL4. */
00395 typedef struct
00396 tagREAL4Vector
00397 {
00398   UINT4  length; /**< Number of elements in array. */
00399   REAL4 *data; /**< Pointer to the data array. */
00400 }
00401 REAL4Vector;
00402 
00403 /** Vector of type REAL8. */
00404 typedef struct tagREAL8Vector
00405 {
00406   UINT4  length; /**< Number of elements in array. */
00407   REAL8 *data; /**< Pointer to the data array. */
00408 }
00409 REAL8Vector;
00410 
00411 /** Vector of type COMPLEX8. */
00412 typedef struct tagCOMPLEX8Vector
00413 {
00414   UINT4     length; /**< Number of elements in array. */
00415   COMPLEX8 *data; /**< Pointer to the data array. */
00416 }
00417 COMPLEX8Vector;
00418 
00419 /** Vector of type COMPLEX16. */
00420 typedef struct tagCOMPLEX16Vector
00421 {
00422   UINT4      length; /**< Number of elements in array. */
00423   COMPLEX16 *data; /**< Pointer to the data array. */
00424 }
00425 COMPLEX16Vector;
00426 
00427 
00428 /* <lalLaTeX>
00429 
00430 \vspace{2ex}
00431 \begin{verbatim}
00432 <datatype>Array
00433 \end{verbatim}
00434 This structure stores a set of elements of type \verb@<datatype>@,
00435 which can be any primitive datatype, arranged as an $m$-dimensional
00436 array.  That is, each element can be thought of as having $m$
00437 indecies, $\mathsf{A}_{i_0\cdots i_{m-1}}$, where each index $i_k$
00438 runs over its own range $0,\ldots,n_k-1$.  The total number of
00439 elements is then $N=n_0\times\cdots\times n_{m-1}$.  In memory the
00440 array is ``flattened'' so that the elements are stored sequentially in
00441 a contiguous block.  The fields are:
00442 \begin{description}
00443 \item[\texttt{UINT4Vector *dimLength}] Pointer to a vector of length
00444 $m$, storing the index ranges $(n_0,\ldots,n_{m-1})$.
00445 \item[\texttt{<datatype> *data}] Pointer to the data array.  The data
00446 element $\mathsf{A}_{i_0\cdots i_{m-1}}$ is stored as
00447 \verb@data[@$i_{m-1} + n_{m-2}\times(i_{m-2} +
00448 n_{m-3}\times(\cdots(i_1 + n_0\times i_0)\cdots))$\verb@]@; that is,
00449 the index of \verb@data[]@ runs over the entire range of an index
00450 $i_{k+1}$ before incrementing $i_k$.
00451 \end{description}
00452 
00453 </lalLaTeX> */
00454 
00455 /** Multidimentional array of INT2. */
00456 typedef struct
00457 tagINT2Array
00458 {
00459   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00460   INT2        *data; /**< Pointer to the data array. */
00461 }
00462 INT2Array;
00463 
00464 /** Multidimentional array of UINT2. */
00465 typedef struct
00466 tagUINT2Array
00467 {
00468   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00469   UINT2       *data; /**< Pointer to the data array. */
00470 }
00471 UINT2Array;
00472 
00473 /** Multidimentional array of INT4. */
00474 typedef struct
00475 tagINT4Array
00476 {
00477   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00478   INT4        *data; /**< Pointer to the data array. */
00479 }
00480 INT4Array;
00481 
00482 /** Multidimentional array of UINT4. */
00483 typedef struct
00484 tagUINT4Array
00485 {
00486   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00487   UINT4       *data; /**< Pointer to the data array. */
00488 }
00489 UINT4Array;
00490 
00491 /** Multidimentional array of INT8. */
00492 typedef struct
00493 tagINT8Array
00494 {
00495   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00496   INT8        *data; /**< Pointer to the data array. */
00497 }
00498 INT8Array;
00499 
00500 /** Multidimentional array of UINT8. */
00501 typedef struct
00502 tagUINT8Array
00503 {
00504   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00505   UINT8       *data; /**< Pointer to the data array. */
00506 }
00507 UINT8Array;
00508 
00509 /** Multidimentional array of REAL4. */
00510 typedef struct
00511 tagREAL4Array
00512 {
00513   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00514   REAL4       *data; /**< Pointer to the data array. */
00515 }
00516 REAL4Array;
00517 
00518 /** Multidimentional array of REAL8. */
00519 typedef struct
00520 tagREAL8Array
00521 {
00522   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00523   REAL8       *data; /**< Pointer to the data array. */
00524 }
00525 REAL8Array;
00526 
00527 /** Multidimentional array of COMPLEX8. */
00528 typedef struct
00529 tagCOMPLEX8Array
00530 {
00531   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00532   COMPLEX8    *data; /**< Pointer to the data array. */
00533 }
00534 COMPLEX8Array;
00535 
00536 /** Multidimentional array of COMPLEX16. */
00537 typedef struct
00538 tagCOMPLEX16Array
00539 {
00540   UINT4Vector *dimLength; /**< Vector of array dimensions. */
00541   COMPLEX16   *data; /**< Pointer to the data array. */
00542 }
00543 COMPLEX16Array;
00544 
00545 
00546 /* <lalLaTeX>
00547 
00548 \vspace{2ex}
00549 \begin{verbatim}
00550 <datatype>Sequence
00551 \end{verbatim}
00552 This structure stores an ordered set of $l$ elements of type
00553 \verb@<datatype>@, which can be any primitive datatype.  It is
00554 identical to \verb@<datatype>Vector@, except that the elements are to
00555 be interpreted as $l$ consecutive elements rather than the components
00556 of an $l$-dimensional vector.  The fields are:
00557 \begin{description}
00558 \item[\texttt{UINT4 length}] The number of data $l$.
00559 \item[\texttt{<datatype> *data}] Pointer to the data array.  The data
00560 are stored sequentially as \verb@data[@$0,\ldots,l-1$\verb@]@.
00561 \end{description}
00562 
00563 </lalLaTeX> */
00564 
00565 typedef CHARVector      CHARSequence;
00566 typedef INT2Vector      INT2Sequence;
00567 typedef UINT2Vector     UINT2Sequence;
00568 typedef INT4Vector      INT4Sequence;
00569 typedef UINT4Vector     UINT4Sequence;
00570 typedef INT8Vector      INT8Sequence;
00571 typedef UINT8Vector     UINT8Sequence;
00572 typedef REAL4Vector     REAL4Sequence;
00573 typedef REAL8Vector     REAL8Sequence;
00574 typedef COMPLEX8Vector  COMPLEX8Sequence;
00575 typedef COMPLEX16Vector COMPLEX16Sequence;
00576 
00577 
00578 /* <lalLaTeX>
00579 
00580 \vspace{2ex}
00581 \begin{verbatim}
00582 <datatype>VectorSequence
00583 \end{verbatim}
00584 This structure stores an ordered set of $l$ elements of type
00585 \verb@<datatype>Vector@, where \verb@<datatype>@ can be any primitive
00586 datatype.  Mathematically the sequence can be written as
00587 $\{\vec{v}^{(0)},\ldots,\vec{v}^{(l-1)}\}$, where each element
00588 $\vec{v}^{(j)}=(v^{(j)}_0,\ldots,v^{(i)}_{n-1})$ is a vector of length
00589 $n$.  In memory the elements are ``flattened''; that is, they are
00590 stored sequentially in a contiguous block of memory.  The fields are:
00591 \begin{description}
00592 \item[\texttt{UINT4 length}] The number of vectors $l$.
00593 \item[\texttt{UINT4 vectorLength}] The length $n$ of each vector.
00594 \item[\texttt{<datatype> *data}] Pointer to the data array.  The data
00595 element $v^{(j)}_i$ is stored as \verb@data[@$j\times n + i$\verb@]@;
00596 that is, the index of \verb@data[]@ runs over the internal index of
00597 each vector element before incrementing to the next vector element.
00598 \end{description}
00599 
00600 </lalLaTeX> */
00601 
00602 /** Sequence of CHAR Vectors. */
00603 typedef struct
00604 tagCHARVectorSequence
00605 {
00606   UINT4  length; /**< The number \a l of vectors. */
00607   UINT4  vectorLength; /**< The length \a n of each vector. */
00608   CHAR  *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00609 }
00610 CHARVectorSequence;
00611 
00612 /** Sequence of INT2 Vectors. */
00613 typedef struct
00614 tagINT2VectorSequence
00615 {
00616   UINT4  length; /**< The number \a l of vectors. */
00617   UINT4  vectorLength; /**< The length \a n of each vector. */
00618   INT2  *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00619 }
00620 INT2VectorSequence;
00621 
00622 /** Sequence of UINT2 Vectors. */
00623 typedef struct
00624 tagUINT2VectorSequence
00625 {
00626   UINT4  length; /**< The number \a l of vectors. */
00627   UINT4  vectorLength; /**< The length \a n of each vector. */
00628   UINT2 *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00629 }
00630 UINT2VectorSequence;
00631 
00632 /** Sequence of INT4 Vectors. */
00633 typedef struct
00634 tagINT4VectorSequence
00635 {
00636   UINT4  length; /**< The number \a l of vectors. */
00637   UINT4  vectorLength; /**< The length \a n of each vector. */
00638   INT4  *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00639 }
00640 INT4VectorSequence;
00641 
00642 /** Sequence of UINT4 Vectors. */
00643 typedef struct
00644 tagUINT4VectorSequence
00645 {
00646   UINT4  length; /**< The number \a l of vectors. */
00647   UINT4  vectorLength; /**< The length \a n of each vector. */
00648   UINT4 *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00649 }
00650 UINT4VectorSequence;
00651 
00652 /** Sequence of INT8 Vectors. */
00653 typedef struct
00654 tagINT8VectorSequence
00655 {
00656   UINT4  length; /**< The number \a l of vectors. */
00657   UINT4  vectorLength; /**< The length \a n of each vector. */
00658   INT8  *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00659 }
00660 INT8VectorSequence;
00661 
00662 /** Sequence of UINT8 Vectors. */
00663 typedef struct
00664 tagUINT8VectorSequence
00665 {
00666   UINT4  length; /**< The number \a l of vectors. */
00667   UINT4  vectorLength; /**< The length \a n of each vector. */
00668   UINT8 *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00669 }
00670 UINT8VectorSequence;
00671 
00672 /** Sequence of REAL4 Vectors. */
00673 typedef struct
00674 tagREAL4VectorSequence
00675 {
00676   UINT4  length; /**< The number \a l of vectors. */
00677   UINT4  vectorLength; /**< The length \a n of each vector. */
00678   REAL4 *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00679 }
00680 REAL4VectorSequence;
00681 
00682 /** Sequence of REAL8 Vectors. */
00683 typedef struct
00684 tagREAL8VectorSequence
00685 {
00686   UINT4  length; /**< The number \a l of vectors. */
00687   UINT4  vectorLength; /**< The length \a n of each vector. */
00688   REAL8 *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00689 }
00690 REAL8VectorSequence;
00691 
00692 /** Sequence of COMPLEX8 Vectors. */
00693 typedef struct
00694 tagCOMPLEX8VectorSequence
00695 {
00696   UINT4     length; /**< The number \a l of vectors. */
00697   UINT4     vectorLength; /**< The length \a n of each vector. */
00698   COMPLEX8 *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00699 }
00700 COMPLEX8VectorSequence;
00701 
00702 /** Sequence of COMPLEX16 Vectors. */
00703 typedef struct
00704 tagCOMPLEX16VectorSequence
00705 {
00706   UINT4      length; /**< The number \a l of vectors. */
00707   UINT4      vectorLength; /**< The length \a n of each vector. */
00708   COMPLEX16 *data; /**< Pointer to the data array.  Element \a i of vector \a j is \c data[ \a jn + \a i \c]. */
00709 }
00710 COMPLEX16VectorSequence;
00711 
00712 
00713 /* <lalLaTeX>
00714 
00715 \vspace{2ex}
00716 \begin{verbatim}
00717 <datatype>ArraySequence
00718 \end{verbatim}
00719 This structure stores an ordered set of $l$ elements of type
00720 \verb@<datatype>Array@, where \verb@<datatype>@ can be any primitive
00721 datatype.  The indexing of an array sequence can get quite
00722 complicated; it helps to read first the documentation for data arrays,
00723 above.  Mathematically the data can be written as a set
00724 $\{\mathsf{A}^{(j)}_{i_0\cdots i_{m-1}}$, where the sequence number
00725 $j$ runs from 0 to $l-1$, and each array index $i_k$ runs over its own
00726 range $0,\ldots,n_k-1$.  The total number of data in a given array
00727 element is then $N=n_0\times\cdots\times n_{m-1}$, and the total
00728 number of data in the sequence is $N\times l$.  In memory the array is
00729 ``flattened'' so that the elements are stored sequentially in a
00730 contiguous block.  The fields are:
00731 \begin{description}
00732 \item[\texttt{UINT4 length}] The number $l$ of array elements in the
00733 sequence.
00734 \item[\texttt{UINT4 arrayDim}] The number of data $N$ (\emph{not} the
00735 number of indecies $m$) in each array element of the sequence.
00736 \item[\texttt{UINT4Vector *dimLength}] Pointer to a vector of length
00737 $m$, storing the index ranges $(n_0,\ldots,n_{m-1})$.
00738 \item[\texttt{<datatype> *data}] Pointer to the data.  The element
00739 $\mathsf{A}^{(j)}_{i_0\cdots i_{m-1}}$ is stored as
00740 \verb@data[@$j\times N + i_{m-1} + n_{m-2}\times(i_{m-2} +
00741 n_{m-3}\times(\cdots(i_1 + n_0\times i_0)\cdots))$\verb@]@; that is,
00742 the index of \verb@data[]@ runs over the internal indecies of each
00743 array element before incrementing to the next array element.
00744 \end{description}
00745 
00746 </lalLaTeX> */
00747 
00748 /** Sequency of INT2 multidimensional arrays. */
00749 typedef struct
00750 tagINT2ArraySequence
00751 {
00752   UINT4        length; /**< The number \a l of vectors. */
00753   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00754   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00755   INT2        *data; /**< Pointer to the data array. */
00756 }
00757 INT2ArraySequence;
00758 
00759 /** Sequency of UINT2 multidimensional arrays. */
00760 typedef struct
00761 tagUINT2ArraySequence
00762 {
00763   UINT4        length; /**< The number \a l of vectors. */
00764   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00765   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00766   UINT2       *data; /**< Pointer to the data array. */
00767 }
00768 UINT2ArraySequence;
00769 
00770 /** Sequency of INT4 multidimensional arrays. */
00771 typedef struct
00772 tagINT4ArraySequence
00773 {
00774   UINT4        length; /**< The number \a l of vectors. */
00775   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00776   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00777   INT4        *data; /**< Pointer to the data array. */
00778 }
00779 INT4ArraySequence;
00780 
00781 /** Sequency of UINT4 multidimensional arrays. */
00782 typedef struct
00783 tagUINT4ArraySequence
00784 {
00785   UINT4        length; /**< The number \a l of vectors. */
00786   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00787   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00788   UINT4       *data; /**< Pointer to the data array. */
00789 }
00790 UINT4ArraySequence;
00791 
00792 /** Sequency of INT8 multidimensional arrays. */
00793 typedef struct
00794 tagINT8ArraySequence
00795 {
00796   UINT4        length; /**< The number \a l of vectors. */
00797   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00798   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00799   INT8        *data; /**< Pointer to the data array. */
00800 }
00801 INT8ArraySequence;
00802 
00803 /** Sequency of UINT8 multidimensional arrays. */
00804 typedef struct
00805 tagUINT8ArraySequence
00806 {
00807   UINT4        length; /**< The number \a l of vectors. */
00808   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00809   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00810   UINT8       *data; /**< Pointer to the data array. */
00811 }
00812 UINT8ArraySequence;
00813 
00814 /** Sequency of REAL4 multidimensional arrays. */
00815 typedef struct
00816 tagREAL4ArraySequence
00817 {
00818   UINT4        length; /**< The number \a l of vectors. */
00819   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00820   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00821   REAL4       *data; /**< Pointer to the data array. */
00822 }
00823 REAL4ArraySequence;
00824 
00825 /** Sequency of REAL8 multidimensional arrays. */
00826 typedef struct
00827 tagREAL8ArraySequence
00828 {
00829   UINT4        length; /**< The number \a l of vectors. */
00830   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00831   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00832   REAL8       *data; /**< Pointer to the data array. */
00833 }
00834 REAL8ArraySequence;
00835 
00836 /** Sequency of COMPLEX8 multidimensional arrays. */
00837 typedef struct
00838 tagCOMPLEX8ArraySequence
00839 {
00840   UINT4        length; /**< The number \a l of vectors. */
00841   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00842   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00843   COMPLEX8    *data; /**< Pointer to the data array. */
00844 }
00845 COMPLEX8ArraySequence;
00846 
00847 /** Sequency of COMPLEX16 multidimensional arrays. */
00848 typedef struct
00849 tagCOMPLEX16ArraySequence
00850 {
00851   UINT4        length; /**< The number \a l of vectors. */
00852   UINT4        arrayDim; /**< The number of data \a N in each array element (this is not the number \a m of indices). */
00853   UINT4Vector *dimLength; /**< Pointer to a vector of length \a m storing the array dimensions */
00854   COMPLEX16   *data; /**< Pointer to the data array. */
00855 }
00856 COMPLEX16ArraySequence;
00857 /*@}*/
00858 
00859 
00860 /* <lalLaTeX>
00861 \newpage
00862 \subsection{Structured datatypes}
00863 \label{ss:structured-datatypes}
00864 
00865 These datatypes embed primitive and aggregate datatypes inside
00866 structures that define their physical meaning.  Most of these
00867 structures are wrappers for aggregate datatypes that store a physical
00868 quantity as a function of time or frequency.  Other structures store
00869 speci