* remove Cross product expression: MatrixBase::cross() now returns a temporary

which is even better optimized by the compiler.
* Quaternion no longer inherits MatrixBase. Instead it stores the coefficients
  using a Matrix<> and provides only relevant methods.
This commit is contained in:
Gael Guennebaud
2008-06-07 13:18:29 +00:00
parent 6998037930
commit eb7b7b2cfc
5 changed files with 113 additions and 186 deletions

View File

@@ -558,7 +558,8 @@ template<typename Derived> class MatrixBase : public ArrayBase<Derived>
/////////// Geometry module ///////////
template<typename OtherDerived>
const Cross<Derived,OtherDerived> cross(const MatrixBase<OtherDerived>& other) const;
typename ei_eval<Derived>::type
cross(const MatrixBase<OtherDerived>& other) const;
};

View File

@@ -27,7 +27,7 @@
#define EIGEN_REDUX_H
template<typename BinaryOp, typename Derived, int Start, int Length>
struct ei_redux_unroller
struct ei_redux_impl
{
enum {
HalfLength = Length/2
@@ -38,13 +38,13 @@ struct ei_redux_unroller
static Scalar run(const Derived &mat, const BinaryOp& func)
{
return func(
ei_redux_unroller<BinaryOp, Derived, Start, HalfLength>::run(mat, func),
ei_redux_unroller<BinaryOp, Derived, Start+HalfLength, Length - HalfLength>::run(mat, func));
ei_redux_impl<BinaryOp, Derived, Start, HalfLength>::run(mat, func),
ei_redux_impl<BinaryOp, Derived, Start+HalfLength, Length - HalfLength>::run(mat, func));
}
};
template<typename BinaryOp, typename Derived, int Start>
struct ei_redux_unroller<BinaryOp, Derived, Start, 1>
struct ei_redux_impl<BinaryOp, Derived, Start, 1>
{
enum {
col = Start / Derived::RowsAtCompileTime,
@@ -60,7 +60,7 @@ struct ei_redux_unroller<BinaryOp, Derived, Start, 1>
};
template<typename BinaryOp, typename Derived, int Start>
struct ei_redux_unroller<BinaryOp, Derived, Start, Dynamic>
struct ei_redux_impl<BinaryOp, Derived, Start, Dynamic>
{
typedef typename ei_result_of<BinaryOp(typename Derived::Scalar)>::type Scalar;
static Scalar run(const Derived& mat, const BinaryOp& func)
@@ -91,7 +91,7 @@ MatrixBase<Derived>::redux(const BinaryOp& func) const
const bool unroll = SizeAtCompileTime * CoeffReadCost
+ (SizeAtCompileTime-1) * ei_functor_traits<BinaryOp>::Cost
<= EIGEN_UNROLLING_LIMIT;
return ei_redux_unroller<BinaryOp, Derived, 0,
return ei_redux_impl<BinaryOp, Derived, 0,
unroll ? int(SizeAtCompileTime) : Dynamic>
::run(derived(), func);
}

View File

@@ -26,7 +26,7 @@
#define EIGEN_VISITOR_H
template<typename Visitor, typename Derived, int UnrollCount>
struct ei_visitor_unroller
struct ei_visitor_impl
{
enum {
col = (UnrollCount-1) / Derived::RowsAtCompileTime,
@@ -35,13 +35,13 @@ struct ei_visitor_unroller
inline static void run(const Derived &mat, Visitor& visitor)
{
ei_visitor_unroller<Visitor, Derived, UnrollCount-1>::run(mat, visitor);
ei_visitor_impl<Visitor, Derived, UnrollCount-1>::run(mat, visitor);
visitor(mat.coeff(row, col), row, col);
}
};
template<typename Visitor, typename Derived>
struct ei_visitor_unroller<Visitor, Derived, 1>
struct ei_visitor_impl<Visitor, Derived, 1>
{
inline static void run(const Derived &mat, Visitor& visitor)
{
@@ -50,7 +50,7 @@ struct ei_visitor_unroller<Visitor, Derived, 1>
};
template<typename Visitor, typename Derived>
struct ei_visitor_unroller<Visitor, Derived, Dynamic>
struct ei_visitor_impl<Visitor, Derived, Dynamic>
{
inline static void run(const Derived& mat, Visitor& visitor)
{
@@ -85,7 +85,7 @@ void MatrixBase<Derived>::visit(Visitor& visitor) const
const bool unroll = SizeAtCompileTime * CoeffReadCost
+ (SizeAtCompileTime-1) * ei_functor_traits<Visitor>::Cost
<= EIGEN_UNROLLING_LIMIT;
return ei_visitor_unroller<Visitor, Derived,
return ei_visitor_impl<Visitor, Derived,
unroll ? int(SizeAtCompileTime) : Dynamic
>::run(derived(), visitor);
}