mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-16 22:59:39 +08:00
bug #1707: Fix deprecation warnings, or disable warnings when testing deprecated functions
This commit is contained in:
parent
d3ef7cf03e
commit
4ccd1ece92
@ -237,7 +237,7 @@ struct inplace_transpose_selector;
|
||||
template<typename MatrixType>
|
||||
struct inplace_transpose_selector<MatrixType,true,false> { // square matrix
|
||||
static void run(MatrixType& m) {
|
||||
m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose());
|
||||
m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose().template triangularView<StrictlyUpper>());
|
||||
}
|
||||
};
|
||||
|
||||
@ -262,7 +262,7 @@ template<typename MatrixType,bool MatchPacketSize>
|
||||
struct inplace_transpose_selector<MatrixType,false,MatchPacketSize> { // non square matrix
|
||||
static void run(MatrixType& m) {
|
||||
if (m.rows()==m.cols())
|
||||
m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose());
|
||||
m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose().template triangularView<StrictlyUpper>());
|
||||
else
|
||||
m = m.transpose().eval();
|
||||
}
|
||||
|
@ -1111,12 +1111,12 @@ EIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeRotationScalin
|
||||
Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant(); // so x has absolute value 1
|
||||
VectorType sv(svd.singularValues());
|
||||
sv.coeffRef(0) *= x;
|
||||
if(scaling) scaling->lazyAssign(svd.matrixV() * sv.asDiagonal() * svd.matrixV().adjoint());
|
||||
if(scaling) *scaling = svd.matrixV() * sv.asDiagonal() * svd.matrixV().adjoint();
|
||||
if(rotation)
|
||||
{
|
||||
LinearMatrixType m(svd.matrixU());
|
||||
m.col(0) /= x;
|
||||
rotation->lazyAssign(m * svd.matrixV().adjoint());
|
||||
*rotation = m * svd.matrixV().adjoint();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1140,12 +1140,12 @@ EIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeScalingRotatio
|
||||
Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant(); // so x has absolute value 1
|
||||
VectorType sv(svd.singularValues());
|
||||
sv.coeffRef(0) *= x;
|
||||
if(scaling) scaling->lazyAssign(svd.matrixU() * sv.asDiagonal() * svd.matrixU().adjoint());
|
||||
if(scaling) *scaling = svd.matrixU() * sv.asDiagonal() * svd.matrixU().adjoint();
|
||||
if(rotation)
|
||||
{
|
||||
LinearMatrixType m(svd.matrixU());
|
||||
m.col(0) /= x;
|
||||
rotation->lazyAssign(m * svd.matrixV().adjoint());
|
||||
*rotation = m * svd.matrixV().adjoint();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,35 @@
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifdef EIGEN_TEST_PART_100
|
||||
# define EIGEN_NO_DEPRECATED_WARNING
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
template<typename MatrixType> void triangular_deprecated(const MatrixType &m)
|
||||
{
|
||||
Index rows = m.rows();
|
||||
Index cols = m.cols();
|
||||
MatrixType m1, m2, m3, m4;
|
||||
m1.setRandom(rows,cols);
|
||||
m2.setRandom(rows,cols);
|
||||
m3 = m1; m4 = m2;
|
||||
// deprecated method:
|
||||
m1.template triangularView<Eigen::Upper>().swap(m2);
|
||||
// use this method instead:
|
||||
m3.template triangularView<Eigen::Upper>().swap(m4.template triangularView<Eigen::Upper>());
|
||||
VERIFY_IS_APPROX(m1,m3);
|
||||
VERIFY_IS_APPROX(m2,m4);
|
||||
// deprecated method:
|
||||
m1.template triangularView<Eigen::Lower>().swap(m4);
|
||||
// use this method instead:
|
||||
m3.template triangularView<Eigen::Lower>().swap(m2.template triangularView<Eigen::Lower>());
|
||||
VERIFY_IS_APPROX(m1,m3);
|
||||
VERIFY_IS_APPROX(m2,m4);
|
||||
}
|
||||
|
||||
|
||||
template<typename MatrixType> void triangular_square(const MatrixType& m)
|
||||
{
|
||||
@ -109,11 +135,12 @@ template<typename MatrixType> void triangular_square(const MatrixType& m)
|
||||
// test swap
|
||||
m1.setOnes();
|
||||
m2.setZero();
|
||||
m2.template triangularView<Upper>().swap(m1);
|
||||
m2.template triangularView<Upper>().swap(m1.template triangularView<Eigen::Upper>());
|
||||
m3.setZero();
|
||||
m3.template triangularView<Upper>().setOnes();
|
||||
VERIFY_IS_APPROX(m2,m3);
|
||||
|
||||
VERIFY_RAISES_STATIC_ASSERT(m1.template triangularView<Eigen::Lower>().swap(m2.template triangularView<Eigen::Upper>()));
|
||||
|
||||
m1.setRandom();
|
||||
m3 = m1.template triangularView<Upper>();
|
||||
Matrix<Scalar, MatrixType::ColsAtCompileTime, Dynamic> m5(cols, internal::random<int>(1,20)); m5.setRandom();
|
||||
@ -224,7 +251,7 @@ template<typename MatrixType> void triangular_rect(const MatrixType& m)
|
||||
// test swap
|
||||
m1.setOnes();
|
||||
m2.setZero();
|
||||
m2.template triangularView<Upper>().swap(m1);
|
||||
m2.template triangularView<Upper>().swap(m1.template triangularView<Eigen::Upper>());
|
||||
m3.setZero();
|
||||
m3.template triangularView<Upper>().setOnes();
|
||||
VERIFY_IS_APPROX(m2,m3);
|
||||
@ -256,6 +283,9 @@ EIGEN_DECLARE_TEST(triangular)
|
||||
CALL_SUBTEST_9( triangular_rect(MatrixXcf(r, c)) );
|
||||
CALL_SUBTEST_5( triangular_rect(MatrixXcd(r, c)) );
|
||||
CALL_SUBTEST_6( triangular_rect(Matrix<float,Dynamic,Dynamic,RowMajor>(r, c)) );
|
||||
|
||||
CALL_SUBTEST_100( triangular_deprecated(Matrix<float, 5, 7>()) );
|
||||
CALL_SUBTEST_100( triangular_deprecated(MatrixXd(r,c)) );
|
||||
}
|
||||
|
||||
CALL_SUBTEST_1( bug_159() );
|
||||
|
@ -214,9 +214,9 @@ template<typename Scalar> void eulerangles_manual()
|
||||
check_singular_cases(-PI);
|
||||
|
||||
// non-singular cases
|
||||
VectorX alpha = VectorX::LinSpaced(Eigen::Sequential, 20, Scalar(-0.99) * PI, PI);
|
||||
VectorX beta = VectorX::LinSpaced(Eigen::Sequential, 20, Scalar(-0.49) * PI, Scalar(0.49) * PI);
|
||||
VectorX gamma = VectorX::LinSpaced(Eigen::Sequential, 20, Scalar(-0.99) * PI, PI);
|
||||
VectorX alpha = VectorX::LinSpaced(20, Scalar(-0.99) * PI, PI);
|
||||
VectorX beta = VectorX::LinSpaced(20, Scalar(-0.49) * PI, Scalar(0.49) * PI);
|
||||
VectorX gamma = VectorX::LinSpaced(20, Scalar(-0.99) * PI, PI);
|
||||
for (int i = 0; i < alpha.size(); ++i) {
|
||||
for (int j = 0; j < beta.size(); ++j) {
|
||||
for (int k = 0; k < gamma.size(); ++k) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user