[math] Adding array_{op}_times_scalar methods

This commit is contained in:
Al
2016-01-09 01:42:54 -05:00
parent 2f1e2139ca
commit 9c4b5ccbb1
2 changed files with 225 additions and 200 deletions

View File

@@ -182,10 +182,23 @@
} \ } \
} \ } \
\ \
static inline void name##_add_array_times_scalar(type *a1, type *a2, double v, size_t n) { \
for (int i = 0; i < n; i++) { \
a1[i] += a2[i] * v; \
} \
} \
\
static inline void name##_sub_array(type *a1, type *a2, size_t n) { \ static inline void name##_sub_array(type *a1, type *a2, size_t n) { \
for (int i = 0; i < n; i++) { \ for (int i = 0; i < n; i++) { \
a1[i] -= a2[i]; \ a1[i] -= a2[i]; \
} \ } \
} \
\
\
static inline void name##_sub_array_times_scalar(type *a1, type *a2, double v, size_t n) { \
for (int i = 0; i < n; i++) { \
a1[i] -= a2[i] * v; \
} \
} \ } \
\ \
static inline void name##_mul_array(type *a1, type *a2, size_t n) { \ static inline void name##_mul_array(type *a1, type *a2, size_t n) { \
@@ -194,12 +207,24 @@
} \ } \
} \ } \
\ \
static inline void name##_mul_array_times_scalar(type *a1, type *a2, double v, size_t n) { \
for (int i = 0; i < n; i++) { \
a1[i] *= a2[i] * v; \
} \
} \
\
static inline void name##_div_array(type *a1, type *a2, size_t n) { \ static inline void name##_div_array(type *a1, type *a2, size_t n) { \
for (int i = 0; i < n; i++) { \ for (int i = 0; i < n; i++) { \
a1[i] /= a2[i]; \ a1[i] /= a2[i]; \
} \ } \
} \ } \
\ \
static inline void name##_div_array_times_scalar(type *a1, type *a2, double v, size_t n) { \
for (int i = 0; i < n; i++) { \
a1[i] /= a2[i] * v; \
} \
} \
\
static inline type name##_dot(type *a1, type *a2, size_t n) { \ static inline type name##_dot(type *a1, type *a2, size_t n) { \
type result = 0; \ type result = 0; \
for (int i = 0; i < n; i++) { \ for (int i = 0; i < n; i++) { \