extern "C" { extern void row_test(); } #include "allocator.h" #include #include #include #include #include #include "dsp/matrix_functions.h" #include "matrix_utils.h" template static void test() { constexpr int NBOUT = C-1; std::cout << "----\r\n"; std::cout << R << " x " << C << "\r\n"; std::cout << "NBOUT = " << NBOUT << "\r\n"; #if defined(STATIC_TEST) PMat a; #else PMat a(R,C); #endif init_array(a,R*C); INIT_SYSTICK START_CYCLE_MEASUREMENT; startSectionNB(1); #if defined(STATIC_TEST) PVector res = a.row(0,1) + a.row(1,1); #else PVector res = a.row(0,1) + a.row(1,1); #endif stopSectionNB(1); STOP_CYCLE_MEASUREMENT; INIT_SYSTICK; START_CYCLE_MEASUREMENT; PVector da (a.row(0,1)); PVector db (a.row(1,1)); PVector ref; cmsisdsp_add(da.const_ptr(),db.const_ptr(),ref.ptr(),NBOUT); STOP_CYCLE_MEASUREMENT; if (!validate(res.const_ptr(),ref.const_ptr(),NBOUT)) { printf("row add failed \r\n"); } std::cout << "=====\r\n"; } template static void swaptest() { constexpr int NBOUT = C-2; std::cout << "----\r\n"; std::cout << R << " x " << C << "\r\n"; std::cout << "NBOUT = " << NBOUT << "\r\n"; #if defined(STATIC_TEST) PMat a; PMat b; #else PMat a(R,C); PMat b(R,C); #endif init_array(a,R*C); init_array(b,R*C); INIT_SYSTICK; START_CYCLE_MEASUREMENT; startSectionNB(1); swap(a.row(0,2) , a.row(1,2)); stopSectionNB(1); STOP_CYCLE_MEASUREMENT; typename CMSISMatrixType::type mat; mat.numCols = C; mat.numRows = R; mat.pData = b.ptr(); INIT_SYSTICK; START_CYCLE_MEASUREMENT; SWAP_ROWS_F32(&mat,2,0,1); STOP_CYCLE_MEASUREMENT; if (!validate(a.const_ptr(),(const float32_t*)mat.pData,R*C)) { printf("row add failed \r\n"); } std::cout << "=====\r\n"; } template void all_row_test() { const int nb_tails = TailForTests::tail; const int nb_loops = TailForTests::loop; title("Row test"); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); if constexpr (std::is_same::value) { title("Swap test"); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); swaptest(); } //print_map("Stats",max_stats); } void row_test() { #if defined(ROW_TEST) #if defined(F64_DT) all_row_test(); #endif #if defined(F32_DT) all_row_test(); #endif #if defined(F16_DT) && !defined(DISABLEFLOAT16) all_row_test(); #endif #if defined(Q31_DT) all_row_test(); #endif #if defined(Q15_DT) all_row_test(); #endif #if defined(Q7_DT) all_row_test(); #endif #endif }