26 static void vector_fmul_c(
float *dst,
const float *src0,
const float *src1,
30 for (i = 0; i <
len; i++)
31 dst[i] = src0[i] * src1[i];
38 for (i = 0; i <
len; i++)
39 dst[i] += src[i] * mul;
46 for (i = 0; i <
len; i++)
47 dst[i] = src[i] * mul;
54 for (i = 0; i <
len; i++)
55 dst[i] = src[i] * mul;
59 const float *src1,
const float *win,
int len)
67 for (i = -len, j = len - 1; i < 0; i++, j--) {
72 dst[i] = s0 * wj - s1 * wi;
73 dst[j] = s0 * wi + s1 * wj;
78 const float *src2,
int len){
81 for (i = 0; i <
len; i++)
82 dst[i] = src0[i] * src1[i] + src2[i];
86 const float *src1,
int len)
91 for (i = 0; i <
len; i++)
92 dst[i] = src0[i] * src1[-i];
100 for (i = 0; i <
len; i++) {
101 float t = v1[i] - v2[i];
112 for (i = 0; i <
len; i++)
152 #include "internal.h"
160 static void fill_float_array(
AVLFG *lfg,
float *
a,
int len)
163 double bmg[2], stddev = 10.0, mean = 0.0;
165 for (i = 0; i <
len; i += 2) {
167 a[i] = bmg[0] * stddev + mean;
168 a[i + 1] = bmg[1] * stddev + mean;
171 static int compare_floats(
const float *a,
const float *
b,
int len,
175 for (i = 0; i <
len; i++) {
176 if (fabsf(a[i] - b[i]) > max_diff) {
178 i, a[i], b[i], a[i] - b[i]);
185 static void fill_double_array(
AVLFG *lfg,
double *a,
int len)
188 double bmg[2], stddev = 10.0, mean = 0.0;
190 for (i = 0; i <
len; i += 2) {
192 a[i] = bmg[0] * stddev + mean;
193 a[i + 1] = bmg[1] * stddev + mean;
197 static int compare_doubles(
const double *a,
const double *b,
int len,
202 for (i = 0; i <
len; i++) {
203 if (fabs(a[i] - b[i]) > max_diff) {
205 i, a[i], b[i], a[i] - b[i]);
213 const float *v1,
const float *v2)
222 if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
228 #define ARBITRARY_FMAC_SCALAR_CONST 0.005
230 const float *v1,
const float *src0,
float scale)
236 memcpy(cdst, v1, LEN *
sizeof(*v1));
237 memcpy(odst, v1, LEN *
sizeof(*v1));
242 if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMAC_SCALAR_CONST))
249 const float *v1,
float scale)
258 if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
265 const double *v1,
double scale)
274 if (ret = compare_doubles(cdst, odst, LEN, DBL_EPSILON))
280 #define ARBITRARY_FMUL_WINDOW_CONST 0.008
282 const float *v1,
const float *v2,
const float *v3)
291 if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_WINDOW_CONST))
297 #define ARBITRARY_FMUL_ADD_CONST 0.005
299 const float *v1,
const float *v2,
const float *v3)
308 if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST))
315 const float *v1,
const float *v2)
324 if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
331 const float *v1,
const float *v2)
339 memcpy(cv1, v1, LEN *
sizeof(*v1));
340 memcpy(cv2, v2, LEN *
sizeof(*v2));
341 memcpy(ov1, v1, LEN *
sizeof(*v1));
342 memcpy(ov2, v2, LEN *
sizeof(*v2));
347 if ((ret = compare_floats(cv1, ov1, LEN, FLT_EPSILON)) ||
348 (ret = compare_floats(cv2, ov2, LEN, FLT_EPSILON)))
354 #define ARBITRARY_SCALARPRODUCT_CONST 0.2
356 const float *v1,
const float *v2)
364 if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST))
370 int main(
int argc,
char **argv)
383 if (argc > 2 && !strcmp(argv[1],
"-s"))
384 seed = strtoul(argv[2], NULL, 10);
392 fill_float_array(&lfg, src0, LEN);
393 fill_float_array(&lfg, src1, LEN);
394 fill_float_array(&lfg, src2, LEN);
396 fill_double_array(&lfg, dbl_src0, LEN);
397 fill_double_array(&lfg, dbl_src1, LEN);
403 if (test_vector_fmul(&fdsp, &cdsp, src0, src1))
405 if (test_vector_fmac_scalar(&fdsp, &cdsp, src2, src0, src1[0]))
407 if (test_vector_fmul_scalar(&fdsp, &cdsp, src0, src1[0]))
409 if (test_vector_fmul_window(&fdsp, &cdsp, src0, src1, src2))
411 if (test_vector_fmul_add(&fdsp, &cdsp, src0, src1, src2))
413 if (test_vector_fmul_reverse(&fdsp, &cdsp, src0, src1))
415 if (test_butterflies_float(&fdsp, &cdsp, src0, src1))
417 if (test_scalarproduct_float(&fdsp, &cdsp, src0, src1))
419 if (test_vector_dmul_scalar(&fdsp, &cdsp, dbl_src0, dbl_src1[0]))