File: widen_hints_float.c

package info (click to toggle)
frama-c 20220511-manganese-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 66,492 kB
  • sloc: ml: 278,834; ansic: 47,093; sh: 4,823; makefile: 3,613; javascript: 2,436; python: 1,919; perl: 897; lisp: 293; xml: 62
file content (74 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download | duplicates (2)
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
/* run.config*
 PLUGIN: @EVA_PLUGINS@
   STDOPT: #"-eva-subdivide-non-linear 20"
*/

#include "__fc_builtin.h"
#include <math.h>

void parabola(void) {
  /*
    The expression is a parabola p
      where p([0.;64.]) = [0.;64.] and p([64.;128.]) = [0.;64.].
      For any value x<0, p(x) < x;
      For any value 128.<x, p(x) < -x;
   */

  double f1 = Frama_C_double_interval(0.,1./64.);

  //@ loop widen_hints f1, 71.;
  for(int i = 0; i < 100; i++){
    f1 = (64*64 - (f1 - 64) * (f1 - 64))/64;
  }

  double f2 = Frama_C_double_interval(-1./64.,-0);

  //@ loop widen_hints f2, -80.;
  for(int i = 0; i < 100; i++){
    f2 = -(64*64 - (-f2 - 64) * (-f2 - 64))/64;
  }

  double f3 = Frama_C_double_interval(0.,1./64.);

  for(int i = 0; i < 100; i++){
    f3 = (64*64 - (f3 - 64) * (f3 - 64))/64;
  }
}

void trigo(void) {
  double f1 = 0.0;

  for (int i = 0; i < 100; i++) {
    f1 = sin(f1 + Frama_C_double_interval(-0.01, 0.01));
  }
}

void first_order_filter(void) {
  float f1 = 0.0;
  for (int i = 1; i < 100; i++)
    f1 = f1 * 0.8 + Frama_C_double_interval(-1.0, 1.0);

  float f2 = 0.0;
  //@ loop widen_hints f2, 5., -5.;
  for (int i = 1; i < 100; i++)
    f2 = f2 * 0.8 + Frama_C_double_interval(-1.0, 1.0);
}

void newton_sqrt(void) {
  double f1 = 2.0;
  for (int i = 1; i < 100; i++)
    f1 = (f1 + 2.0 / f1) / 2.0;

  double f2 = 2.0;
  //@ loop widen_hints f2, 1.4;
  for (int i = 1; i < 100; i++) {
    f2 = (f2 + 2.0 / f2) / 2.0;
  }
}

void main(voi) {
  parabola();
  trigo();
  first_order_filter();
  newton_sqrt();
}