Lines Matching +full:- +full:r
95 constexpr static float abserr_cholesky = 3e-4;
96 constexpr static float relerr_cholesky = 1e-4;
112 constexpr static float abserr_cholesky = 3e-4;
113 constexpr static float relerr_cholesky = 1e-4;
120 constexpr static float abserr_inv = 4.0e-6;
121 constexpr static float relerr_inv = 5.0e-6;
130 constexpr static float abserr_cholesky = 2e-1;
131 constexpr static float relerr_cholesky = 2e-1;
133 constexpr static float abserr_householder = 2e-4;
134 constexpr static float relerr_householder = 2e-3;
138 constexpr static float relerr_qr = 1e-2;
140 constexpr static float abserr_inv = 3e-2;
141 constexpr static float relerr_inv = 3e-2;
147 uint32_t r,uint32_t c) in cmsisdsp_mat_inv() argument
153 src.numRows = r; in cmsisdsp_mat_inv()
157 dst.numRows = r; in cmsisdsp_mat_inv()
167 uint32_t r,uint32_t c) in cmsisdsp_mat_inv() argument
173 src.numRows = r; in cmsisdsp_mat_inv()
177 dst.numRows = r; in cmsisdsp_mat_inv()
188 uint32_t r,uint32_t c) in cmsisdsp_mat_inv() argument
194 src.numRows = r; in cmsisdsp_mat_inv()
198 dst.numRows = r; in cmsisdsp_mat_inv()
263 template<typename T,int R,int C, template<int> typename A>
264 void init_mat(Matrix<T,R,C,A> &pDst,std::size_t r,std::size_t c) in init_mat() argument
267 if ((r==4) && (r==c)) in init_mat()
272 if ((r==8) && (r==c)) in init_mat()
277 if ((r==16) && (r==c)) in init_mat()
283 for(std::size_t i=0;i<r*c;i++) in init_mat()
319 for(index_t r=0;r < nb_rows ; r++) in _matinv() local
321 res.row(r) = T{}; in _matinv()
322 res(r,r) = number_traits<T>::one(); in _matinv()
332 for(index_t r=c+1;r < nb_rows ; r++) in _matinv() local
334 T newPivot = b(r,c); in _matinv()
338 selectedRow = r; in _matinv()
357 index_t r=0; in _matinv() local
359 for(;r < c ; r++) in _matinv()
361 const T tmp = b(r,c); in _matinv()
362 b.row(r,c) -= b.row(c,c)*tmp; in _matinv()
363 res.row(r) -= res.row(c)*tmp; in _matinv()
366 for(r=c+1;r < nb_rows ; r++) in _matinv()
368 const T tmp = b(r,c); in _matinv()
369 b.row(r,c) -= b.row(c,c)*tmp; in _matinv()
370 res.row(r) -= res.row(c)*tmp; in _matinv()
410 template<typename T,int R,int C>
413 std::cout << "----\r\n"; in testinv()
414 std::cout << R << " x " << C << "\r\n"; in testinv()
417 PMat<T,R,C> a; in testinv()
419 PMat<T> a(R,C); in testinv()
422 init_mat(a,R,C); in testinv()
425 PMat<T> res(R,C); in testinv()
432 PMat<T,R,C> res = matinv(a); in testinv()
440 PMat<T> cmsis_res(R,C); in testinv()
444 cmsisdsp_mat_inv(amod.ptr(),cmsis_res.ptr(),R,C); in testinv()
449 if (!validate(res.const_ptr(),cmsis_res.const_ptr(),R*C, in testinv()
452 printf("inv failed \r\n"); in testinv()
456 std::cout << "=====\r\n"; in testinv()
460 template<typename T,int R,int C>
463 std::cout << "----\r\n"; in testadd()
464 std::cout << R << " x " << C << "\r\n"; in testadd()
467 PMat<T,R,C> a; in testadd()
468 PMat<T,R,C> b; in testadd()
470 PMat<T> a(R,C); in testadd()
471 PMat<T> b(R,C); in testadd()
474 init_array(a,R*C); in testadd()
475 init_array(b,R*C); in testadd()
482 PMat<T,R,C> res = a+b; in testadd()
492 //std::cout << "a: " << IsVector<decltype(a)>::value << "\r\n"; in testadd()
493 //std::cout << "b: " << IsVector<decltype(b)>::value << "\r\n"; in testadd()
494 //std::cout << "a+b: " << IsVector<decltype(a+b)>::value << "\r\n"; in testadd()
495 //std::cout << "res: " << IsVector<decltype(res)>::value << "\r\n"; in testadd()
496 //std::cout << "same: " << SameElementType<decltype(res),decltype(a+b)>::value << "\r\n"; in testadd()
498 //std::cout << "vec inst: " << has_vector_inst<decltype(res)>() << "\r\n"; in testadd()
499 //std::cout << "vec index pair: " << vector_idx_pair<decltype(res),decltype(a+b)>() << "\r\n"; in testadd()
500 …:cout << "must use mat idx: " << must_use_matrix_idx_pair<decltype(res),decltype(a+b)>() << "\r\n"; in testadd()
505 PMat<T,R,C> cmsis_res; in testadd()
507 PMat<T> cmsis_res(R,C); in testadd()
509 cmsisdsp_mat_add(a.const_ptr(),b.const_ptr(),cmsis_res.ptr(),R,C); in testadd()
514 if (!validate(res.const_ptr(),cmsis_res.const_ptr(),R*C, in testadd()
517 printf("add failed \r\n"); in testadd()
520 std::cout << "=====\r\n"; in testadd()
525 template<typename T,int R,int C>
528 std::cout << "----\r\n"; in testdiag()
529 std::cout << R << " x " << C << "\r\n"; in testdiag()
531 PVector<T,R> a; in testdiag()
533 PVector<T> a(R); in testdiag()
535 init_array(a,R); in testdiag()
541 PMat<T,R,C> res=PMat<T,R,C>::diagonal(a); in testdiag()
554 PMat<T,R,C> cmsis_res; in testdiag()
556 PMat<T> cmsis_res(R,C); in testdiag()
561 for(index_t row=0;row < R; row++) in testdiag()
580 if (!validate(res.const_ptr(),cmsis_res.const_ptr(),R*C, in testdiag()
583 printf("diag failed \r\n"); in testdiag()
586 std::cout << "=====\r\n"; in testdiag()
591 template<typename T,int R,int C>
594 std::cout << "----\r\n"; in testouter()
595 std::cout << R << " x " << C << "\r\n"; in testouter()
597 PVector<T,R> a; in testouter()
599 init_array(a,R); in testouter()
607 PMat<T,R,C> res = outer(a,b); in testouter()
617 PMat<T,R,C> cmsis_res; in testouter()
619 PMat<T> cmsis_res(R,C); in testouter()
621 CMSISOuter<T>::run(a.const_ptr(),b.const_ptr(),cmsis_res.ptr(),R,C); in testouter()
627 if (!validate(res.const_ptr(),cmsis_res.const_ptr(),R*C, in testouter()
630 printf("outer failed \r\n"); in testouter()
633 std::cout << "=====\r\n"; in testouter()
637 template<typename T,int R,int C>
640 std::cout << "----\r\n"; in testview()
641 std::cout << R << " x " << C << "\r\n"; in testview()
644 PVector<T,R> a; in testview()
646 PVector<T> a(R); in testview()
648 init_array(a,R); in testview()
651 PMat<T,R,C> res=PMat<T,R,C>::diagonal(a); in testview()
658 auto r = res.sub(Slice(subpos,subpos+subsize),Slice(subpos,subpos+subsize)); in testview() local
669 resb = r+r; in testview()
673 //std::cout << IsMatrix<decltype(r+r)>::value << "\r\n"; in testview()
685 cmsis_res(row,col) = r(row,col)+r(row,col); in testview()
697 printf("sub matrix failed \r\n"); in testview()
700 std::cout << "=====\r\n"; in testview()
706 template<typename T,int R,int C>
712 std::cout << "----\r\n"; in testmatvec()
713 std::cout << R << " x " << C << "\r\n"; in testmatvec()
723 PMat<T,R,C> m; in testmatvec()
725 PMat<T> m(R,C); in testmatvec()
727 init_array(m,R*C); in testmatvec()
734 PVector<T,R> res = dot(m,a); in testmatvec()
741 //std::cout << IsMatrix<decltype(r+r)>::value << "\r\n"; in testmatvec()
746 PVector<T,R> cmsis_res; in testmatvec()
748 PVector<T> cmsis_res(R); in testmatvec()
751 S.numRows = R; in testmatvec()
763 if (!validate(res.const_ptr(),cmsis_res.const_ptr(),R, in testmatvec()
766 printf("matrix times vector failed \r\n"); in testmatvec()
768 std::cout << "=====\r\n"; in testmatvec()
772 template<typename T,int R,int C>
778 std::cout << "----\r\n"; in testcomplexmatvec()
779 std::cout << R << " x " << C << "\r\n"; in testcomplexmatvec()
792 PMat<T,R,C> m; in testcomplexmatvec()
794 PMat<T> m(R,C); in testcomplexmatvec()
796 init_array(m,R*C); in testcomplexmatvec()
804 PVector<T,R> res = dot(m,tmpv); in testcomplexmatvec()
812 //std::cout << IsMatrix<decltype(r+r)>::value << "\r\n"; in testcomplexmatvec()
817 PVector<T,R> cmsis_res; in testcomplexmatvec()
820 PVector<T> cmsis_res(R); in testcomplexmatvec()
824 S.numRows = R; in testcomplexmatvec()
843 if (!validate(res.const_ptr(),cmsis_res.const_ptr(),R, in testcomplexmatvec()
846 printf("matrix times vector expression failed \r\n"); in testcomplexmatvec()
849 std::cout << "=====\r\n"; in testcomplexmatvec()
854 template<typename T,int R, int K,int C>
857 std::cout << "----\r\n"; in testmatmult()
858 std::cout << R << " x " << K << " x " << C << "\r\n"; in testmatmult()
863 PMat<T,R,K> ma; in testmatmult()
865 PMat<T> ma(R,K); in testmatmult()
867 init_array(ma,R*K); in testmatmult()
888 PMat<T,R,C> res = dot(ma,mb); in testmatmult()
902 //std::cout << IsMatrix<decltype(r+r)>::value << "\r\n"; in testmatmult()
909 PMat<T,R,C> cmsis_res; in testmatmult()
911 PMat<T> cmsis_res(R,C); in testmatmult()
916 SA.numRows = R; in testmatmult()
926 RES.numRows = R; in testmatmult()
942 printf("matrix times matrix expression failed \r\n"); in testmatmult()
945 std::cout << "=====\r\n"; in testmatmult()
949 template<typename T,int R,int K, int C>
952 std::cout << "----\r\n"; in testsubmatmult()
953 std::cout << R << " x " << K << " x " << C << "\r\n"; in testsubmatmult()
956 constexpr int TOTALA = 4 + 2*K + 2*R + K*R; in testsubmatmult()
960 PMat<T,R+2,K+2> ma; in testsubmatmult()
962 PMat<T> ma(R+2,K+2); in testsubmatmult()
984 PMat<T,R,C> res(T{}); in testsubmatmult()
986 PMat<T> res(R,C,T{}); in testsubmatmult()
989 …res.sub(Slice(0,R),Slice(0,C)) = copy(dot(ma.sub(Slice(0,R),Slice(0,K)),mb.sub(Slice(0,K),Slice(0,… in testsubmatmult()
1000 //std::cout << IsMatrix<decltype(r+r)>::value << "\r\n"; in testsubmatmult()
1002 PMat<T> cmsis_res(R,C); in testsubmatmult()
1003 PMat<T> cmsis_ma(R,K); in testsubmatmult()
1008 SA.numRows = R; in testsubmatmult()
1018 RES.numRows = R; in testsubmatmult()
1027 cmsis_ma = copy(ma.sub(Slice(0,R),Slice(0,K))); in testsubmatmult()
1036 if (!validate(res.sub(Slice(0,R),Slice(0,C)),cmsis_res, in testsubmatmult()
1039 printf("matrix times matrix expression failed \r\n"); in testsubmatmult()
1043 std::cout << "=====\r\n"; in testsubmatmult()
1047 template<typename T,int R,int C>
1050 std::cout << "----\r\n"; in testmattranspose()
1051 std::cout << R << " x " << C << "\r\n"; in testmattranspose()
1054 PMat<T,R,C> ma; in testmattranspose()
1056 PMat<T> ma(R,C); in testmattranspose()
1058 init_array(ma,R*C); in testmattranspose()
1066 PMat<T,C,R> res = ma.transpose(); in testmattranspose()
1073 //std::cout << IsMatrix<decltype(r+r)>::value << "\r\n"; in testmattranspose()
1078 PMat<T,C,R> cmsis_res; in testmattranspose()
1080 PMat<T> cmsis_res(C,R); in testmattranspose()
1084 SA.numRows = R; in testmattranspose()
1090 RES.numCols = R; in testmattranspose()
1104 printf("matrix transpose failed \r\n"); in testmattranspose()
1108 std::cout << "=====\r\n"; in testmattranspose()
1143 //std::cout << xnorm2 << "\r\n"; in _householder()
1157 beta = -_gen_sqrt(alpha*alpha+xnorm2); in _householder()
1159 T r = number_traits<T>::one() / (alpha - beta); in _householder() local
1160 res = v * r; in _householder()
1161 tau = (beta - alpha)/beta; in _householder()
1231 std::cout << "----\r\n" << "N = " << NB << "\r\n"; in testHouseholder()
1266 printf("householder vector failed \r\n"); in testHouseholder()
1273 printf("householder beta failed \r\n"); in testHouseholder()
1275 std::cout << "=====\r\n"; in testHouseholder()
1281 // R >= C
1282 template<typename T,int R,int C,template<int> typename A>
1283 auto QR(const Matrix<T,R,C,A>&m,const T eps,bool wantQ) in QR() argument
1287 Matrix<T,R,C,TMP_ALLOC> RM = m; in QR()
1288 Matrix<T,R,R,TMP_ALLOC> Q = Matrix<T,R,R>::identity(); in QR()
1292 Vector<T,R,TMP_ALLOC> tmpvec; in QR()
1293 Matrix<T,1,R,TMP_ALLOC> tmpmat; in QR()
1309 for(index_t c=0;c<NBC-1;c++) in QR()
1314 MatrixView<T> vt(tmpvec,1,NBR-c); in QR()
1315 dot(tmpmat.sub(0,1,0,NBC-c),vt,RM.sub(c,c)); in QR()
1318 RM.sub(c,c) - beta * outer(tmpvec.sub(0,NBR-c),tmpmat.row(0,0,NBC-c)); in QR()
1321 // Not valid when c == C-1 in QR()
1322 // We don't want to use a test since CMSIS-DSP is not using in QR()
1324 RM.col(c,c+1) = copy(tmpvec.sub(1,NBR-c)); in QR()
1329 auto beta = householder(RM.col(NBC-1,NBC-1),eps,tmpvec); in QR()
1330 tau[NBC-1] = beta; in QR()
1332 MatrixView<T> vt(tmpvec,1,NBR-(NBC-1)); in QR()
1333 dot(tmpmat.sub(0,1,0,NBC-(NBC-1)),vt,RM.sub(NBC-1,NBC-1)); in QR()
1335 RM.sub(NBC-1,NBC-1) = in QR()
1336 RM.sub(NBC-1,NBC-1) - beta * outer(tmpvec.sub(0,NBR-(NBC-1)),tmpmat.row(0,0,NBC-(NBC-1))); in QR()
1343 for(index_t c=NBC-1;c>=0;c--) in QR()
1348 MatrixView<T> vt(tmpvec,1,NBR-c); in QR()
1349 dot(tmpmat.sub(0,1,0,NBR-c),vt,Q.sub(c,c)); in QR()
1352 Q.sub(c,c) - tau[c] * outer(tmpvec.sub(0,NBR-c),tmpmat.row(0,0,NBR-c)); in QR()
1361 template<typename T,int R,int C>
1364 std::cout << "----\r\n"; in testQR()
1365 std::cout << R << " x " << C << "\r\n"; in testQR()
1367 PMat<T,R,C> a; in testQR()
1369 PMat<T> a(R,C); in testQR()
1372 cmsis_init_qr(a.ptr(),R,C); in testQR()
1382 //std::cout << "next\r\n"; in testQR()
1397 PMat<T,R,C> cmsis_res; in testQR()
1398 PMat<T,R,C> cmsis_outRp; in testQR()
1399 PMat<T,R,R> cmsis_outQp; in testQR()
1401 PVector<T,R> cmsis_tmpa; in testQR()
1404 PMat<T> cmsis_res(R,C); in testQR()
1405 PMat<T> cmsis_outRp(R,C); in testQR()
1406 PMat<T> cmsis_outQp(R,R); in testQR()
1408 PVector<T> cmsis_tmpa(R); in testQR()
1413 RP.numRows = R; in testQR()
1418 QP.numRows = R; in testQR()
1419 QP.numCols = R; in testQR()
1423 IN.numRows = R; in testQR()
1427 //std::cout << "-------\r\n"; in testQR()
1448 printf("QR Rp matrix failed \r\n"); in testQR()
1455 printf("QR Qp matrix failed \r\n"); in testQR()
1461 printf("QR tau failed \r\n"); in testQR()
1463 std::cout << "=====\r\n"; in testQR()
1469 template<typename T,int R,template<int> typename A>
1470 auto cholesky(const Matrix<T,R,R,A>&a) in cholesky() argument
1474 Matrix<T,R,R,TMP_ALLOC> g = a; in cholesky()
1475 Vector<T,R,TMP_ALLOC> tmp; in cholesky()
1489 … g.col(j,j) = (g.col(j,j) - tmp.sub(j)) * (T)(number_traits<T>::one() / _gen_sqrt(g(j,j)- tmp[j])); in cholesky()
1496 template<typename T,int R>
1499 std::cout << "----\r\n"; in testCholesky()
1500 std::cout << R << " x " << R << "\r\n"; in testCholesky()
1502 PMat<T,R,R> a; in testCholesky()
1504 PMat<T> a(R,R); in testCholesky()
1507 cmsis_init_cholesky(a.ptr(),R,R); in testCholesky()
1516 // temporary buffer like CMSIS-DSP in testCholesky()
1524 PMat<T,R,R> cmsis_res(T{}); in testCholesky()
1527 OUT.numRows = R; in testCholesky()
1528 OUT.numCols = R; in testCholesky()
1533 IN.numRows = R; in testCholesky()
1534 IN.numCols = R; in testCholesky()
1537 //std::cout << "-------\r\n"; in testCholesky()
1552 printf("cholesky failed \r\n"); in testCholesky()
1554 std::cout << "=====\r\n"; in testCholesky()