summaryrefslogtreecommitdiff
path: root/test/c/integr.c
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2006-06-29 16:07:01 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2006-06-29 16:07:01 +0000
commit917e891d06e16516fe90e286f184062e6b7409fe (patch)
treedd5ea25f036abdb00a7b35b0caeac5e75cae82ed /test/c/integr.c
parenta29dfda37f01871db5b8e40d5312d08fc0ee53e3 (diff)
Version C des tests Cminor
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@40 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/c/integr.c')
-rw-r--r--test/c/integr.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/c/integr.c b/test/c/integr.c
new file mode 100644
index 0000000..abcbd28
--- /dev/null
+++ b/test/c/integr.c
@@ -0,0 +1,23 @@
+static double square(double x)
+{
+ return x * x;
+}
+
+static double integr(double (*f)(double), double low, double high, int n)
+{
+ double h, x, s;
+ int i;
+
+ h = (high - low) / n;
+ s = 0;
+ for (i = n, x = low; i > 0; i--, x += h) s += f(x);
+ return s * h;
+}
+
+double test(int n)
+{
+ return integr(square, 0.0, 1.0, n);
+}
+
+
+