| 21 | #include <Eigen/SVD> |
| 22 | |
| 23 | template<typename MatrixType> void nomalloc(const MatrixType& m) |
| 24 | { |
| 25 | /* this test check no dynamic memory allocation are issued with fixed-size matrices |
| 26 | */ |
| 27 | typedef typename MatrixType::Scalar Scalar; |
| 28 | |
| 29 | Index rows = m.rows(); |
| 30 | Index cols = m.cols(); |
| 31 | |
| 32 | MatrixType m1 = MatrixType::Random(rows, cols), |
| 33 | m2 = MatrixType::Random(rows, cols), |
| 34 | m3(rows, cols); |
| 35 | |
| 36 | Scalar s1 = internal::random<Scalar>(); |
| 37 | |
| 38 | Index r = internal::random<Index>(0, rows-1), |
| 39 | c = internal::random<Index>(0, cols-1); |
| 40 | |
| 41 | VERIFY_IS_APPROX((m1+m2)*s1, s1*m1+s1*m2); |
| 42 | VERIFY_IS_APPROX((m1+m2)(r,c), (m1(r,c))+(m2(r,c))); |
| 43 | VERIFY_IS_APPROX(m1.cwiseProduct(m1.block(0,0,rows,cols)), (m1.array()*m1.array()).matrix()); |
| 44 | VERIFY_IS_APPROX((m1*m1.transpose())*m2, m1*(m1.transpose()*m2)); |
| 45 | |
| 46 | m2.col(0).noalias() = m1 * m1.col(0); |
| 47 | m2.col(0).noalias() -= m1.adjoint() * m1.col(0); |
| 48 | m2.col(0).noalias() -= m1 * m1.row(0).adjoint(); |
| 49 | m2.col(0).noalias() -= m1.adjoint() * m1.row(0).adjoint(); |
| 50 | |
| 51 | m2.row(0).noalias() = m1.row(0) * m1; |
| 52 | m2.row(0).noalias() -= m1.row(0) * m1.adjoint(); |
| 53 | m2.row(0).noalias() -= m1.col(0).adjoint() * m1; |
| 54 | m2.row(0).noalias() -= m1.col(0).adjoint() * m1.adjoint(); |
| 55 | VERIFY_IS_APPROX(m2,m2); |
| 56 | |
| 57 | m2.col(0).noalias() = m1.template triangularView<Upper>() * m1.col(0); |
| 58 | m2.col(0).noalias() -= m1.adjoint().template triangularView<Upper>() * m1.col(0); |
| 59 | m2.col(0).noalias() -= m1.template triangularView<Upper>() * m1.row(0).adjoint(); |
| 60 | m2.col(0).noalias() -= m1.adjoint().template triangularView<Upper>() * m1.row(0).adjoint(); |
| 61 | |
| 62 | m2.row(0).noalias() = m1.row(0) * m1.template triangularView<Upper>(); |
| 63 | m2.row(0).noalias() -= m1.row(0) * m1.adjoint().template triangularView<Upper>(); |
| 64 | m2.row(0).noalias() -= m1.col(0).adjoint() * m1.template triangularView<Upper>(); |
| 65 | m2.row(0).noalias() -= m1.col(0).adjoint() * m1.adjoint().template triangularView<Upper>(); |
| 66 | VERIFY_IS_APPROX(m2,m2); |
| 67 | |
| 68 | m2.col(0).noalias() = m1.template selfadjointView<Upper>() * m1.col(0); |
| 69 | m2.col(0).noalias() -= m1.adjoint().template selfadjointView<Upper>() * m1.col(0); |
| 70 | m2.col(0).noalias() -= m1.template selfadjointView<Upper>() * m1.row(0).adjoint(); |
| 71 | m2.col(0).noalias() -= m1.adjoint().template selfadjointView<Upper>() * m1.row(0).adjoint(); |
| 72 | |
| 73 | m2.row(0).noalias() = m1.row(0) * m1.template selfadjointView<Upper>(); |
| 74 | m2.row(0).noalias() -= m1.row(0) * m1.adjoint().template selfadjointView<Upper>(); |
| 75 | m2.row(0).noalias() -= m1.col(0).adjoint() * m1.template selfadjointView<Upper>(); |
| 76 | m2.row(0).noalias() -= m1.col(0).adjoint() * m1.adjoint().template selfadjointView<Upper>(); |
| 77 | VERIFY_IS_APPROX(m2,m2); |
| 78 | |
| 79 | m2.template selfadjointView<Lower>().rankUpdate(m1.col(0),-1); |
| 80 | m2.template selfadjointView<Upper>().rankUpdate(m1.row(0),-1); |
no test coverage detected