From 713c92140c0033265b91ea0089bf6af5a89dff4c Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 23 Jul 2009 14:20:45 +0200 Subject: improve SYMV it is now faster and ready for use --- test/product_selfadjoint.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'test/product_selfadjoint.cpp') diff --git a/test/product_selfadjoint.cpp b/test/product_selfadjoint.cpp index 44bafad93..2cacc8e5e 100644 --- a/test/product_selfadjoint.cpp +++ b/test/product_selfadjoint.cpp @@ -31,6 +31,8 @@ template void product_selfadjoint(const MatrixType& m) typedef Matrix VectorType; typedef Matrix RowVectorType; + typedef Matrix RhsMatrixType; + int rows = m.rows(); int cols = m.cols(); @@ -38,31 +40,36 @@ template void product_selfadjoint(const MatrixType& m) m2 = MatrixType::Random(rows, cols), m3; VectorType v1 = VectorType::Random(rows), - v2 = VectorType::Random(rows); - + v2 = VectorType::Random(rows), + v3(rows); RowVectorType r1 = RowVectorType::Random(rows), r2 = RowVectorType::Random(rows); + RhsMatrixType m4 = RhsMatrixType::Random(rows,10); Scalar s1 = ei_random(), s2 = ei_random(), s3 = ei_random(); - m1 = m1.adjoint()*m1; + m1 = (m1.adjoint() + m1).eval(); // lower - m2.setZero(); - m2.template triangularView() = m1; - ei_product_selfadjoint_vector - (cols,m2.data(),cols, v1.data(), v2.data()); - VERIFY_IS_APPROX(v2, m1 * v1); - VERIFY_IS_APPROX((m2.template selfadjointView() * v1).eval(), m1 * v1); + m2 = m1.template triangularView(); + VERIFY_IS_APPROX(v3 = (s1*m2).template selfadjointView() * (s2*v1), (s1*m1) * (s2*v1)); + VERIFY_IS_APPROX(v3 = (s1*m2.conjugate()).template selfadjointView() * (s2*v1), (s1*m1.conjugate()) * (s2*v1)); + VERIFY_IS_APPROX(v3 = (s1*m2).template selfadjointView() * (s2*m4.col(1)), (s1*m1) * (s2*m4.col(1))); + + VERIFY_IS_APPROX(v3 = (s1*m2).template selfadjointView() * (s2*v1.conjugate()), (s1*m1) * (s2*v1.conjugate())); + VERIFY_IS_APPROX(v3 = (s1*m2.conjugate()).template selfadjointView() * (s2*v1.conjugate()), (s1*m1.conjugate()) * (s2*v1.conjugate())); // upper - m2.setZero(); - m2.template triangularView() = m1; - ei_product_selfadjoint_vector(cols,m2.data(),cols, v1.data(), v2.data()); - VERIFY_IS_APPROX(v2, m1 * v1); - VERIFY_IS_APPROX((m2.template selfadjointView() * v1).eval(), m1 * v1); + m2 = m1.template triangularView(); + VERIFY_IS_APPROX(v3 = (s1*m2).template selfadjointView() * (s2*v1), (s1*m1) * (s2*v1)); + VERIFY_IS_APPROX(v3 = (s1*m2.conjugate()).template selfadjointView() * (s2*v1), (s1*m1.conjugate()) * (s2*v1)); + VERIFY_IS_APPROX(v3 = (s1*m2.adjoint()).template selfadjointView() * (s2*v1), (s1*m1.adjoint()) * (s2*v1)); + VERIFY_IS_APPROX(v3 = (s1*m2.transpose()).template selfadjointView() * (s2*v1), (s1*m1.transpose()) * (s2*v1)); + + VERIFY_IS_APPROX(v3 = (s1*m2).template selfadjointView() * (s2*v1.conjugate()), (s1*m1) * (s2*v1.conjugate())); + VERIFY_IS_APPROX(v3 = (s1*m2.conjugate()).template selfadjointView() * (s2*v1.conjugate()), (s1*m1.conjugate()) * (s2*v1.conjugate())); // rank2 update m2 = m1.template triangularView(); -- cgit v1.2.3