ArraySequenceFactories.c

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------- 
00002 
00003 File Name: ArraySequenceFactories.c
00004 
00005 <lalVerbatim file="ArraySequenceFactoriesCV">
00006 Revision: $Id: ArraySequenceFactories.m4,v 1.1 2002/05/21 17:14:38 teviet Exp $
00007 </lalVerbatim>
00008 
00009 -------------------------------------------------------------------------*/
00010 
00011 /* <lalLaTeX>
00012 
00013 \subsection{Module \texttt{ArraySequenceFactories.c}}
00014 \label{ss:ArraySequenceFactories.c}
00015 
00016 Create/destroy $\langle\mbox{datatype}\rangle$ArraySequence objects. 
00017 
00018 \subsubsection*{Prototypes}
00019 \vspace{0.1in}
00020 \input{ArraySequenceFactoriesD}
00021 \idx{LALZCreateArraySequence()}
00022 \idx{LALCCreateArraySequence()}
00023 \idx{LALDCreateArraySequence()}
00024 \idx{LALSCreateArraySequence()}
00025 \idx{LALI2CreateArraySequence()}
00026 \idx{LALI4CreateArraySequence()}
00027 \idx{LALI8CreateArraySequence()}
00028 \idx{LALU2CreateArraySequence()}
00029 \idx{LALU4CreateArraySequence()}
00030 \idx{LALU8CreateArraySequence()}
00031 \idx{LALCreateArraySequence()}
00032 \idx{LALZDestroyArraySequence()}
00033 \idx{LALCDestroyArraySequence()}
00034 \idx{LALDDestroyArraySequence()}
00035 \idx{LALSDestroyArraySequence()}
00036 \idx{LALI2DestroyArraySequence()}
00037 \idx{LALI4DestroyArraySequence()}
00038 \idx{LALI8DestroyArraySequence()}
00039 \idx{LALU2DestroyArraySequence()}
00040 \idx{LALU4DestroyArraySequence()}
00041 \idx{LALU8DestroyArraySequence()}
00042 \idx{LALDestroyArraySequence()}
00043 
00044 \subsubsection*{Description}
00045 
00046 The \texttt{CreateArraySequence} family of functions create a
00047 $\langle\mbox{datatype}\rangle$\texttt{ArraySequence} of the
00048 appropriate dimensions.
00049 
00050 The \texttt{DestroyArraySequence} family of functions return the storage
00051 allocated by the \texttt{CreateArraySequence} functions to the system.
00052 
00053 \subsubsection*{Algorithm}
00054 
00055 \subsubsection*{Uses}
00056 \begin{verbatim}
00057 LALMalloc()
00058 LALFree()
00059 \end{verbatim}
00060 
00061 \subsubsection*{Notes}
00062 
00063 \vfill{\footnotesize\input{ArraySequenceFactoriesCV}}
00064 
00065 </lalLaTeX> */
00066 
00067 #include "LALStdlib.h"
00068 #include "AVFactories.h"
00069 #include "SeqFactories.h"
00070 
00071 /* <lalVerbatim file="ArraySequenceFactoriesNRCSID"> */
00072 NRCSID( ARRAYSEQUENCEFACTORIESC, "$Id: ArraySequenceFactories.m4,v 1.1 2002/05/21 17:14:38 teviet Exp $" );
00073 /* </lalVerbatim> */
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00091 void LALZCreateArraySequence ( LALStatus *status, COMPLEX16ArraySequence **aseq, CreateArraySequenceIn *in ) 
00092 { /* </lalVerbatim> */
00093   UINT4 i;
00094 
00095   /* 
00096    * Initialize status
00097    */
00098   INITSTATUS( status, "LALZCreateArraySequence", ARRAYSEQUENCEFACTORIESC );     
00099   ATTATCHSTATUSPTR( status );
00100 
00101   /* Check input structure: report if NULL */
00102 
00103   ASSERT (in != NULL, status, SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR);
00104   ASSERT (in->dimLength, status,
00105           SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR); 
00106       
00107   /* Check sequence length: report error if 0 
00108    * Use of unsigned for length means we can't check if negative
00109    * length was passed
00110    */
00111 
00112   ASSERT (in->length > 0, status,
00113           SEQFACTORIESH_ESLENGTH, SEQFACTORIESH_MSGESLENGTH);
00114 
00115   /* Check dimension lengths: report error any are 0 
00116    * Use of unsigned for length means we can't check if negative
00117    * length was passed
00118    */
00119 #ifndef NDEBUG
00120   for ( i = 0; i < in->dimLength->length; i++ )
00121   {
00122     ASSERT (in->dimLength->data[i] > 0, status,
00123             SEQFACTORIESH_EALENGTH, SEQFACTORIESH_MSGEALENGTH); 
00124   }
00125 #endif
00126 
00127   /* 
00128    * Check return structure: If return pointer does not point to a
00129    *    valid pointer then report an error 
00130    */
00131 
00132   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR);
00133   ASSERT (*aseq == NULL, status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00134 
00135   /*
00136    * Allocate pointer
00137    */
00138 
00139   *aseq = ( COMPLEX16ArraySequence * ) LALMalloc( sizeof( COMPLEX16ArraySequence ) );
00140   if ( NULL == *aseq )
00141   {
00142     ABORT( status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC );
00143   }
00144 
00145   (*aseq)->length = in->length;
00146   (*aseq)->arrayDim = 1;
00147   (*aseq)->dimLength = NULL;    /* NULL dimLength until allocated */
00148   (*aseq)->data   = NULL;       /* NULL data until allocated */
00149 
00150   /* 
00151    * Allocate dimLength
00152    */
00153   {
00154     LALU4CreateVector( status->statusPtr, &((*aseq)->dimLength),
00155                        in->dimLength->length );
00156     BEGINFAIL( status ) {
00157       LALFree ((void *) *aseq);
00158       ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00159     } ENDFAIL( status );
00160     for ( i = 0; i < in->dimLength->length; i++ )
00161       (*aseq)->arrayDim *= (*aseq)->dimLength->data[i]
00162         = in->dimLength->data[i];
00163   }
00164 
00165   /* 
00166    * Allocate storage 
00167    */
00168   {
00169     size_t tlength;
00170     tlength = (*aseq)->length * (*aseq)->arrayDim * sizeof( COMPLEX16 );
00171     (*aseq)->data = ( COMPLEX16 * ) LALMalloc (tlength);
00172   }
00173 
00174   if (NULL == (*aseq)->data)
00175   {
00176     /* Must free storage pointed to by *aseq */
00177     TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00178          status );
00179     LALFree ((void *) *aseq);
00180     ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00181   }
00182 
00183   /* We be done: Normal exit */
00184 
00185   DETATCHSTATUSPTR( status );
00186   RETURN (status);
00187 }
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00204 void LALZDestroyArraySequence ( LALStatus *status, COMPLEX16ArraySequence **aseq )
00205 { /* </lalVerbatim> */
00206   /* 
00207    * Initialize status
00208    */
00209 
00210   INITSTATUS( status, "LALZDestroyArraySequence", ARRAYSEQUENCEFACTORIESC );
00211   ATTATCHSTATUSPTR( status );
00212       
00213   /* 
00214    * Check aseq: is it non-NULL?
00215    */
00216 
00217   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR); 
00218 
00219   /* 
00220    * Check aseq: does it point to non-NULL?
00221    */
00222 
00223   ASSERT (*aseq != NULL,status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00224 
00225   /*
00226    * Check dimLength in aseq: does it point to non-NULL?
00227    */
00228 
00229   ASSERT ((*aseq)->dimLength != NULL, status,
00230           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00231 
00232   /*
00233    * Check data in aseq: does it point to non-NULL?
00234    */
00235 
00236   ASSERT ((*aseq)->data != NULL, status,
00237           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00238 
00239   /* Ok, now let's free allocated storage */
00240 
00241   TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00242        status );
00243   LALFree ( (*aseq)->data ); /* free allocated data */
00244   LALFree ( *aseq );          /* free aseq struct itself */
00245 
00246   *aseq = NULL;         /* make sure we don't point to freed struct */
00247 
00248   DETATCHSTATUSPTR( status );
00249   RETURN (status);
00250 }
00251 
00252 
00253 
00254 
00255 
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00269 void LALCCreateArraySequence ( LALStatus *status, COMPLEX8ArraySequence **aseq, CreateArraySequenceIn *in ) 
00270 { /* </lalVerbatim> */
00271   UINT4 i;
00272 
00273   /* 
00274    * Initialize status
00275    */
00276   INITSTATUS( status, "LALCCreateArraySequence", ARRAYSEQUENCEFACTORIESC );     
00277   ATTATCHSTATUSPTR( status );
00278 
00279   /* Check input structure: report if NULL */
00280 
00281   ASSERT (in != NULL, status, SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR);
00282   ASSERT (in->dimLength, status,
00283           SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR); 
00284       
00285   /* Check sequence length: report error if 0 
00286    * Use of unsigned for length means we can't check if negative
00287    * length was passed
00288    */
00289 
00290   ASSERT (in->length > 0, status,
00291           SEQFACTORIESH_ESLENGTH, SEQFACTORIESH_MSGESLENGTH);
00292 
00293   /* Check dimension lengths: report error any are 0 
00294    * Use of unsigned for length means we can't check if negative
00295    * length was passed
00296    */
00297 #ifndef NDEBUG
00298   for ( i = 0; i < in->dimLength->length; i++ )
00299   {
00300     ASSERT (in->dimLength->data[i] > 0, status,
00301             SEQFACTORIESH_EALENGTH, SEQFACTORIESH_MSGEALENGTH); 
00302   }
00303 #endif
00304 
00305   /* 
00306    * Check return structure: If return pointer does not point to a
00307    *    valid pointer then report an error 
00308    */
00309 
00310   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR);
00311   ASSERT (*aseq == NULL, status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00312 
00313   /*
00314    * Allocate pointer
00315    */
00316 
00317   *aseq = ( COMPLEX8ArraySequence * ) LALMalloc( sizeof( COMPLEX8ArraySequence ) );
00318   if ( NULL == *aseq )
00319   {
00320     ABORT( status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC );
00321   }
00322 
00323   (*aseq)->length = in->length;
00324   (*aseq)->arrayDim = 1;
00325   (*aseq)->dimLength = NULL;    /* NULL dimLength until allocated */
00326   (*aseq)->data   = NULL;       /* NULL data until allocated */
00327 
00328   /* 
00329    * Allocate dimLength
00330    */
00331   {
00332     LALU4CreateVector( status->statusPtr, &((*aseq)->dimLength),
00333                        in->dimLength->length );
00334     BEGINFAIL( status ) {
00335       LALFree ((void *) *aseq);
00336       ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00337     } ENDFAIL( status );
00338     for ( i = 0; i < in->dimLength->length; i++ )
00339       (*aseq)->arrayDim *= (*aseq)->dimLength->data[i]
00340         = in->dimLength->data[i];
00341   }
00342 
00343   /* 
00344    * Allocate storage 
00345    */
00346   {
00347     size_t tlength;
00348     tlength = (*aseq)->length * (*aseq)->arrayDim * sizeof( COMPLEX8 );
00349     (*aseq)->data = ( COMPLEX8 * ) LALMalloc (tlength);
00350   }
00351 
00352   if (NULL == (*aseq)->data)
00353   {
00354     /* Must free storage pointed to by *aseq */
00355     TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00356          status );
00357     LALFree ((void *) *aseq);
00358     ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00359   }
00360 
00361   /* We be done: Normal exit */
00362 
00363   DETATCHSTATUSPTR( status );
00364   RETURN (status);
00365 }
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374 
00375 
00376 
00377 
00378 
00379 
00380 
00381 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00382 void LALCDestroyArraySequence ( LALStatus *status, COMPLEX8ArraySequence **aseq )
00383 { /* </lalVerbatim> */
00384   /* 
00385    * Initialize status
00386    */
00387 
00388   INITSTATUS( status, "LALCDestroyArraySequence", ARRAYSEQUENCEFACTORIESC );
00389   ATTATCHSTATUSPTR( status );
00390       
00391   /* 
00392    * Check aseq: is it non-NULL?
00393    */
00394 
00395   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR); 
00396 
00397   /* 
00398    * Check aseq: does it point to non-NULL?
00399    */
00400 
00401   ASSERT (*aseq != NULL,status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00402 
00403   /*
00404    * Check dimLength in aseq: does it point to non-NULL?
00405    */
00406 
00407   ASSERT ((*aseq)->dimLength != NULL, status,
00408           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00409 
00410   /*
00411    * Check data in aseq: does it point to non-NULL?
00412    */
00413 
00414   ASSERT ((*aseq)->data != NULL, status,
00415           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00416 
00417   /* Ok, now let's free allocated storage */
00418 
00419   TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00420        status );
00421   LALFree ( (*aseq)->data ); /* free allocated data */
00422   LALFree ( *aseq );          /* free aseq struct itself */
00423 
00424   *aseq = NULL;         /* make sure we don't point to freed struct */
00425 
00426   DETATCHSTATUSPTR( status );
00427   RETURN (status);
00428 }
00429 
00430 
00431 
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 
00440 
00441 
00442 
00443 
00444 
00445 
00446 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00447 void LALDCreateArraySequence ( LALStatus *status, REAL8ArraySequence **aseq, CreateArraySequenceIn *in ) 
00448 { /* </lalVerbatim> */
00449   UINT4 i;
00450 
00451   /* 
00452    * Initialize status
00453    */
00454   INITSTATUS( status, "LALDCreateArraySequence", ARRAYSEQUENCEFACTORIESC );     
00455   ATTATCHSTATUSPTR( status );
00456 
00457   /* Check input structure: report if NULL */
00458 
00459   ASSERT (in != NULL, status, SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR);
00460   ASSERT (in->dimLength, status,
00461           SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR); 
00462       
00463   /* Check sequence length: report error if 0 
00464    * Use of unsigned for length means we can't check if negative
00465    * length was passed
00466    */
00467 
00468   ASSERT (in->length > 0, status,
00469           SEQFACTORIESH_ESLENGTH, SEQFACTORIESH_MSGESLENGTH);
00470 
00471   /* Check dimension lengths: report error any are 0 
00472    * Use of unsigned for length means we can't check if negative
00473    * length was passed
00474    */
00475 #ifndef NDEBUG
00476   for ( i = 0; i < in->dimLength->length; i++ )
00477   {
00478     ASSERT (in->dimLength->data[i] > 0, status,
00479             SEQFACTORIESH_EALENGTH, SEQFACTORIESH_MSGEALENGTH); 
00480   }
00481 #endif
00482 
00483   /* 
00484    * Check return structure: If return pointer does not point to a
00485    *    valid pointer then report an error 
00486    */
00487 
00488   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR);
00489   ASSERT (*aseq == NULL, status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00490 
00491   /*
00492    * Allocate pointer
00493    */
00494 
00495   *aseq = ( REAL8ArraySequence * ) LALMalloc( sizeof( REAL8ArraySequence ) );
00496   if ( NULL == *aseq )
00497   {
00498     ABORT( status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC );
00499   }
00500 
00501   (*aseq)->length = in->length;
00502   (*aseq)->arrayDim = 1;
00503   (*aseq)->dimLength = NULL;    /* NULL dimLength until allocated */
00504   (*aseq)->data   = NULL;       /* NULL data until allocated */
00505 
00506   /* 
00507    * Allocate dimLength
00508    */
00509   {
00510     LALU4CreateVector( status->statusPtr, &((*aseq)->dimLength),
00511                        in->dimLength->length );
00512     BEGINFAIL( status ) {
00513       LALFree ((void *) *aseq);
00514       ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00515     } ENDFAIL( status );
00516     for ( i = 0; i < in->dimLength->length; i++ )
00517       (*aseq)->arrayDim *= (*aseq)->dimLength->data[i]
00518         = in->dimLength->data[i];
00519   }
00520 
00521   /* 
00522    * Allocate storage 
00523    */
00524   {
00525     size_t tlength;
00526     tlength = (*aseq)->length * (*aseq)->arrayDim * sizeof( REAL8 );
00527     (*aseq)->data = ( REAL8 * ) LALMalloc (tlength);
00528   }
00529 
00530   if (NULL == (*aseq)->data)
00531   {
00532     /* Must free storage pointed to by *aseq */
00533     TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00534          status );
00535     LALFree ((void *) *aseq);
00536     ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00537   }
00538 
00539   /* We be done: Normal exit */
00540 
00541   DETATCHSTATUSPTR( status );
00542   RETURN (status);
00543 }
00544 
00545 
00546 
00547 
00548 
00549 
00550 
00551 
00552 
00553 
00554 
00555 
00556 
00557 
00558 
00559 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00560 void LALDDestroyArraySequence ( LALStatus *status, REAL8ArraySequence **aseq )
00561 { /* </lalVerbatim> */
00562   /* 
00563    * Initialize status
00564    */
00565 
00566   INITSTATUS( status, "LALDDestroyArraySequence", ARRAYSEQUENCEFACTORIESC );
00567   ATTATCHSTATUSPTR( status );
00568       
00569   /* 
00570    * Check aseq: is it non-NULL?
00571    */
00572 
00573   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR); 
00574 
00575   /* 
00576    * Check aseq: does it point to non-NULL?
00577    */
00578 
00579   ASSERT (*aseq != NULL,status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00580 
00581   /*
00582    * Check dimLength in aseq: does it point to non-NULL?
00583    */
00584 
00585   ASSERT ((*aseq)->dimLength != NULL, status,
00586           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00587 
00588   /*
00589    * Check data in aseq: does it point to non-NULL?
00590    */
00591 
00592   ASSERT ((*aseq)->data != NULL, status,
00593           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00594 
00595   /* Ok, now let's free allocated storage */
00596 
00597   TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00598        status );
00599   LALFree ( (*aseq)->data ); /* free allocated data */
00600   LALFree ( *aseq );          /* free aseq struct itself */
00601 
00602   *aseq = NULL;         /* make sure we don't point to freed struct */
00603 
00604   DETATCHSTATUSPTR( status );
00605   RETURN (status);
00606 }
00607 
00608 
00609 
00610 
00611 
00612 
00613 
00614 
00615 
00616 
00617 
00618 
00619 
00620 
00621 
00622 
00623 
00624 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00625 void LALSCreateArraySequence ( LALStatus *status, REAL4ArraySequence **aseq, CreateArraySequenceIn *in ) 
00626 { /* </lalVerbatim> */
00627   UINT4 i;
00628 
00629   /* 
00630    * Initialize status
00631    */
00632   INITSTATUS( status, "LALSCreateArraySequence", ARRAYSEQUENCEFACTORIESC );     
00633   ATTATCHSTATUSPTR( status );
00634 
00635   /* Check input structure: report if NULL */
00636 
00637   ASSERT (in != NULL, status, SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR);
00638   ASSERT (in->dimLength, status,
00639           SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR); 
00640       
00641   /* Check sequence length: report error if 0 
00642    * Use of unsigned for length means we can't check if negative
00643    * length was passed
00644    */
00645 
00646   ASSERT (in->length > 0, status,
00647           SEQFACTORIESH_ESLENGTH, SEQFACTORIESH_MSGESLENGTH);
00648 
00649   /* Check dimension lengths: report error any are 0 
00650    * Use of unsigned for length means we can't check if negative
00651    * length was passed
00652    */
00653 #ifndef NDEBUG
00654   for ( i = 0; i < in->dimLength->length; i++ )
00655   {
00656     ASSERT (in->dimLength->data[i] > 0, status,
00657             SEQFACTORIESH_EALENGTH, SEQFACTORIESH_MSGEALENGTH); 
00658   }
00659 #endif
00660 
00661   /* 
00662    * Check return structure: If return pointer does not point to a
00663    *    valid pointer then report an error 
00664    */
00665 
00666   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR);
00667   ASSERT (*aseq == NULL, status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00668 
00669   /*
00670    * Allocate pointer
00671    */
00672 
00673   *aseq = ( REAL4ArraySequence * ) LALMalloc( sizeof( REAL4ArraySequence ) );
00674   if ( NULL == *aseq )
00675   {
00676     ABORT( status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC );
00677   }
00678 
00679   (*aseq)->length = in->length;
00680   (*aseq)->arrayDim = 1;
00681   (*aseq)->dimLength = NULL;    /* NULL dimLength until allocated */
00682   (*aseq)->data   = NULL;       /* NULL data until allocated */
00683 
00684   /* 
00685    * Allocate dimLength
00686    */
00687   {
00688     LALU4CreateVector( status->statusPtr, &((*aseq)->dimLength),
00689                        in->dimLength->length );
00690     BEGINFAIL( status ) {
00691       LALFree ((void *) *aseq);
00692       ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00693     } ENDFAIL( status );
00694     for ( i = 0; i < in->dimLength->length; i++ )
00695       (*aseq)->arrayDim *= (*aseq)->dimLength->data[i]
00696         = in->dimLength->data[i];
00697   }
00698 
00699   /* 
00700    * Allocate storage 
00701    */
00702   {
00703     size_t tlength;
00704     tlength = (*aseq)->length * (*aseq)->arrayDim * sizeof( REAL4 );
00705     (*aseq)->data = ( REAL4 * ) LALMalloc (tlength);
00706   }
00707 
00708   if (NULL == (*aseq)->data)
00709   {
00710     /* Must free storage pointed to by *aseq */
00711     TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00712          status );
00713     LALFree ((void *) *aseq);
00714     ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00715   }
00716 
00717   /* We be done: Normal exit */
00718 
00719   DETATCHSTATUSPTR( status );
00720   RETURN (status);
00721 }
00722 
00723 
00724 
00725 
00726 
00727 
00728 
00729 
00730 
00731 
00732 
00733 
00734 
00735 
00736 
00737 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00738 void LALSDestroyArraySequence ( LALStatus *status, REAL4ArraySequence **aseq )
00739 { /* </lalVerbatim> */
00740   /* 
00741    * Initialize status
00742    */
00743 
00744   INITSTATUS( status, "LALSDestroyArraySequence", ARRAYSEQUENCEFACTORIESC );
00745   ATTATCHSTATUSPTR( status );
00746       
00747   /* 
00748    * Check aseq: is it non-NULL?
00749    */
00750 
00751   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR); 
00752 
00753   /* 
00754    * Check aseq: does it point to non-NULL?
00755    */
00756 
00757   ASSERT (*aseq != NULL,status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00758 
00759   /*
00760    * Check dimLength in aseq: does it point to non-NULL?
00761    */
00762 
00763   ASSERT ((*aseq)->dimLength != NULL, status,
00764           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00765 
00766   /*
00767    * Check data in aseq: does it point to non-NULL?
00768    */
00769 
00770   ASSERT ((*aseq)->data != NULL, status,
00771           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00772 
00773   /* Ok, now let's free allocated storage */
00774 
00775   TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00776        status );
00777   LALFree ( (*aseq)->data ); /* free allocated data */
00778   LALFree ( *aseq );          /* free aseq struct itself */
00779 
00780   *aseq = NULL;         /* make sure we don't point to freed struct */
00781 
00782   DETATCHSTATUSPTR( status );
00783   RETURN (status);
00784 }
00785 
00786 
00787 
00788 
00789 
00790 
00791 
00792 
00793 
00794 
00795 
00796 
00797 
00798 
00799 
00800 
00801 
00802 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00803 void LALI2CreateArraySequence ( LALStatus *status, INT2ArraySequence **aseq, CreateArraySequenceIn *in ) 
00804 { /* </lalVerbatim> */
00805   UINT4 i;
00806 
00807   /* 
00808    * Initialize status
00809    */
00810   INITSTATUS( status, "LALI2CreateArraySequence", ARRAYSEQUENCEFACTORIESC );    
00811   ATTATCHSTATUSPTR( status );
00812 
00813   /* Check input structure: report if NULL */
00814 
00815   ASSERT (in != NULL, status, SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR);
00816   ASSERT (in->dimLength, status,
00817           SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR); 
00818       
00819   /* Check sequence length: report error if 0 
00820    * Use of unsigned for length means we can't check if negative
00821    * length was passed
00822    */
00823 
00824   ASSERT (in->length > 0, status,
00825           SEQFACTORIESH_ESLENGTH, SEQFACTORIESH_MSGESLENGTH);
00826 
00827   /* Check dimension lengths: report error any are 0 
00828    * Use of unsigned for length means we can't check if negative
00829    * length was passed
00830    */
00831 #ifndef NDEBUG
00832   for ( i = 0; i < in->dimLength->length; i++ )
00833   {
00834     ASSERT (in->dimLength->data[i] > 0, status,
00835             SEQFACTORIESH_EALENGTH, SEQFACTORIESH_MSGEALENGTH); 
00836   }
00837 #endif
00838 
00839   /* 
00840    * Check return structure: If return pointer does not point to a
00841    *    valid pointer then report an error 
00842    */
00843 
00844   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR);
00845   ASSERT (*aseq == NULL, status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00846 
00847   /*
00848    * Allocate pointer
00849    */
00850 
00851   *aseq = ( INT2ArraySequence * ) LALMalloc( sizeof( INT2ArraySequence ) );
00852   if ( NULL == *aseq )
00853   {
00854     ABORT( status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC );
00855   }
00856 
00857   (*aseq)->length = in->length;
00858   (*aseq)->arrayDim = 1;
00859   (*aseq)->dimLength = NULL;    /* NULL dimLength until allocated */
00860   (*aseq)->data   = NULL;       /* NULL data until allocated */
00861 
00862   /* 
00863    * Allocate dimLength
00864    */
00865   {
00866     LALU4CreateVector( status->statusPtr, &((*aseq)->dimLength),
00867                        in->dimLength->length );
00868     BEGINFAIL( status ) {
00869       LALFree ((void *) *aseq);
00870       ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00871     } ENDFAIL( status );
00872     for ( i = 0; i < in->dimLength->length; i++ )
00873       (*aseq)->arrayDim *= (*aseq)->dimLength->data[i]
00874         = in->dimLength->data[i];
00875   }
00876 
00877   /* 
00878    * Allocate storage 
00879    */
00880   {
00881     size_t tlength;
00882     tlength = (*aseq)->length * (*aseq)->arrayDim * sizeof( INT2 );
00883     (*aseq)->data = ( INT2 * ) LALMalloc (tlength);
00884   }
00885 
00886   if (NULL == (*aseq)->data)
00887   {
00888     /* Must free storage pointed to by *aseq */
00889     TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00890          status );
00891     LALFree ((void *) *aseq);
00892     ABORT (status, SEQFACTORIESH_EMALLOC, SEQFACTORIESH_MSGEMALLOC);
00893   }
00894 
00895   /* We be done: Normal exit */
00896 
00897   DETATCHSTATUSPTR( status );
00898   RETURN (status);
00899 }
00900 
00901 
00902 
00903 
00904 
00905 
00906 
00907 
00908 
00909 
00910 
00911 
00912 
00913 
00914 
00915 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00916 void LALI2DestroyArraySequence ( LALStatus *status, INT2ArraySequence **aseq )
00917 { /* </lalVerbatim> */
00918   /* 
00919    * Initialize status
00920    */
00921 
00922   INITSTATUS( status, "LALI2DestroyArraySequence", ARRAYSEQUENCEFACTORIESC );
00923   ATTATCHSTATUSPTR( status );
00924       
00925   /* 
00926    * Check aseq: is it non-NULL?
00927    */
00928 
00929   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR); 
00930 
00931   /* 
00932    * Check aseq: does it point to non-NULL?
00933    */
00934 
00935   ASSERT (*aseq != NULL,status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
00936 
00937   /*
00938    * Check dimLength in aseq: does it point to non-NULL?
00939    */
00940 
00941   ASSERT ((*aseq)->dimLength != NULL, status,
00942           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00943 
00944   /*
00945    * Check data in aseq: does it point to non-NULL?
00946    */
00947 
00948   ASSERT ((*aseq)->data != NULL, status,
00949           SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
00950 
00951   /* Ok, now let's free allocated storage */
00952 
00953   TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
00954        status );
00955   LALFree ( (*aseq)->data ); /* free allocated data */
00956   LALFree ( *aseq );          /* free aseq struct itself */
00957 
00958   *aseq = NULL;         /* make sure we don't point to freed struct */
00959 
00960   DETATCHSTATUSPTR( status );
00961   RETURN (status);
00962 }
00963 
00964 
00965 
00966 
00967 
00968 
00969 
00970 
00971 
00972 
00973 
00974 
00975 
00976 
00977 
00978 
00979 
00980 /* <lalVerbatim file="ArraySequenceFactoriesD"> */
00981 void LALI4CreateArraySequence ( LALStatus *status, INT4ArraySequence **aseq, CreateArraySequenceIn *in ) 
00982 { /* </lalVerbatim> */
00983   UINT4 i;
00984 
00985   /* 
00986    * Initialize status
00987    */
00988   INITSTATUS( status, "LALI4CreateArraySequence", ARRAYSEQUENCEFACTORIESC );    
00989   ATTATCHSTATUSPTR( status );
00990 
00991   /* Check input structure: report if NULL */
00992 
00993   ASSERT (in != NULL, status, SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR);
00994   ASSERT (in->dimLength, status,
00995           SEQFACTORIESH_EINPTR, SEQFACTORIESH_MSGEINPTR); 
00996       
00997   /* Check sequence length: report error if 0 
00998    * Use of unsigned for length means we can't check if negative
00999    * length was passed
01000    */
01001 
01002   ASSERT (in->length > 0, status,
01003           SEQFACTORIESH_ESLENGTH, SEQFACTORIESH_MSGESLENGTH);
01004 
01005   /* Check dimension lengths: report error any are 0 
01006    * Use of unsigned for length means we can't check if negative
01007    * length was passed
01008    */
01009 #ifndef NDEBUG
01010   for ( i = 0; i < in->dimLength->length; i++ )
01011   {
01012     ASSERT (in->dimLength->data[i] > 0, status,
01013             SEQFACTORIESH_EALENGTH, SEQFACTORIESH_MSGEALENGTH); 
01014   }
01015 #endif
01016 
01017   /* 
01018    * Check return structure: If return pointer does not point to a
01019    *    valid pointer then report an error 
01020    */
01021 
01022   ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR);
01023   ASSERT (*aseq == NULL, status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
01024 
01025   /*
01026    * Allocate pointer
01027    */
01028 
01029   *aseq = ( INT4ArraySequence * ) LALMalloc( sizeof( INT4ArraySequence ) );
01030   if (