void prodh(vsip::const_Matrix<T, Block1> a, vsip::const_Matrix<T, Block2> b, vsip::Matrix <T, Block3> c) { using vsip::index_type; assert(a.size(1) == c.size(0)); assert(b.size(1) == c.size(1)); assert(a.size(0) == b.size(0)); for (index_type i=0; i<c.size(0); ++i) for (index_type j=0; j<c.size(1); ++j) { T tmp = T(); for (index_type k=0; k<a.size(0); ++k) tmp += Test_traits<T>::conj(a.get(k, i)) * b.get(k, j); c(i, j) = tmp; } }
float prod_check( vsip::const_Matrix<T, Block1> a, vsip::const_Matrix<T, Block2> b, vsip::Matrix<T, Block3> c) { using vsip::index_type; typedef typename ovxx::scalar_of<T>::type scalar_type; assert(a.size(0) == c.size(0)); assert(b.size(1) == c.size(1)); assert(a.size(1) == b.size(0)); float err = 0.f; for (index_type i=0; i<c.size(0); ++i) for (index_type j=0; j<c.size(1); ++j) { T tmp = T(); scalar_type guage = scalar_type(); for (index_type k=0; k<a.size(1); ++k) { tmp += a.get(i, k) * b.get(k, j); guage += vsip::mag(a.get(i, k)) * vsip::mag(b.get(k, j)); } float err_ij = vsip::mag(tmp - c(i, j)) / test::precision<scalar_type>::eps; if (guage > scalar_type()) err_ij = err_ij/guage; err = std::max(err, err_ij); } return err; }
void apply_proj( vsip::const_Matrix<CoeffT, Block1> P, T u, T v, T& x, T& y) { T w = u * P.get(2, 0) + v * P.get(2, 1) + P.get(2,2); x = (u * P.get(0, 0) + v * P.get(0, 1) + P.get(0,2)) / w; y = (u * P.get(1, 0) + v * P.get(1, 1) + P.get(1,2)) / w; }
void apply_proj_w( vsip::const_Matrix<CoeffT, Block1> P, T u, T v, T& x, T& y, T& w) { x = u * P.get(0, 0) + v * P.get(0, 1) + P.get(0,2); y = u * P.get(1, 0) + v * P.get(1, 1) + P.get(1,2); w = u * P.get(2, 0) + v * P.get(2, 1) + P.get(2,2); }