File: dotprod_cccf_example.c

package info (click to toggle)
liquid-dsp 1.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,216 kB
  • sloc: ansic: 115,859; sh: 3,513; makefile: 1,350; python: 274; asm: 11
file content (42 lines) | stat: -rw-r--r-- 1,148 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// dotprod_cccf_example.c
//
// This example demonstrates the interface to the complex floating-point
// dot product object (dotprod_cccf).
//

#include <stdio.h>
#include "liquid.h"

int main() {
    // input array
    float complex x[] = { 1 + 1 * _Complex_I,
                          2 + 1 * _Complex_I,
                          3 + 1 * _Complex_I,
                          4 + 1 * _Complex_I,
                          5 + 1 * _Complex_I};

    // coefficients array
    float complex h[] = { 1 + 1 * _Complex_I,
                         -1 + 1 * _Complex_I,
                          1 + 1 * _Complex_I,
                         -1 + 1 * _Complex_I,
                          1 + 1 * _Complex_I};

    // dot product result
    float complex y;

    // run regular dot product
    dotprod_cccf_run(x,h,5,&y);
    printf("dotprod_cccf              : %8.2f + j%8.2f\n", crealf(y), cimagf(y));

    // run structured dot product
    dotprod_cccf q = dotprod_cccf_create(x,5);
    dotprod_cccf_execute(q,h,&y);
    printf("dotprod_cccf (structured) : %8.2f + j%8.2f\n", crealf(y), cimagf(y));
    dotprod_cccf_destroy(q);

    return 0;
}