diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h index e04b4db4d..e1ccd58e7 100644 --- a/Eigen/src/Core/util/StaticAssert.h +++ b/Eigen/src/Core/util/StaticAssert.h @@ -64,6 +64,7 @@ YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR, UNALIGNED_LOAD_AND_STORE_OPERATIONS_UNIMPLEMENTED_ON_ALTIVEC, NUMERIC_TYPE_MUST_BE_FLOATING_POINT, + NUMERIC_TYPE_MUST_BE_REAL, COEFFICIENT_WRITE_ACCESS_TO_SELFADJOINT_NOT_SUPPORTED, WRITING_TO_TRIANGULAR_PART_WITH_UNIT_DIAGONAL_IS_NOT_SUPPORTED, THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE, diff --git a/Eigen/src/Geometry/Umeyama.h b/Eigen/src/Geometry/Umeyama.h index b55445797..6f3960f6e 100644 --- a/Eigen/src/Geometry/Umeyama.h +++ b/Eigen/src/Geometry/Umeyama.h @@ -110,7 +110,7 @@ umeyama(const MatrixBase& src, const MatrixBase& dst, boo typedef typename ei_traits::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - EIGEN_STATIC_ASSERT(!NumTraits::IsComplex, NUMERIC_TYPE_MUST_BE_FLOATING_POINT) + EIGEN_STATIC_ASSERT(!NumTraits::IsComplex, NUMERIC_TYPE_MUST_BE_REAL) EIGEN_STATIC_ASSERT((ei_is_same_type::Scalar>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) @@ -141,7 +141,7 @@ umeyama(const MatrixBase& src, const MatrixBase& dst, boo // Eq. (36)-(37) const Scalar src_var = src_demean.rowwise().squaredNorm().sum() * one_over_n; - const Scalar dst_var = dst_demean.rowwise().squaredNorm().sum() * one_over_n; + // const Scalar dst_var = dst_demean.rowwise().squaredNorm().sum() * one_over_n; // Eq. (38) const MatrixType sigma = (dst_demean*src_demean.transpose()).lazy() * one_over_n; @@ -182,22 +182,4 @@ umeyama(const MatrixBase& src, const MatrixBase& dst, boo return Rt; } -#ifndef EIGEN_PARSED_BY_DOXYGEN - -/** -* This is simply here to prevent the creation of dozens compile time errors for -* std::complex types... -*/ -template - typename ei_umeyama_transform_matrix_type,_Rows,_Cols,_Options,_MaxRows,_MaxCols>, - Matrix,_OtherRows,_OtherCols,_OtherOptions,_OtherMaxRows,_OtherMaxCols> >::type -umeyama(const MatrixBase,_Rows,_Cols,_Options,_MaxRows,_MaxCols> >& src, - const MatrixBase,_OtherRows,_OtherCols,_OtherOptions,_OtherMaxRows,_OtherMaxCols> >& dst, bool with_scaling = true) -{ - EIGEN_STATIC_ASSERT(false, NUMERIC_TYPE_MUST_BE_FLOATING_POINT) -} - -#endif - #endif // EIGEN_UMEYAMA_H diff --git a/test/umeyama.cpp b/test/umeyama.cpp index 94198ae44..b6d394883 100644 --- a/test/umeyama.cpp +++ b/test/umeyama.cpp @@ -33,17 +33,11 @@ using namespace Eigen; -#define VAR_CALL_SUBTEST(...) do { \ - g_test_stack.push_back(EI_PP_MAKE_STRING(__VA_ARGS__)); \ - __VA_ARGS__; \ - g_test_stack.pop_back(); \ -} while (0) - // Constructs a random matrix from the unitary group U(size). template Eigen::Matrix randMatrixUnitary(int size) { - typedef typename T Scalar; + typedef T Scalar; typedef typename NumTraits::Real RealScalar; typedef Eigen::Matrix MatrixType; @@ -55,58 +49,58 @@ Eigen::Matrix randMatrixUnitary(int size) while (!is_unitary && max_tries > 0) { - // initialize random matrix + // initialize random matrix Q = MatrixType::Random(size, size); - // orthogonalize columns using the Gram-Schmidt algorithm - for (int col = 0; col < size; ++col) - { - MatrixType::ColXpr colVec = Q.col(col); - for (int prevCol = 0; prevCol < col; ++prevCol) - { - MatrixType::ColXpr prevColVec = Q.col(prevCol); + // orthogonalize columns using the Gram-Schmidt algorithm + for (int col = 0; col < size; ++col) + { + typename MatrixType::ColXpr colVec = Q.col(col); + for (int prevCol = 0; prevCol < col; ++prevCol) + { + typename MatrixType::ColXpr prevColVec = Q.col(prevCol); colVec -= colVec.dot(prevColVec)*prevColVec; - } - Q.col(col) = colVec.normalized(); - } + } + Q.col(col) = colVec.normalized(); + } - // this additional orthogonalization is not necessary in theory but should enhance + // this additional orthogonalization is not necessary in theory but should enhance // the numerical orthogonality of the matrix - for (int row = 0; row < size; ++row) - { - MatrixType::RowXpr rowVec = Q.row(row); - for (int prevRow = 0; prevRow < row; ++prevRow) - { - MatrixType::RowXpr prevRowVec = Q.row(prevRow); - rowVec -= rowVec.dot(prevRowVec)*prevRowVec; - } - Q.row(row) = rowVec.normalized(); - } + for (int row = 0; row < size; ++row) + { + typename MatrixType::RowXpr rowVec = Q.row(row); + for (int prevRow = 0; prevRow < row; ++prevRow) + { + typename MatrixType::RowXpr prevRowVec = Q.row(prevRow); + rowVec -= rowVec.dot(prevRowVec)*prevRowVec; + } + Q.row(row) = rowVec.normalized(); + } - // final check + // final check is_unitary = Q.isUnitary(); --max_tries; } if (max_tries == 0) - throw std::runtime_error("randMatrixUnitary: Could not construct unitary matrix!"); + ei_assert(false && "randMatrixUnitary: Could not construct unitary matrix!"); - return Q; + return Q; } // Constructs a random matrix from the special unitary group SU(size). template Eigen::Matrix randMatrixSpecialUnitary(int size) { - typedef typename T Scalar; + typedef T Scalar; typedef typename NumTraits::Real RealScalar; typedef Eigen::Matrix MatrixType; - // initialize unitary matrix - MatrixType Q = randMatrixUnitary(size); + // initialize unitary matrix + MatrixType Q = randMatrixUnitary(size); - // tweak the first column to make the determinant be 1 + // tweak the first column to make the determinant be 1 Q.col(0) *= ei_conj(Q.determinant()); return Q; @@ -191,13 +185,13 @@ void test_umeyama() CALL_SUBTEST(run_test(dim, num_elements)); } - VAR_CALL_SUBTEST(run_fixed_size_test(num_elements)); - VAR_CALL_SUBTEST(run_fixed_size_test(num_elements)); - VAR_CALL_SUBTEST(run_fixed_size_test(num_elements)); + CALL_SUBTEST((run_fixed_size_test(num_elements))); + CALL_SUBTEST((run_fixed_size_test(num_elements))); + CALL_SUBTEST((run_fixed_size_test(num_elements))); - VAR_CALL_SUBTEST(run_fixed_size_test(num_elements)); - VAR_CALL_SUBTEST(run_fixed_size_test(num_elements)); - VAR_CALL_SUBTEST(run_fixed_size_test(num_elements)); + CALL_SUBTEST((run_fixed_size_test(num_elements))); + CALL_SUBTEST((run_fixed_size_test(num_elements))); + CALL_SUBTEST((run_fixed_size_test(num_elements))); } // Those two calls don't compile and result in meaningful error messages!