diff options
author | jofret | 2008-05-30 12:14:49 +0000 |
---|---|---|
committer | jofret | 2008-05-30 12:14:49 +0000 |
commit | bce36a4569db3eb9ffc61faa6ed4fe6c53181d7f (patch) | |
tree | 268779c3c76db52f04e86e08520910518840ae7f /src/statisticsFunctions/mean/cmeana.c | |
parent | 1b6fd6bc59862405df426528f0ba21785d59d821 (diff) | |
download | scilab2c-bce36a4569db3eb9ffc61faa6ed4fe6c53181d7f.tar.gz scilab2c-bce36a4569db3eb9ffc61faa6ed4fe6c53181d7f.tar.bz2 scilab2c-bce36a4569db3eb9ffc61faa6ed4fe6c53181d7f.zip |
* Adding mean function
!! WARNING !!
For the moment only the global mean is implemented, the one
with only one parameter.
More will follow.
Diffstat (limited to 'src/statisticsFunctions/mean/cmeana.c')
-rw-r--r-- | src/statisticsFunctions/mean/cmeana.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/statisticsFunctions/mean/cmeana.c b/src/statisticsFunctions/mean/cmeana.c new file mode 100644 index 00000000..ad2a66fc --- /dev/null +++ b/src/statisticsFunctions/mean/cmeana.c @@ -0,0 +1,24 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "mean.h" + +floatComplex cmeana(floatComplex *in, int size) { + floatComplex accumulate = FloatComplex(0.0f, 0.0f); + int i = 0; + + for (i = 0; i < size; ++i) + { + accumulate = cadds(accumulate, in[i]); + } + return FloatComplex(creals(accumulate) / (float) size, cimags(accumulate) / (float) size); +} |