summaryrefslogtreecommitdiff
path: root/math.c
blob: 8e9629d414b95010c7faefb5b6439e13a10ad314 (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
#ifdef __DECC

#include <machine/builtins.h>
#define __rpcc(x) __RPCC(x)
extern int printf (const char * format, ...);
#define M_PI 3.14159265358979323846  /* pi */

#elif defined __GNUC__

#define __rpcc(x) __builtin_alpha_rpcc(x)
#include <stdio.h>
#include <math.h>

#else
#error Unknown compiler
#endif

#define CPML "cpml"
#define GLIBC "glibc"

#ifndef FUNCTION
#error Must define FUNCTION
#else
double FUNCTION(double);
#endif

#ifndef DOMAIN_START
#error Must define RANGE_START
#endif

#ifndef DOMAIN_END
#error Must define DOMAIN_END
#endif

#ifndef INCREMENT
#define INCREMENT 0.1
#endif


int main(int argc, char * argv[]) {
	double x;
	double results[100];
	int i;
	int iterations;

	unsigned int start, end;

	start = __rpcc();

	for (i = 0, x = DOMAIN_START; x < DOMAIN_END; i++, x += INCREMENT) {
		results[i] = FUNCTION(x);
	}

	end = __rpcc();

	iterations = i;

	if (argc != 1) {
		for (i = 0; i < iterations; i++) {
			printf("%f\n", results[i]);
		}
	}

	printf("%u,", (end - start) / iterations);

	return 0;
}