[fix] log_sum_exp in SSE mode shouldn't modify the original array

This commit is contained in:
Al
2017-03-15 00:22:17 -04:00
parent c201939f3a
commit d43989cf1c

View File

@@ -465,9 +465,10 @@ static inline void remez9_0_log2_sse(double *values, size_t num)
\ \
static inline type name##_log_sum_exp(type *array, size_t n) { \ static inline type name##_log_sum_exp(type *array, size_t n) { \
type max = name##_max(array, n); \ type max = name##_max(array, n); \
name##_sub(array, max, n); \ type result = 0; \
remez9_0_log2_sse(array, n); \ for (size_t i = 0; i < n; i++) { \
type result = name##_sum(array, n); \ result += exp(array[i] - max); \
} \
return max + log(result); \ return max + log(result); \
} }