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
PrintVectorTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton
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
22 * \ingroup PrintVector_h
23 *
24 * \brief Tests the routines in \ref PrintVector.c.
25 *
26 * ### Usage ###
27 *
28 * \code
29 * PrintVectorTest
30 * \endcode
31 *
32 * ### Description ###
33 *
34 * This program generates and prints a sequence of
35 * <tt><datatype></tt>Vectors; the program itself always
36 * returns success, so the testing function is actually served by
37 * examinaton of the output files.
38 *
39 * ### Exit codes ###
40 *
41 * <table>
42 * <tr><th>Code</th><th>Explanation</th></tr>
43 * <tr><td>0</td><td>Always returned.</td></tr>
44 * /table>
45 *
46 */
47/** \cond DONT_DOXYGEN */
48
49#ifndef _PRINTVECTOR_H
50#include <lal/PrintVector.h>
51#ifndef _PRINTVECTOR_H
52#define _PRINTVECTOR_H
53#endif
54#endif
55
56#ifndef _MATH_H
57#include <math.h>
58#ifndef _MATH_H
59#define _MATH_H
60#endif
61#endif
62
63#ifndef _LALSTDLIB_H
64#include <lal/LALStdlib.h>
65#ifndef _LALSTDLIB_H
66#define _LALSTDLIB_H
67#endif
68#endif
69
70#ifndef _AVFACTORIES_H
71#include <lal/AVFactories.h>
72#ifndef _AVFACTORIES_H
73#define _AVFACTORIES_H
74#endif
75#endif
76
77
78int main( void )
79{
80 static LALStatus status;
81
82 COMPLEX16Vector *zVector;
83 COMPLEX8Vector *cVector;
84 REAL8Vector *dVector;
85 REAL4Vector *sVector;
86 INT2Vector *i2Vector;
87 INT4Vector *i4Vector;
88 INT8Vector *i8Vector;
89 UINT2Vector *u2Vector;
90 UINT4Vector *u4Vector;
91 UINT8Vector *u8Vector;
92 CHARVector *charVector;
93
94 COMPLEX16 *z;
95 COMPLEX8 *c;
96 REAL8 *d;
97 REAL4 *s;
98 INT2 *i2;
99 INT4 *i4;
100 INT8 *i8;
101 UINT2 *u2;
102 UINT4 *u4;
103 UINT8 *u8;
104 CHAR *ch;
105 INT2 n;
106
107 zVector = NULL;
108
109 LALZCreateVector( &status, &zVector, 8 );
110 for ( n=zVector->length, z=zVector->data; n > 0 ; --n, ++z ) {
111 *(z) = crect( sinh(90.0*(4-n)), - 1 / (1e-300 + creal(*z)) );
112 }
113 LALZPrintVector(zVector);
114
115 cVector = NULL;
116
117 LALCCreateVector( &status, &cVector, 8 );
118 for ( n=cVector->length, c=cVector->data; n > 0 ; --n, ++c ) {
119 *(c) = crectf( sinh(9.0*(4-n)), - 1 / (1e-30 + crealf(*c)) );
120 }
121 LALCPrintVector(cVector);
122
123 dVector = NULL;
124
125 LALDCreateVector( &status, &dVector, 8 );
126 for ( n=dVector->length, d=dVector->data; n > 0 ; --n, ++d ) {
127 *d = sinh(90.0*(4-n));
128 }
129 LALDPrintVector(dVector);
130 for ( n=dVector->length, d=dVector->data; n > 0 ; --n, ++d ) {
131 *d = 1 / (1e-300 + *d);
132 }
133 LALDPrintVector(dVector);
134
135 sVector = NULL;
136
137 LALSCreateVector( &status, &sVector, 8 );
138 for ( n=sVector->length, s=sVector->data; n > 0 ; --n, ++s ) {
139 *s = sinh(9.0*(4-n));
140 }
141 LALSPrintVector(sVector);
142 for ( n=sVector->length, s=sVector->data; n > 0 ; --n, ++s ) {
143 *s = 1 / (1e-30 + *s);
144 }
145 LALSPrintVector(sVector);
146
147 i2Vector = NULL;
148
149 LALI2CreateVector( &status, &i2Vector, 10 );
150 for ( n=i2Vector->length, i2=i2Vector->data; n > 0 ; --n, ++i2 ) {
151 *i2 = pow((n-5),1+abs(n-5));
152 }
153 LALI2PrintVector(i2Vector);
154
155 i4Vector = NULL;
156
157 LALI4CreateVector( &status, &i4Vector, 10 );
158 for ( n=i4Vector->length, i4=i4Vector->data; n > 0 ; --n, ++i4 ) {
159 *i4 = pow((n-5),1+2*abs(n-5));
160 }
161 LALI4PrintVector(i4Vector);
162
163 i8Vector = NULL;
164
165 LALI8CreateVector( &status, &i8Vector, 10 );
166 for ( n=i8Vector->length, i8=i8Vector->data; n > 0 ; --n, ++i8 ) {
167 *i8 = pow((n-5),1+abs(n-5)*abs(n-5));
168 /* *i8 = pow(10,2*n); */
169 }
170 LALI8PrintVector(i8Vector);
171
172 u2Vector = NULL;
173
174 LALU2CreateVector( &status, &u2Vector, 10 );
175 for ( n=u2Vector->length, u2=u2Vector->data; n > 0 ; --n, ++u2 ) {
176 *u2 = pow(abs(n-5),1+abs(n-5));
177 }
178 LALU2PrintVector(u2Vector);
179
180 u4Vector = NULL;
181
182 LALU4CreateVector( &status, &u4Vector, 10 );
183 for ( n=u4Vector->length, u4=u4Vector->data; n > 0 ; --n, ++u4 ) {
184 *u4 = pow(abs(n-5),1+2*abs(n-5));
185 }
186 LALU4PrintVector(u4Vector);
187
188 u8Vector = NULL;
189
190 LALU8CreateVector( &status, &u8Vector, 10 );
191 for ( n=u8Vector->length, u8=u8Vector->data; n > 0 ; --n, ++u8 ) {
192 *u8 = pow(abs(n-5),1+abs(n-5)*abs(n-5));
193 /* *u8 = pow(10,2*n); */
194 }
195 LALU8PrintVector(u8Vector);
196
197
198 charVector = NULL;
199
200 LALCHARCreateVector( &status, &charVector, 10 );
201 ch = charVector->data;
202 *(ch++) = 'a';
203 *(ch++) = 'A';
204 *(ch++) = '%';
205 *(ch++) = '@';
206 *(ch++) = '2';
207 *(ch++) = 'e';
208 *(ch++) = '+';
209 *(ch++) = '\a';
210 *(ch++) = 127;
211 *(ch++) = '\0';
212
213 LALCHARPrintVector(charVector);
214
215 return 0;
216}
217
218/** \endcond */
int main(int argc, char *argv[])
Definition: cache.c:25
#define crect(re, im)
Construct a COMPLEX16 from real and imaginary parts.
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
double complex COMPLEX16
Double-precision floating-point complex number (16 bytes total)
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.
#define crectf(re, im)
Construct a COMPLEX8 from real and imaginary parts.
uint16_t UINT2
Two-byte unsigned integer.
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
void LALU2PrintVector(UINT2Vector *vector)
void LALU8PrintVector(UINT8Vector *vector)
void LALDPrintVector(REAL8Vector *vector)
void LALI4PrintVector(INT4Vector *vector)
void LALCHARPrintVector(CHARVector *vector)
void LALI8PrintVector(INT8Vector *vector)
void LALCPrintVector(COMPLEX8Vector *vector)
void LALI2PrintVector(INT2Vector *vector)
void LALSPrintVector(REAL4Vector *vector)
void LALU4PrintVector(UINT4Vector *vector)
void LALZPrintVector(COMPLEX16Vector *vector)
void LALCCreateVector(LALStatus *, COMPLEX8Vector **, UINT4)
void LALU4CreateVector(LALStatus *, UINT4Vector **, UINT4)
void LALU8CreateVector(LALStatus *, UINT8Vector **, UINT4)
void LALCHARCreateVector(LALStatus *, CHARVector **, UINT4)
void LALU2CreateVector(LALStatus *, UINT2Vector **, UINT4)
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALI4CreateVector(LALStatus *, INT4Vector **, UINT4)
void LALI8CreateVector(LALStatus *, INT8Vector **, UINT4)
void LALZCreateVector(LALStatus *, COMPLEX16Vector **, UINT4)
void LALI2CreateVector(LALStatus *, INT2Vector **, UINT4)
void LALSCreateVector(LALStatus *, REAL4Vector **, UINT4)
Vector of type CHAR, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:73
CHAR * data
Pointer to the data array.
Definition: LALDatatypes.h:78
Vector of type COMPLEX16, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:172
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:176
COMPLEX16 * data
Pointer to the data array.
Definition: LALDatatypes.h:177
Vector of type COMPLEX8, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:163
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:167
COMPLEX8 * data
Pointer to the data array.
Definition: LALDatatypes.h:168
Vector of type INT2, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:91
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:95
INT2 * data
Pointer to the data array.
Definition: LALDatatypes.h:96
Vector of type INT4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:109
INT4 * data
Pointer to the data array.
Definition: LALDatatypes.h:114
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:113
Vector of type INT8, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:127
INT8 * data
Pointer to the data array.
Definition: LALDatatypes.h:132
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:131
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
Vector of type REAL4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:145
REAL4 * data
Pointer to the data array.
Definition: LALDatatypes.h:150
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:149
Vector of type REAL8, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:154
REAL8 * data
Pointer to the data array.
Definition: LALDatatypes.h:159
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:158
Vector of type UINT2, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:100
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:104
UINT2 * data
Pointer to the data array.
Definition: LALDatatypes.h:105
Vector of type UINT4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:118
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:122
UINT4 * data
Pointer to the data array.
Definition: LALDatatypes.h:123
Vector of type UINT8, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:136
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:140
UINT8 * data
Pointer to the data array.
Definition: LALDatatypes.h:141