summaryrefslogtreecommitdiff
path: root/cesar/test_general/proto_gaisler/src/test_spoc.c
blob: 44790ec09e33d3edfe50f15feb49bf466384328c (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    ./src/test_speed.c
 * \brief   « brief description »
 * \ingroup « module »
 *
 * « long description »
 */

#include "common/std.h"
#include "sys/time.h"
#include "math.h"
#include "stdio.h"

#define Pmin 74
#define N0 1155
#define Pmax (Pmin + N0 - 1)

double reg_alpha[41];
double reg_beta[41];
double reg_bloc2[21];
double reg_a0, reg_c0;

void
spoc_update (double rho)
{
    int k;
    double pirho = M_PI*rho;
    double x = pirho * Pmin;
    double xp = pirho * Pmax;
    double s, sp;
    double den = (xp - x);

    double x0 = 2*M_PI*1536*rho;

    for (k=-10; k<=10; k++)
    {
        reg_bloc2[k+10] = sin(x0+k*M_PI)/(x0+k*M_PI);
    }

    double tmp1 = sin (x)/x;
    double tmp2 = x*x;
    reg_a0 = (sin(xp)/xp - tmp1)/(xp*xp - tmp2);
    reg_c0 = tmp1 - reg_a0*tmp2;

    for (k=1; k<=20; k++)
    {
        x += (M_PI + pirho);
        xp += M_PI;
        s = sin (x) /x;
        sp = sin (xp) /xp;
        den -= pirho;
        reg_beta[k+20] = (sp-s)/(den);
        reg_alpha[k+20] = s - reg_beta[k+20]*x;
    }
    x = pirho * Pmin;
    xp = pirho * Pmax;
    den = (xp -x);
    for (k=1; k<=20; k++)
    {
        xp -= (M_PI + pirho);
        x -= M_PI;
        s = sin (x) /x;
        sp = sin (xp) /xp;
        den -= pirho;
        reg_beta[20-k] = (sp-s)/(den);
        reg_alpha[20-k] = s - reg_beta[20-k]*x;
    }
}


int
main (int argc, char **argv)
{
    struct timeval tv0, tv1;
    double rho = 300e-6;
    int t;

    gettimeofday (&tv0, NULL);
    for (t=0; t<1; t++) spoc_update (rho);
    gettimeofday (&tv1, NULL);
    printf ("duration spoc2 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec)));

    gettimeofday (&tv0, NULL);
    for (t=0; t<1000; t++) spoc_update (rho);
    gettimeofday (&tv1, NULL);
    printf ("duration 1000*spoc2 : %d\n",(int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec)));

    return 0;
}