Initial import to Tizen
[profile/ivi/sphinxbase.git] / test / unit / test_matrix / test_determinant.c
1 #include <stdio.h>
2 #include <string.h>
3
4 #include "matrix.h"
5 #include "ckd_alloc.h"
6
7 const float32 foo[3][3] = {
8         {2, 0.42, 1},
9         {0.42, 2, -0.3},
10         {1, -0.3, 2}
11 };
12 const float32 bar[3][3] = {
13         {1, 0, 1},
14         {0, 1, 0},
15         {0, 0, 1}
16 };
17
18 int
19 main(int argc, char *argv[])
20 {
21         float32 **a;
22
23         a = (float32 **)ckd_calloc_2d(3, 3, sizeof(float32));
24
25         memcpy(a[0], foo, sizeof(float32) * 3 * 3);
26         /* Should see 5.22 */
27         printf("%.2f\n", determinant(a, 3));
28
29         /* Should see -1.0 */
30         memcpy(a[0], bar, sizeof(float32) * 3 * 3);
31         printf("%.2f\n", determinant(a, 3));
32
33         ckd_free_2d((void **)a);
34
35         return 0;
36 }