1 /*
2 *
3 * Copyright (c) 2005 The Regents of the University of California. All
4 * rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * - Neither the name of the University nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 */
30
31 /*
32 * test program determines max autocorrelation for different seed values
33 */
34
35 #include "ar.h"
36
37 int main(int argc, char **argv)
38 {
39 int i,j;
40 int chirp_len = CHIRP_CHIPS*MOD_FACTOR*RANGE_FACTOR;
41
42 int16_t *bpsk = g_new(int16_t,chirp_len);
43 float *f_input;
44 float *correl;
45 complex *fft_input;
46 complex *fft_correl;
47 f_input = g_new(float,chirp_len);
48 correl = g_new(float,chirp_len);
49 fft_input = g_new(complex,chirp_len);
50 fft_correl = g_new(complex,chirp_len);
51
52 for (i=1; i<1000; i++) {
53 ar_pn_generate_chirp(bpsk, chirp_len, i, 0, (float)(CHIRP_CHIPS*MOD_FACTOR) / 8192);
54
55 /* convert to float */
56 for (j=0; j<chirp_len; j++)
57 f_input[j] = (float)bpsk[j];
58
59 nl_fft(f_input, fft_input, chirp_len);
60 nl_fd_correl(fft_correl, correl, fft_input, fft_input, chirp_len);
61
62 float max = 0;
63 for (j=3; j<(chirp_len-2); j++) {
64 if (fabs(correl[j]) > max)
65 max = fabs(correl[j]);
66 }
67
68 float frac = fabs(correl[0]) / max;
69 printf ("%d %f %f\n", i, max, frac);
70
71 #if 0
72 for (j=0; j<chirp_len; j++) {
73 printf("%d %f %f\n", j, f_input[j], correl[j]);
74 }
75 #endif
76 }
77
78 return 0;
79 }
80
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.