create a_linalg_dot
[liba.git] / test / linalg.h
blob991a632492f90d927e9bb753d54da33e2d4194a1
1 #define MAIN(x) linalg##x
2 #include "test.h"
3 #include "a/linalg.h"
5 static void test_mul(void)
7 a_uint i;
8 a_float z[3 * 3];
9 a_float x[3 * 3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
10 a_float y[3 * 3] = {9, 8, 7, 6, 5, 4, 3, 2, 1};
12 debug("X\t={");
13 for (i = 0; i < 9; ++i)
15 debug("%" A_FLOAT_PRI "g%c", x[i], i < 8 ? ',' : '}');
17 debug("\n");
19 debug("Y\t={");
20 for (i = 0; i < 9; ++i)
22 debug("%" A_FLOAT_PRI "g%c", y[i], i < 8 ? ',' : '}');
24 debug("\n");
26 a_linalg_mulmm(z, x, y, 3, 3, 3);
28 debug("XY\t={");
29 for (i = 0; i < 9; ++i)
31 debug("%" A_FLOAT_PRI "g%c", z[i], i < 8 ? ',' : '}');
33 debug("\n");
35 a_linalg_mulTm(z, x, y, 3, 3, 3);
37 debug("X'Y\t={");
38 for (i = 0; i < 9; ++i)
40 debug("%" A_FLOAT_PRI "g%c", z[i], i < 8 ? ',' : '}');
42 debug("\n");
44 a_linalg_mulmT(z, x, y, 3, 3, 3);
46 debug("XY'\t={");
47 for (i = 0; i < 9; ++i)
49 debug("%" A_FLOAT_PRI "g%c", z[i], i < 8 ? ',' : '}');
51 debug("\n");
53 a_linalg_mulTT(z, x, y, 3, 3, 3);
55 debug("X'Y'\t={");
56 for (i = 0; i < 9; ++i)
58 debug("%" A_FLOAT_PRI "g%c", z[i], i < 8 ? ',' : '}');
60 debug("\n");
62 debug("X.Y\t=%" A_FLOAT_PRI "g\n", a_linalg_dot(x, y, 9));
65 int main(int argc, char *argv[]) /* NOLINT(misc-definitions-in-headers) */
67 main_init(argc, argv, 1);
68 test_mul();
69 return 0;