Merge pull request #227 from v923z/std-fix

fixed std
This commit is contained in:
Zoltán Vörös 2020-11-18 19:18:06 +01:00 committed by GitHub
commit 2e42dee0e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View file

@ -86,18 +86,16 @@ extern mp_obj_module_t ulab_numerical_module;
// https://www.johndcook.com/blog/2008/09/26/comparing-three-methods-of-computing-standard-deviation/
#define RUN_STD1(ndarray, type, array, results, r, index, div)\
({\
mp_float_t M, m, S = 0.0, s = 0.0;\
M = m = (mp_float_t)(*(type *)(array));\
for(size_t i=1; i < (ndarray)->shape[(index)]; i++) {\
(array) += (ndarray)->strides[(index)];\
mp_float_t M = 0.0, m = 0.0, S = 0.0, s = 0.0;\
for(size_t i=0; i < (ndarray)->shape[(index)]; i++) {\
mp_float_t value = (mp_float_t)(*(type *)(array));\
m = M + (value - M) / (mp_float_t)i;\
m = M + (value - M) / (mp_float_t)(i+1);\
s = S + (value - M) * (value - m);\
M = m;\
S = s;\
(array) += (ndarray)->strides[(index)];\
}\
(array) += (ndarray)->strides[(index)];\
*(r)++ = MICROPY_FLOAT_C_FUN(sqrt)((ndarray)->shape[(index)] * s / (div));\
*(r)++ = MICROPY_FLOAT_C_FUN(sqrt)(s / (div));\
})
#define RUN_DIFF1(ndarray, type, array, results, rarray, index, stencil, N)\

View file

@ -32,7 +32,7 @@
#include "user/user.h"
#include "vector/vectorise.h"
#define ULAB_VERSION 1.4.0
#define ULAB_VERSION 1.4.1
#define xstr(s) str(s)
#define str(s) #s
#if ULAB_NUMPY_COMPATIBILITY

View file

@ -1,5 +1,8 @@
Wed, 18 Nov 2020
version 1.4.1.
fixed std
version 1.4.0
removed size from linalg