diff options
Diffstat (limited to 'scipy/weave/examples/ramp.c')
-rw-r--r-- | scipy/weave/examples/ramp.c | 29 |
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 |