diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index adca9fe2e..c8d92f3c0 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -218,8 +218,8 @@ LDLT& LDLT::compute(const MatrixType& a) int endSize = size - j - 1; if (endSize > 0) { - _temporary.end(endSize) = ( m_matrix.block(j+1,0, endSize, j) - * m_matrix.col(j).start(j).conjugate() ).lazy(); + _temporary.end(endSize).noalias() = m_matrix.block(j+1,0, endSize, j) + * m_matrix.col(j).start(j).conjugate(); m_matrix.row(j).end(endSize) = m_matrix.row(j).end(endSize).conjugate() - _temporary.end(endSize).transpose(); diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h index 3ce85b2d9..ec7b8123c 100644 --- a/Eigen/src/Cholesky/LLT.h +++ b/Eigen/src/Cholesky/LLT.h @@ -141,7 +141,7 @@ template<> struct ei_llt_inplace if (x<=RealScalar(0)) return false; mat.coeffRef(k,k) = x = ei_sqrt(x); - if (k>0 && rs>0) A21 -= (A20 * A10.adjoint()).lazy(); + if (k>0 && rs>0) A21.noalias() -= A20 * A10.adjoint(); if (rs>0) A21 *= RealScalar(1)/x; } return true; diff --git a/Eigen/src/QR/EigenSolver.h b/Eigen/src/QR/EigenSolver.h index bd7a76c49..79d73db7e 100644 --- a/Eigen/src/QR/EigenSolver.h +++ b/Eigen/src/QR/EigenSolver.h @@ -244,11 +244,11 @@ void EigenSolver::orthes(MatrixType& matH, RealVectorType& ort) // Apply Householder similarity transformation // H = (I-u*u'/h)*H*(I-u*u')/h) int bSize = high-m+1; - matH.block(m, m, bSize, n-m) -= ((ort.segment(m, bSize)/h) - * (ort.segment(m, bSize).transpose() * matH.block(m, m, bSize, n-m))).lazy(); + matH.block(m, m, bSize, n-m).noalias() -= ((ort.segment(m, bSize)/h) + * (ort.segment(m, bSize).transpose() * matH.block(m, m, bSize, n-m))); - matH.block(0, m, high+1, bSize) -= ((matH.block(0, m, high+1, bSize) * ort.segment(m, bSize)) - * (ort.segment(m, bSize)/h).transpose()).lazy(); + matH.block(0, m, high+1, bSize).noalias() -= ((matH.block(0, m, high+1, bSize) * ort.segment(m, bSize)) + * (ort.segment(m, bSize)/h).transpose()); ort.coeffRef(m) = scale*ort.coeff(m); matH.coeffRef(m,m-1) = scale*g; @@ -265,8 +265,8 @@ void EigenSolver::orthes(MatrixType& matH, RealVectorType& ort) ort.segment(m+1, high-m) = matH.col(m-1).segment(m+1, high-m); int bSize = high-m+1; - m_eivec.block(m, m, bSize, bSize) += ( (ort.segment(m, bSize) / (matH.coeff(m,m-1) * ort.coeff(m))) - * (ort.segment(m, bSize).transpose() * m_eivec.block(m, m, bSize, bSize)) ).lazy(); + m_eivec.block(m, m, bSize, bSize).noalias() += ( (ort.segment(m, bSize) / (matH.coeff(m,m-1) * ort.coeff(m))) + * (ort.segment(m, bSize).transpose() * m_eivec.block(m, m, bSize, bSize)) ); } } } diff --git a/test/bandmatrix.cpp b/test/bandmatrix.cpp index f677e7b85..2bdc67e28 100644 --- a/test/bandmatrix.cpp +++ b/test/bandmatrix.cpp @@ -44,21 +44,21 @@ template void bandmatrix(const MatrixType& _m) dm1.diagonal().setConstant(123); for (int i=1; i<=m.supers();++i) { - m.diagonal(i).setConstant(i); - dm1.diagonal(i).setConstant(i); + m.diagonal(i).setConstant(static_cast(i)); + dm1.diagonal(i).setConstant(static_cast(i)); } for (int i=1; i<=m.subs();++i) { - m.diagonal(-i).setConstant(-i); - dm1.diagonal(-i).setConstant(-i); + m.diagonal(-i).setConstant(-static_cast(i)); + dm1.diagonal(-i).setConstant(-static_cast(i)); } //std::cerr << m.m_data << "\n\n" << m.toDense() << "\n\n" << dm1 << "\n\n\n\n"; VERIFY_IS_APPROX(dm1,m.toDense()); for (int i=0; i(i+1)); + dm1.col(i).setConstant(static_cast(i+1)); } int d = std::min(rows,cols); int a = std::max(0,cols-d-supers); diff --git a/test/product.h b/test/product.h index 157f6262b..40773ad90 100644 --- a/test/product.h +++ b/test/product.h @@ -81,7 +81,7 @@ template void product(const MatrixType& m) m3 = m1; m3 *= m1.transpose() * m2; VERIFY_IS_APPROX(m3, m1 * (m1.transpose()*m2)); - VERIFY_IS_APPROX(m3, m1.lazy() * (m1.transpose()*m2)); + VERIFY_IS_APPROX(m3, m1 * (m1.transpose()*m2)); // continue testing Product.h: distributivity VERIFY_IS_APPROX(square*(m1 + m2), square*m1+square*m2); @@ -109,26 +109,26 @@ template void product(const MatrixType& m) // test optimized operator+= path res = square; - res += (m1 * m2.transpose()).lazy(); + res.noalias() += m1 * m2.transpose(); VERIFY_IS_APPROX(res, square + m1 * m2.transpose()); if (NumTraits::HasFloatingPoint && std::min(rows,cols)>1) { VERIFY(areNotApprox(res,square + m2 * m1.transpose())); } vcres = vc2; - vcres += (m1.transpose() * v1).lazy(); + vcres.noalias() += m1.transpose() * v1; VERIFY_IS_APPROX(vcres, vc2 + m1.transpose() * v1); // test optimized operator-= path res = square; - res -= (m1 * m2.transpose()).lazy(); + res.noalias() -= m1 * m2.transpose(); VERIFY_IS_APPROX(res, square - (m1 * m2.transpose())); if (NumTraits::HasFloatingPoint && std::min(rows,cols)>1) { VERIFY(areNotApprox(res,square - m2 * m1.transpose())); } vcres = vc2; - vcres -= (m1.transpose() * v1).lazy(); + vcres.noalias() -= m1.transpose() * v1; VERIFY_IS_APPROX(vcres, vc2 - m1.transpose() * v1); tm1 = m1; @@ -145,7 +145,7 @@ template void product(const MatrixType& m) VERIFY_IS_APPROX(res, m1 * m2.transpose()); res2 = square2; - res2 += (m1.transpose() * m2).lazy(); + res2.noalias() += m1.transpose() * m2; VERIFY_IS_APPROX(res2, square2 + m1.transpose() * m2); if (NumTraits::HasFloatingPoint && std::min(rows,cols)>1) { diff --git a/test/product_symm.cpp b/test/product_symm.cpp index 1300928a2..cf0299c64 100644 --- a/test/product_symm.cpp +++ b/test/product_symm.cpp @@ -96,7 +96,7 @@ template void symm(int size = Size, in m2 = m1.template triangularView(); rhs13 = rhs12; - VERIFY_IS_APPROX(rhs12 += (s1 * ((m2.adjoint()).template selfadjointView() * (s2*rhs3).conjugate())).lazy(), + VERIFY_IS_APPROX(rhs12.noalias() += s1 * ((m2.adjoint()).template selfadjointView() * (s2*rhs3).conjugate()), rhs13 += (s1*m1.adjoint()) * (s2*rhs3).conjugate()); // test matrix * selfadjoint diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h index dd25d7f3d..7d8777de7 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h @@ -90,9 +90,9 @@ namespace MatrixExponentialInternal { { typedef typename ei_traits::Scalar Scalar; const Scalar b[] = {120., 60., 12., 1.}; - M2 = (M * M).lazy(); + M2.noalias() = M * M; tmp = b[3]*M2 + b[1]*Id; - U = (M * tmp).lazy(); + U.noalias() = M * tmp; V = b[2]*M2 + b[0]*Id; } @@ -115,10 +115,10 @@ namespace MatrixExponentialInternal { { typedef typename ei_traits::Scalar Scalar; const Scalar b[] = {30240., 15120., 3360., 420., 30., 1.}; - M2 = (M * M).lazy(); - MatrixType M4 = (M2 * M2).lazy(); + M2.noalias() = M * M; + MatrixType M4 = M2 * M2; tmp = b[5]*M4 + b[3]*M2 + b[1]*Id; - U = (M * tmp).lazy(); + U.noalias() = M * tmp; V = b[4]*M4 + b[2]*M2 + b[0]*Id; } @@ -141,11 +141,11 @@ namespace MatrixExponentialInternal { { typedef typename ei_traits::Scalar Scalar; const Scalar b[] = {17297280., 8648640., 1995840., 277200., 25200., 1512., 56., 1.}; - M2 = (M * M).lazy(); - MatrixType M4 = (M2 * M2).lazy(); - MatrixType M6 = (M4 * M2).lazy(); + M2.noalias() = M * M; + MatrixType M4 = M2 * M2; + MatrixType M6 = M4 * M2; tmp = b[7]*M6 + b[5]*M4 + b[3]*M2 + b[1]*Id; - U = (M * tmp).lazy(); + U.noalias() = M * tmp; V = b[6]*M6 + b[4]*M4 + b[2]*M2 + b[0]*Id; } @@ -169,12 +169,12 @@ namespace MatrixExponentialInternal { typedef typename ei_traits::Scalar Scalar; const Scalar b[] = {17643225600., 8821612800., 2075673600., 302702400., 30270240., 2162160., 110880., 3960., 90., 1.}; - M2 = (M * M).lazy(); - MatrixType M4 = (M2 * M2).lazy(); - MatrixType M6 = (M4 * M2).lazy(); - MatrixType M8 = (M6 * M2).lazy(); + M2.noalias() = M * M; + MatrixType M4 = M2 * M2; + MatrixType M6 = M4 * M2; + MatrixType M8 = M6 * M2; tmp = b[9]*M8 + b[7]*M6 + b[5]*M4 + b[3]*M2 + b[1]*Id; - U = (M * tmp).lazy(); + U.noalias() = M * tmp; V = b[8]*M8 + b[6]*M6 + b[4]*M4 + b[2]*M2 + b[0]*Id; } @@ -199,15 +199,15 @@ namespace MatrixExponentialInternal { const Scalar b[] = {64764752532480000., 32382376266240000., 7771770303897600., 1187353796428800., 129060195264000., 10559470521600., 670442572800., 33522128640., 1323241920., 40840800., 960960., 16380., 182., 1.}; - M2 = (M * M).lazy(); - MatrixType M4 = (M2 * M2).lazy(); - MatrixType M6 = (M4 * M2).lazy(); + M2.noalias() = M * M; + MatrixType M4 = M2 * M2; + MatrixType M6 = M4 * M2; V = b[13]*M6 + b[11]*M4 + b[9]*M2; - tmp = (M6 * V).lazy(); + tmp.noalias() = M6 * V; tmp += b[7]*M6 + b[5]*M4 + b[3]*M2 + b[1]*Id; - U = (M * tmp).lazy(); + U.noalias() = M * tmp; tmp = b[12]*M6 + b[10]*M4 + b[8]*M2; - V = (M6 * tmp).lazy(); + V.noalias() = M6 * tmp; V += b[6]*M6 + b[4]*M4 + b[2]*M2 + b[0]*Id; } @@ -252,7 +252,7 @@ namespace MatrixExponentialInternal { } else if (l1norm < 1.880152677804762e+000) { pade5(M, Id, tmp1, tmp2, U, V); } else { - const float maxnorm = 3.925724783138660; + const float maxnorm = 3.925724783138660f; *squarings = std::max(0, (int)ceil(log2(l1norm / maxnorm))); MatrixType A = M / std::pow(typename ei_traits::Scalar(2), *squarings); pade7(A, Id, tmp1, tmp2, U, V); @@ -294,7 +294,7 @@ namespace MatrixExponentialInternal { { MatrixType num, den, U, V; MatrixType Id = MatrixType::Identity(M.rows(), M.cols()); - float l1norm = M.cwise().abs().colwise().sum().maxCoeff(); + float l1norm = static_cast(M.cwise().abs().colwise().sum().maxCoeff()); int squarings; computeUV_selector::run(M, Id, num, den, U, V, l1norm, &squarings); num = U + V; // numerator of Pade approximant diff --git a/unsupported/test/matrixExponential.cpp b/unsupported/test/matrixExponential.cpp index 9a6c335d8..7d65a701a 100644 --- a/unsupported/test/matrixExponential.cpp +++ b/unsupported/test/matrixExponential.cpp @@ -43,10 +43,10 @@ void test2dRotation(double tol) A << 0, 1, -1, 0; for (int i=0; i<=20; i++) { - angle = pow(10, i / 5. - 2); + angle = static_cast(pow(10, i / 5. - 2)); B << cos(angle), sin(angle), -sin(angle), cos(angle); ei_matrix_exponential(angle*A, &C); - VERIFY(C.isApprox(B, tol)); + VERIFY(C.isApprox(B, static_cast(tol))); } } @@ -59,13 +59,13 @@ void test2dHyperbolicRotation(double tol) for (int i=0; i<=20; i++) { - angle = (i-10) / 2.0; + angle = static_cast((i-10) / 2.0); ch = std::cosh(angle); sh = std::sinh(angle); A << 0, angle*imagUnit, -angle*imagUnit, 0; B << ch, sh*imagUnit, -sh*imagUnit, ch; ei_matrix_exponential(A, &C); - VERIFY(C.isApprox(B, tol)); + VERIFY(C.isApprox(B, static_cast(tol))); } } @@ -77,13 +77,13 @@ void testPascal(double tol) Matrix A(size,size), B(size,size), C(size,size); A.setZero(); for (int i=0; i(i+1); B.setZero(); for (int i=0; i(binom(i,j)); ei_matrix_exponential(A, &C); - VERIFY(C.isApprox(B, tol)); + VERIFY(C.isApprox(B, static_cast(tol))); } } @@ -98,11 +98,13 @@ void randomTest(const MatrixType& m, double tol) MatrixType m1(rows, cols), m2(rows, cols), m3(rows, cols), identity = MatrixType::Identity(rows, rows); + typedef typename NumTraits::Scalar>::Real RealScalar; + for(int i = 0; i < g_repeat; i++) { m1 = MatrixType::Random(rows, cols); ei_matrix_exponential(m1, &m2); ei_matrix_exponential(-m1, &m3); - VERIFY(identity.isApprox(m2 * m3, tol)); + VERIFY(identity.isApprox(m2 * m3, static_cast(tol))); } }