Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | #include "jtest.h" |
2 | #include "matrix_test_data.h" |
||
3 | #include "arr_desc.h" |
||
4 | #include "arm_math.h" /* FUTs */ |
||
5 | #include "ref.h" /* Reference Functions */ |
||
6 | #include "test_templates.h" |
||
7 | #include "matrix_templates.h" |
||
8 | #include "type_abbrev.h" |
||
9 | |||
10 | JTEST_DEFINE_TEST(arm_mat_inverse_f32_test, arm_mat_inverse_f32) |
||
11 | { |
||
12 | TEMPLATE_DO_ARR_DESC( |
||
13 | mat_idx, arm_matrix_instance_f32 *, mat_ptr, matrix_f32_invertible_inputs |
||
14 | , |
||
15 | JTEST_DUMP_STRF("Matrix Dimensions: %dx%d\n", |
||
16 | (int)mat_ptr->numRows, |
||
17 | (int)mat_ptr->numCols); |
||
18 | |||
19 | if (MATRIX_TEST_VALID_SQUARE_DIMENSIONS(arm_matrix_instance_f32 *, mat_ptr)) |
||
20 | { |
||
21 | MATRIX_TEST_CONFIG_SAMESIZE_OUTPUT(arm_matrix_instance_f32 *, mat_ptr); |
||
22 | |||
23 | /* arm_mat_inverse_f32() modifies its source input. Use the scratch |
||
24 | * buffer to store a copy of the intended input. */ |
||
25 | { |
||
26 | float32_t * original_pdata_ptr = mat_ptr->pData; |
||
27 | |||
28 | memcpy(matrix_output_scratch, |
||
29 | mat_ptr->pData, |
||
30 | mat_ptr->numRows * mat_ptr->numCols * sizeof(float32_t)); |
||
31 | mat_ptr->pData = (void*) &matrix_output_scratch; |
||
32 | |||
33 | JTEST_COUNT_CYCLES(arm_mat_inverse_f32(mat_ptr, &matrix_output_fut)); |
||
34 | mat_ptr->pData = original_pdata_ptr; |
||
35 | } |
||
36 | |||
37 | ref_mat_inverse_f32(mat_ptr, &matrix_output_ref); |
||
38 | |||
39 | MATRIX_SNR_COMPARE_INTERFACE(arm_matrix_instance_f32, |
||
40 | float32_t); |
||
41 | }); |
||
42 | |||
43 | return JTEST_TEST_PASSED; |
||
44 | } |
||
45 | |||
46 | JTEST_DEFINE_TEST(arm_mat_inverse_f64_test, arm_mat_inverse_f64) |
||
47 | { |
||
48 | TEMPLATE_DO_ARR_DESC( |
||
49 | mat_idx, arm_matrix_instance_f64 *, mat_ptr, matrix_f64_invertible_inputs |
||
50 | , |
||
51 | JTEST_DUMP_STRF("Matrix Dimensions: %dx%d\n", |
||
52 | (int)mat_ptr->numRows, |
||
53 | (int)mat_ptr->numCols); |
||
54 | |||
55 | if (MATRIX_TEST_VALID_SQUARE_DIMENSIONS(arm_matrix_instance_f64 *, mat_ptr)) |
||
56 | { |
||
57 | MATRIX_TEST_CONFIG_SAMESIZE_OUTPUT(arm_matrix_instance_f64 *, mat_ptr); |
||
58 | |||
59 | /* arm_mat_inverse_f64() modifies its source input. Use the scratch |
||
60 | * buffer to store a copy of the intended input. */ |
||
61 | { |
||
62 | float64_t * original_pdata_ptr = mat_ptr->pData; |
||
63 | |||
64 | memcpy(matrix_output_scratch, |
||
65 | mat_ptr->pData, |
||
66 | mat_ptr->numRows * mat_ptr->numCols * sizeof(float64_t)); |
||
67 | mat_ptr->pData = (void*) &matrix_output_scratch; |
||
68 | |||
69 | JTEST_COUNT_CYCLES(arm_mat_inverse_f64(mat_ptr, &matrix_output_fut64)); |
||
70 | mat_ptr->pData = original_pdata_ptr; |
||
71 | } |
||
72 | |||
73 | ref_mat_inverse_f64(mat_ptr, &matrix_output_ref64); |
||
74 | |||
75 | MATRIX_DBL_SNR_COMPARE_INTERFACE(arm_matrix_instance_f64); |
||
76 | }); |
||
77 | |||
78 | return JTEST_TEST_PASSED; |
||
79 | } |
||
80 | |||
81 | /*--------------------------------------------------------------------------------*/ |
||
82 | /* Collect all tests in a group. */ |
||
83 | /*--------------------------------------------------------------------------------*/ |
||
84 | |||
85 | JTEST_DEFINE_GROUP(mat_inverse_tests) |
||
86 | { |
||
87 | /* |
||
88 | To skip a test, comment it out. |
||
89 | */ |
||
90 | JTEST_TEST_CALL(arm_mat_inverse_f32_test); |
||
91 | JTEST_TEST_CALL(arm_mat_inverse_f64_test); |
||
92 | } |