aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/nomalloc.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2011-02-01 11:38:46 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2011-02-01 11:38:46 +0100
commitc60818fca8ed58a272fab9f3f62024e04eac1a1c (patch)
tree55cf1d692557b7fbd682b33378cb0cae4444bb8a /test/nomalloc.cpp
parent0fdd01fe247ce40add4a6e45e817246fdf99ba5d (diff)
fix trmv regarding strided vectors and static allocation of temporaries
Diffstat (limited to 'test/nomalloc.cpp')
-rw-r--r--test/nomalloc.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/test/nomalloc.cpp b/test/nomalloc.cpp
index 94c1b0533..7ef71bfcd 100644
--- a/test/nomalloc.cpp
+++ b/test/nomalloc.cpp
@@ -71,7 +71,7 @@ template<typename MatrixType> void nomalloc(const MatrixType& m)
VERIFY_IS_APPROX((m1+m2)(r,c), (m1(r,c))+(m2(r,c)));
VERIFY_IS_APPROX(m1.cwiseProduct(m1.block(0,0,rows,cols)), (m1.array()*m1.array()).matrix());
VERIFY_IS_APPROX((m1*m1.transpose())*m2, m1*(m1.transpose()*m2));
-
+
m2.col(0).noalias() = m1 * m1.col(0);
m2.col(0).noalias() -= m1.adjoint() * m1.col(0);
m2.col(0).noalias() -= m1 * m1.row(0).adjoint();
@@ -81,6 +81,36 @@ template<typename MatrixType> void nomalloc(const MatrixType& m)
m2.row(0).noalias() -= m1.row(0) * m1.adjoint();
m2.row(0).noalias() -= m1.col(0).adjoint() * m1;
m2.row(0).noalias() -= m1.col(0).adjoint() * m1.adjoint();
+ VERIFY_IS_APPROX(m2,m2);
+
+ m2.col(0).noalias() = m1.template triangularView<Upper>() * m1.col(0);
+ m2.col(0).noalias() -= m1.adjoint().template triangularView<Upper>() * m1.col(0);
+ m2.col(0).noalias() -= m1.template triangularView<Upper>() * m1.row(0).adjoint();
+ m2.col(0).noalias() -= m1.adjoint().template triangularView<Upper>() * m1.row(0).adjoint();
+
+ m2.row(0).noalias() = m1.row(0) * m1.template triangularView<Upper>();
+ m2.row(0).noalias() -= m1.row(0) * m1.adjoint().template triangularView<Upper>();
+ m2.row(0).noalias() -= m1.col(0).adjoint() * m1.template triangularView<Upper>();
+ m2.row(0).noalias() -= m1.col(0).adjoint() * m1.adjoint().template triangularView<Upper>();
+ VERIFY_IS_APPROX(m2,m2);
+
+ m2.col(0).noalias() = m1.template selfadjointView<Upper>() * m1.col(0);
+ m2.col(0).noalias() -= m1.adjoint().template selfadjointView<Upper>() * m1.col(0);
+ m2.col(0).noalias() -= m1.template selfadjointView<Upper>() * m1.row(0).adjoint();
+ m2.col(0).noalias() -= m1.adjoint().template selfadjointView<Upper>() * m1.row(0).adjoint();
+
+ m2.row(0).noalias() = m1.row(0) * m1.template selfadjointView<Upper>();
+ m2.row(0).noalias() -= m1.row(0) * m1.adjoint().template selfadjointView<Upper>();
+ m2.row(0).noalias() -= m1.col(0).adjoint() * m1.template selfadjointView<Upper>();
+ m2.row(0).noalias() -= m1.col(0).adjoint() * m1.adjoint().template selfadjointView<Upper>();
+ VERIFY_IS_APPROX(m2,m2);
+
+ // The following fancy matrix-matrix products are not safe yet regarding static allocation
+// m1 += m1.template triangularView<Upper>() * m2.col(;
+// m1.template selfadjointView<Lower>().rankUpdate(m2);
+// m1 += m1.template triangularView<Upper>() * m2;
+// m1 += m1.template selfadjointView<Lower>() * m2;
+// VERIFY_IS_APPROX(m1,m1);
}
template<typename Scalar>