diff options
-rw-r--r-- | scilab2c/src/c/implicitList/dimplicitLists.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scilab2c/src/c/implicitList/dimplicitLists.c b/scilab2c/src/c/implicitList/dimplicitLists.c index d3908ed2..1c7753f8 100644 --- a/scilab2c/src/c/implicitList/dimplicitLists.c +++ b/scilab2c/src/c/implicitList/dimplicitLists.c @@ -10,33 +10,33 @@ * */ +#include <math.h> #include "implicitList.h" void dimplicitLists(double start, double step, double end, double *out) { int i = 0; + int iNbElements = 0; if (start <= end) { if (start < start + step) { - while (start <= end) - { - out[i] = start; - start += step; - ++i; - } + iNbElements = floor((end - start) / step) + 1; + out[0] = start; } } else { if (start > start + step) { - while (start >= end) - { - out[i] = start; - start += step; - ++i; - } + iNbElements = floor((start - end) / step) + 1; + out[0] = start; } } + + for (i = 1 ; i < iNbElements ; ++i) + { + start += step; + out[i] = start; + } } |