[math] Adding array_{op}_times_scalar methods
This commit is contained in:
@@ -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++) { \
|
||||||
|
|||||||
Reference in New Issue
Block a user