13 #include <Eigen/Geometry> 18 using namespace Eigen;
30 bool is_unitary =
false;
32 while (!is_unitary && max_tries > 0)
35 Q = MatrixType::Random(size, size);
41 for (
int prevCol = 0; prevCol <
col; ++prevCol)
44 colVec -= colVec.dot(prevColVec)*prevColVec;
46 Q.col(col) = colVec.normalized();
54 for (
int prevRow = 0; prevRow <
row; ++prevRow)
57 rowVec -= rowVec.dot(prevRowVec)*prevRowVec;
59 Q.row(row) = rowVec.normalized();
63 is_unitary = Q.isUnitary();
68 eigen_assert(
false &&
"randMatrixUnitary: Could not construct unitary matrix!");
82 MatrixType
Q = randMatrixUnitary<Scalar>(
size);
90 template <
typename MatrixType>
100 const Scalar
c =
abs(internal::random<Scalar>());
102 MatrixX
R = randMatrixSpecialUnitary<Scalar>(dim);
103 VectorX
t =
Scalar(50)*VectorX::Random(dim,1);
105 MatrixX cR_t = MatrixX::Identity(dim+1,dim+1);
106 cR_t.block(0,0,dim,dim) = c*
R;
107 cR_t.block(0,dim,dim,1) =
t;
109 MatrixX src = MatrixX::Random(dim+1, num_elements);
112 MatrixX dst = cR_t*src;
114 MatrixX cR_t_umeyama =
umeyama(src.block(0,0,dim,num_elements), dst.block(0,0,dim,num_elements));
116 const Scalar
error = ( cR_t_umeyama*src - dst ).norm() / dst.norm();
120 template<
typename Scalar,
int Dimension>
129 const int dim = Dimension;
134 const Scalar c = internal::random<Scalar>(0.5, 2.0);
136 FixedMatrix
R = randMatrixSpecialUnitary<Scalar>(dim);
137 FixedVector
t =
Scalar(32)*FixedVector::Random(dim,1);
139 HomMatrix cR_t = HomMatrix::Identity(dim+1,dim+1);
140 cR_t.block(0,0,dim,dim) = c*
R;
141 cR_t.block(0,dim,dim,1) =
t;
143 MatrixX src = MatrixX::Random(dim+1, num_elements);
146 MatrixX dst = cR_t*src;
151 HomMatrix cR_t_umeyama =
umeyama(src_block, dst_block);
153 const Scalar error = ( cR_t_umeyama*src - dst ).squaredNorm();
162 const int num_elements = internal::random<int>(40,500);
165 for (
int dim=2; dim<8; ++dim)
Block< Derived, 1, internal::traits< Derived >::ColsAtCompileTime, IsRowMajor > RowXpr
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
#define CALL_SUBTEST_3(FUNC)
Matrix< Scalar, Dynamic, 1 > VectorX
#define CALL_SUBTEST_7(FUNC)
void run_test(int dim, int num_elements)
Rot2 R(Rot2::fromAngle(0.1))
Namespace containing all symbols from the Eigen library.
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, 1, !IsRowMajor > ColXpr
void run_fixed_size_test(int num_elements)
AnnoyingScalar conj(const AnnoyingScalar &x)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > randMatrixSpecialUnitary(int size)
#define CALL_SUBTEST_1(FUNC)
#define CALL_SUBTEST_8(FUNC)
internal::umeyama_transform_matrix_type< Derived, OtherDerived >::type umeyama(const MatrixBase< Derived > &src, const MatrixBase< OtherDerived > &dst, bool with_scaling=true)
Returns the transformation between two point sets.
#define CALL_SUBTEST_5(FUNC)
Expression of a fixed-size or dynamic-size block.
The quaternion class used to represent 3D orientations and rotations.
EIGEN_DECLARE_TEST(umeyama)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > randMatrixUnitary(int size)
#define CALL_SUBTEST_2(FUNC)
The matrix class, also used for vectors and row-vectors.