diff options
author | jofret | 2009-02-04 13:40:37 +0000 |
---|---|---|
committer | jofret | 2009-02-04 13:40:37 +0000 |
commit | cb2404246c35eff9b1a976bac98ba9532d82a6af (patch) | |
tree | ce18c438b5bf3f440b54a512f8d341e69fd9a7aa /src | |
parent | 8f7564882af670a5b958a4f2e8cc5b81892f45ee (diff) | |
download | scilab2c-cb2404246c35eff9b1a976bac98ba9532d82a6af.tar.gz scilab2c-cb2404246c35eff9b1a976bac98ba9532d82a6af.tar.bz2 scilab2c-cb2404246c35eff9b1a976bac98ba9532d82a6af.zip |
Without malloc ?
Diffstat (limited to 'src')
-rw-r--r-- | src/auxiliaryFunctions/rand/zranda.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/auxiliaryFunctions/rand/zranda.c b/src/auxiliaryFunctions/rand/zranda.c index 98cc10cf..a9b9c895 100644 --- a/src/auxiliaryFunctions/rand/zranda.c +++ b/src/auxiliaryFunctions/rand/zranda.c @@ -14,20 +14,12 @@ #include <stdio.h> void zranda(doubleComplex *out, int size) { int i = 0; - double *Real_randa, *Imag_randa; - Real_randa = malloc((uint)size*sizeof(double)); - Imag_randa = malloc((uint)size*sizeof(double)); - + for (i = 0 ; i < size ; ++i) { - Real_randa[i]=drands(); + out[i] = DoubleComplex(drands(), 0); } - for (i = 0 ; i < size ; ++i) { - Imag_randa[i]=drands(); + for (i = 0 ; i < size ; ++i) { + out[i] = DoubleComplex(zreals(out[i]), drands()); } - - for (i = 0 ; i < size ; ++i) { - out[i]=DoubleComplex(Real_randa[i],Imag_randa[i]); - } - } |