compilation fix + test orho methods for complex

This commit is contained in:
Gael Guennebaud 2009-02-26 10:09:23 +00:00
parent 91af389a9a
commit 170128770a
2 changed files with 5 additions and 4 deletions

View File

@ -101,7 +101,7 @@ struct ei_unitOrthogonal_selector
src.cwise().abs().maxCoeff(&maxi); src.cwise().abs().maxCoeff(&maxi);
if (maxi==0) if (maxi==0)
sndi = 1; sndi = 1;
RealScalar invnm = RealScalar(1)/Vector2(src.coeff(sndi),src.coeff(maxi)).norm(); RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm();
perp.coeffRef(maxi) = -ei_conj(src.coeff(sndi)) * invnm; perp.coeffRef(maxi) = -ei_conj(src.coeff(sndi)) * invnm;
perp.coeffRef(sndi) = ei_conj(src.coeff(maxi)) * invnm; perp.coeffRef(sndi) = ei_conj(src.coeff(maxi)) * invnm;

View File

@ -63,6 +63,7 @@ template<typename Scalar> void orthomethods_3()
template<typename Scalar, int Size> void orthomethods(int size=Size) template<typename Scalar, int Size> void orthomethods(int size=Size)
{ {
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar,Size,1> VectorType; typedef Matrix<Scalar,Size,1> VectorType;
typedef Matrix<Scalar,3,Size> Matrix3N; typedef Matrix<Scalar,3,Size> Matrix3N;
typedef Matrix<Scalar,Size,3> MatrixN3; typedef Matrix<Scalar,Size,3> MatrixN3;
@ -74,7 +75,7 @@ template<typename Scalar, int Size> void orthomethods(int size=Size)
// unitOrthogonal // unitOrthogonal
VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().dot(v0), Scalar(1)); VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().dot(v0), Scalar(1));
VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), Scalar(1)); VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), RealScalar(1));
if (size>3) if (size>3)
{ {
@ -82,7 +83,7 @@ template<typename Scalar, int Size> void orthomethods(int size=Size)
v0.end(size-3).setRandom(); v0.end(size-3).setRandom();
VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().dot(v0), Scalar(1)); VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().dot(v0), Scalar(1));
VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), Scalar(1)); VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), RealScalar(1));
} }
// colwise/rowwise cross product // colwise/rowwise cross product
@ -110,7 +111,7 @@ void test_geo_orthomethods()
CALL_SUBTEST( (orthomethods<float,3>()) ); CALL_SUBTEST( (orthomethods<float,3>()) );
CALL_SUBTEST( (orthomethods<double,3>()) ); CALL_SUBTEST( (orthomethods<double,3>()) );
CALL_SUBTEST( (orthomethods<float,7>()) ); CALL_SUBTEST( (orthomethods<float,7>()) );
CALL_SUBTEST( (orthomethods<double,8>()) ); CALL_SUBTEST( (orthomethods<std::complex<double>,8>()) );
CALL_SUBTEST( (orthomethods<float,Dynamic>(36)) ); CALL_SUBTEST( (orthomethods<float,Dynamic>(36)) );
CALL_SUBTEST( (orthomethods<double,Dynamic>(35)) ); CALL_SUBTEST( (orthomethods<double,Dynamic>(35)) );
} }