Révision 21

Pi/C/Simple/Makefile (revision 21)
1
EXECUTABLE=Pi_LONG Pi_INTEGER
1
EXECUTABLE=Pi_LONG Pi_INT Pi_LONG_IFSQRT Pi_LONG_IFWOSQRT  Pi_INT_IFSQRT Pi_INT_IFWOSQRT
2 2

  
3 3
SOURCE=Pi.c
4 4

  
5 5
CC=gcc
6
CFLAGS=-Wall -O3 -std=c99
6
CFLAGS=-Wall -O3 -std=c99 -g
7 7
LIBRARY=-lm
8 8

  
9 9
all: $(EXECUTABLE)
......
12 12

  
13 13
	$(CC) $(CFLAGS) $(DIRECTIVES) -DLONG -o $@ $< $(LIBRARY)
14 14

  
15
Pi_INTEGER: $(SOURCE)
15
Pi_LONG_IFSQRT: $(SOURCE)
16 16

  
17
	$(CC) $(CFLAGS) $(DIRECTIVES) -DLONG -DIFSQRT -o $@ $< $(LIBRARY)
18

  
19
Pi_LONG_IFWOSQRT: $(SOURCE)
20

  
21
	$(CC) $(CFLAGS) $(DIRECTIVES) -DLONG -DIFWOSQRT -o $@ $< $(LIBRARY)
22

  
23
Pi_INT: $(SOURCE)
24

  
17 25
	$(CC) $(CFLAGS) $(DIRECTIVES) -DINTEGER -o $@ $< $(LIBRARY)
18 26

  
27
Pi_INT_IFSQRT: $(SOURCE)
28

  
29
	$(CC) $(CFLAGS) $(DIRECTIVES) -DINTEGER -IFSQRT -o $@ $< $(LIBRARY)
30

  
31
Pi_INT_IFWOSQRT: $(SOURCE)
32

  
33
	$(CC) $(CFLAGS) $(DIRECTIVES) -DINTEGER -IFWOSQRT -o $@ $< $(LIBRARY)
34

  
19 35
.PHONY: clean check mrproper
20 36

  
21 37
mrproper: 
Pi/C/Simple/Pi.c (revision 21)
40 40
      float y=MWCfp ;
41 41

  
42 42
      // Matching test
43

  
44
#ifdef IFSQRT
45
      if ( sqrt(x*x+y*y) < 1.0f ) {
46
	total+=1;
47
      }
48
#elif IFWOSQRT
49
      if ( (x*x+y*y) < 1.0f ) {
50
	total+=1;
51
      }
52
#else
43 53
      int inside=((x*x+y*y) < 1.0f) ? 1:0;
44 54
      total+=inside;
55
#endif
56

  
45 57
   }
46 58

  
47 59
   return(total);
......
62 74

  
63 75
  float pi=(float)MainLoopGlobal(iterations,seed_w,seed_z)/(float)iterations*4;
64 76

  
65
  printf("\tPi=%f with error %f and %lu iterations\n\n",pi,
77
  printf("\tPi=%.40f\n\twith error %.40f\n\twith %lu iterations\n\n",pi,
66 78
         fabs(pi-4*atan(1))/pi,(unsigned long)iterations);
67 79
  
68 80
}

Formats disponibles : Unified diff