1 //
2 // bsequence_example.c
3 //
4 // This example demonstrates the interface to the bsequence (binary
5 // sequence) object. The bsequence object acts like a buffer of bits
6 // which are stored and manipulated efficiently in memory.
7 //
8
9 #include <stdio.h>
10 #include <complex.h>
11 #include <math.h>
12
13 #include "liquid.h"
14
15 //#define OUTPUT_FILENAME "bsequence_example.m"
16
main()17 int main() {
18 // create and initialize binary sequence
19 unsigned int n=16;
20 bsequence q = bsequence_create(n);
21
22 unsigned char v[4] = {0x35, 0x35};
23 bsequence_init(q,v);
24
25 bsequence_push(q,1);
26 bsequence_push(q,1);
27 bsequence_push(q,1);
28 bsequence_push(q,1);
29
30 bsequence_push(q,0);
31 bsequence_push(q,1);
32
33 bsequence_print(q);
34
35 bsequence_circshift(q);
36 bsequence_print(q);
37 bsequence_circshift(q);
38 bsequence_print(q);
39
40 unsigned int b;
41 unsigned int i;
42 for (i=0; i<n; i++) {
43 b = bsequence_index(q,i);
44 printf("b[%3u] = %3u\n", i, b);
45 }
46
47 // clean up memory
48 bsequence_destroy(q);
49
50 return 0;
51 }
52
53