summaryrefslogtreecommitdiff
path: root/scipy/weave/examples/ramp.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2005-09-26 20:20:16 +0000
committerTravis Oliphant <oliphant@enthought.com>2005-09-26 20:20:16 +0000
commit45d01a4be1c4221132ba46d687e6af3a8df3329b (patch)
treece3be5290e918def7c7187e747c5460193b0ca85 /scipy/weave/examples/ramp.c
parentccd1c3db37672627aa4fe0fdb5437f5dddc0fe86 (diff)
downloadnumpy-45d01a4be1c4221132ba46d687e6af3a8df3329b.tar.gz
Moved weave
Diffstat (limited to 'scipy/weave/examples/ramp.c')
-rw-r--r--scipy/weave/examples/ramp.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/scipy/weave/examples/ramp.c b/scipy/weave/examples/ramp.c
new file mode 100644
index 000000000..3a733dce0
--- /dev/null
+++ b/scipy/weave/examples/ramp.c
@@ -0,0 +1,29 @@
+#include <time.h>
+#include <stdio.h>
+
+void Ramp(double* result, int size, double start, double end)
+{
+ double step = (end-start)/(size-1);
+ double val = start;
+ int i;
+ for (i = 0; i < size; i++)
+ {
+ *result++ = val;
+ val += step;
+ }
+}
+
+void main()
+{
+ double array[10000];
+ int i;
+ clock_t t1, t2;
+ float seconds;
+ t1 = clock();
+ for (i = 0; i < 10000; i++)
+ Ramp(array, 10000, 0.0, 1.0);
+ t2 = clock();
+ seconds = (float)(t2-t1)/CLOCKS_PER_SEC;
+ printf("c version (seconds): %f\n", seconds);
+ printf("array[500]: %f\n", array[500]);
+} \ No newline at end of file