mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
add an Options template parameter to Hyperplane and ParametrizedLine
This commit is contained in:
@@ -35,6 +35,7 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
|
||||
*/
|
||||
typedef typename HyperplaneType::Index Index;
|
||||
const Index dim = _plane.dim();
|
||||
enum { Options = HyperplaneType::Options };
|
||||
typedef typename HyperplaneType::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
typedef Matrix<Scalar, HyperplaneType::AmbientDimAtCompileTime, 1> VectorType;
|
||||
@@ -85,9 +86,9 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
|
||||
// casting
|
||||
const int Dim = HyperplaneType::AmbientDimAtCompileTime;
|
||||
typedef typename GetDifferentType<Scalar>::type OtherScalar;
|
||||
Hyperplane<OtherScalar,Dim> hp1f = pl1.template cast<OtherScalar>();
|
||||
Hyperplane<OtherScalar,Dim,Options> hp1f = pl1.template cast<OtherScalar>();
|
||||
VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),pl1);
|
||||
Hyperplane<Scalar,Dim> hp1d = pl1.template cast<Scalar>();
|
||||
Hyperplane<Scalar,Dim,Options> hp1d = pl1.template cast<Scalar>();
|
||||
VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),pl1);
|
||||
}
|
||||
|
||||
@@ -128,11 +129,40 @@ template<typename Scalar> void lines()
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Scalar> void hyperplane_alignment()
|
||||
{
|
||||
typedef Hyperplane<Scalar,3,AutoAlign> Plane3a;
|
||||
typedef Hyperplane<Scalar,3,DontAlign> Plane3u;
|
||||
|
||||
EIGEN_ALIGN16 Scalar array1[4];
|
||||
EIGEN_ALIGN16 Scalar array2[4];
|
||||
EIGEN_ALIGN16 Scalar array3[4+1];
|
||||
Scalar* array3u = array3+1;
|
||||
|
||||
Plane3a *p1 = ::new(reinterpret_cast<void*>(array1)) Plane3a;
|
||||
Plane3u *p2 = ::new(reinterpret_cast<void*>(array2)) Plane3u;
|
||||
Plane3u *p3 = ::new(reinterpret_cast<void*>(array3u)) Plane3u;
|
||||
|
||||
p1->coeffs().setRandom();
|
||||
*p2 = *p1;
|
||||
*p3 = *p1;
|
||||
|
||||
VERIFY_IS_APPROX(p1->coeffs(), p2->coeffs());
|
||||
VERIFY_IS_APPROX(p1->coeffs(), p3->coeffs());
|
||||
|
||||
#ifdef EIGEN_VECTORIZE
|
||||
VERIFY_RAISES_ASSERT((::new(reinterpret_cast<void*>(array3u)) Plane3a));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void test_geo_hyperplane()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1( hyperplane(Hyperplane<float,2>()) );
|
||||
CALL_SUBTEST_2( hyperplane(Hyperplane<float,3>()) );
|
||||
CALL_SUBTEST_2( hyperplane(Hyperplane<float,3,DontAlign>()) );
|
||||
CALL_SUBTEST_2( hyperplane_alignment<float>() );
|
||||
CALL_SUBTEST_3( hyperplane(Hyperplane<double,4>()) );
|
||||
CALL_SUBTEST_4( hyperplane(Hyperplane<std::complex<double>,5>()) );
|
||||
CALL_SUBTEST_1( lines<float>() );
|
||||
|
||||
@@ -66,12 +66,42 @@ template<typename LineType> void parametrizedline(const LineType& _line)
|
||||
VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),l0);
|
||||
}
|
||||
|
||||
template<typename Scalar> void parametrizedline_alignment()
|
||||
{
|
||||
typedef ParametrizedLine<Scalar,4,AutoAlign> Line4a;
|
||||
typedef ParametrizedLine<Scalar,4,DontAlign> Line4u;
|
||||
|
||||
EIGEN_ALIGN16 Scalar array1[8];
|
||||
EIGEN_ALIGN16 Scalar array2[8];
|
||||
EIGEN_ALIGN16 Scalar array3[8+1];
|
||||
Scalar* array3u = array3+1;
|
||||
|
||||
Line4a *p1 = ::new(reinterpret_cast<void*>(array1)) Line4a;
|
||||
Line4u *p2 = ::new(reinterpret_cast<void*>(array2)) Line4u;
|
||||
Line4u *p3 = ::new(reinterpret_cast<void*>(array3u)) Line4u;
|
||||
|
||||
p1->origin().setRandom();
|
||||
p1->direction().setRandom();
|
||||
*p2 = *p1;
|
||||
*p3 = *p1;
|
||||
|
||||
VERIFY_IS_APPROX(p1->origin(), p2->origin());
|
||||
VERIFY_IS_APPROX(p1->origin(), p3->origin());
|
||||
VERIFY_IS_APPROX(p1->direction(), p2->direction());
|
||||
VERIFY_IS_APPROX(p1->direction(), p3->direction());
|
||||
|
||||
#ifdef EIGEN_VECTORIZE
|
||||
VERIFY_RAISES_ASSERT((::new(reinterpret_cast<void*>(array3u)) Line4a));
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_geo_parametrizedline()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1( parametrizedline(ParametrizedLine<float,2>()) );
|
||||
CALL_SUBTEST_2( parametrizedline(ParametrizedLine<float,3>()) );
|
||||
CALL_SUBTEST_3( parametrizedline(ParametrizedLine<double,4>()) );
|
||||
CALL_SUBTEST_3( parametrizedline_alignment<double>() );
|
||||
CALL_SUBTEST_4( parametrizedline(ParametrizedLine<std::complex<double>,5>()) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,17 +429,17 @@ template<typename Scalar, int Mode, int Options> void transformations()
|
||||
|
||||
template<typename Scalar> void transform_alignment()
|
||||
{
|
||||
typedef Transform<Scalar,3,Projective,AutoAlign> Projective4a;
|
||||
typedef Transform<Scalar,3,Projective,DontAlign> Projective4u;
|
||||
typedef Transform<Scalar,3,Projective,AutoAlign> Projective3a;
|
||||
typedef Transform<Scalar,3,Projective,DontAlign> Projective3u;
|
||||
|
||||
EIGEN_ALIGN16 Scalar array1[16];
|
||||
EIGEN_ALIGN16 Scalar array2[16];
|
||||
EIGEN_ALIGN16 Scalar array3[16+1];
|
||||
Scalar* array3u = array3+1;
|
||||
|
||||
Projective4a *p1 = ::new(reinterpret_cast<void*>(array1)) Projective4a;
|
||||
Projective4u *p2 = ::new(reinterpret_cast<void*>(array2)) Projective4u;
|
||||
Projective4u *p3 = ::new(reinterpret_cast<void*>(array3u)) Projective4u;
|
||||
Projective3a *p1 = ::new(reinterpret_cast<void*>(array1)) Projective3a;
|
||||
Projective3u *p2 = ::new(reinterpret_cast<void*>(array2)) Projective3u;
|
||||
Projective3u *p3 = ::new(reinterpret_cast<void*>(array3u)) Projective3u;
|
||||
|
||||
p1->matrix().setRandom();
|
||||
*p2 = *p1;
|
||||
|
||||
Reference in New Issue
Block a user