- some small cleanup and improved readability.

- virtual overload warnings should not be issued anymore
release/4.3a0
HannesSommer 2014-11-21 21:13:24 +01:00
parent f699dd26bb
commit 6d0c1a44e1
1 changed files with 32 additions and 23 deletions

View File

@ -67,9 +67,8 @@ struct ConvertToDynamicRowsIf<false> {
* with Rows in 1..MaxSupportedStaticRows * with Rows in 1..MaxSupportedStaticRows
*/ */
template<int MaxSupportedStaticRows, int Cols> template<int MaxSupportedStaticRows, int Cols>
struct ReverseADInterface: public ReverseADInterface<MaxSupportedStaticRows - 1, struct ReverseADInterface: ReverseADInterface<MaxSupportedStaticRows - 1,
Cols> { Cols> {
protected:
using ReverseADInterface<MaxSupportedStaticRows - 1, Cols>::_reverseAD; using ReverseADInterface<MaxSupportedStaticRows - 1, Cols>::_reverseAD;
virtual void _reverseAD( virtual void _reverseAD(
const Eigen::Matrix<double, MaxSupportedStaticRows, Cols> & dFdT, const Eigen::Matrix<double, MaxSupportedStaticRows, Cols> & dFdT,
@ -78,10 +77,15 @@ protected:
template<int Cols> template<int Cols>
struct ReverseADInterface<0, Cols> { struct ReverseADInterface<0, Cols> {
protected: virtual void _reverseAD(
void _reverseAD() { const Eigen::Matrix<double, Eigen::Dynamic, Cols> & dFdT,
} //dummy to allow the using directive in the template without failing for MaxSupportedStaticRows == 1. JacobianMap& jacobians) const = 0;
virtual void _reverseAD(const Matrix & dFdT,
JacobianMap& jacobians) const = 0;
}; };
template<typename Derived, int MaxSupportedStaticRows, int Cols>
struct ReverseADImplementor; // forward for CallRecord's friend declaration
} }
/** /**
@ -115,15 +119,12 @@ struct CallRecord: private internal::ReverseADInterface<MaxVirtualStaticRows,
} }
private: private:
using internal::ReverseADInterface<MaxVirtualStaticRows, Cols>::_reverseAD;
virtual void _print(const std::string& indent) const = 0; virtual void _print(const std::string& indent) const = 0;
virtual void _startReverseAD(JacobianMap& jacobians) const = 0; virtual void _startReverseAD(JacobianMap& jacobians) const = 0;
virtual void _reverseAD( using internal::ReverseADInterface<MaxVirtualStaticRows,
const Eigen::Matrix<double, Eigen::Dynamic, Cols> & dFdT, Cols>::_reverseAD;
JacobianMap& jacobians) const = 0; template<typename Derived, int MaxSupportedStaticRows, int OtherCols>
virtual void _reverseAD(const Matrix & dFdT, friend struct internal::ReverseADImplementor;
JacobianMap& jacobians) const = 0;
}; };
namespace internal { namespace internal {
@ -136,17 +137,33 @@ template<typename Derived, int MaxSupportedStaticRows, int Cols>
struct ReverseADImplementor: ReverseADImplementor<Derived, struct ReverseADImplementor: ReverseADImplementor<Derived,
MaxSupportedStaticRows - 1, Cols> { MaxSupportedStaticRows - 1, Cols> {
protected: private:
using ReverseADImplementor<Derived,
MaxSupportedStaticRows - 1, Cols>::_reverseAD;
virtual void _reverseAD( virtual void _reverseAD(
const Eigen::Matrix<double, MaxSupportedStaticRows, Cols> & dFdT, const Eigen::Matrix<double, MaxSupportedStaticRows, Cols> & dFdT,
JacobianMap& jacobians) const { JacobianMap& jacobians) const {
static_cast<const Derived *>(this)->reverseAD(dFdT, jacobians); static_cast<const Derived *>(this)->reverseAD(dFdT, jacobians);
} }
friend struct internal::ReverseADImplementor<Derived, MaxSupportedStaticRows + 1, Cols>;
}; };
template<typename Derived, int Cols> template<typename Derived, int Cols>
struct ReverseADImplementor<Derived, 0, Cols> : CallRecord<Cols> { struct ReverseADImplementor<Derived, 0, Cols> : CallRecord<Cols> {
private:
using CallRecord<Cols>::_reverseAD;
const Derived & derived() const {
return static_cast<const Derived&>(*this);
}
virtual void _reverseAD(
const Eigen::Matrix<double, Eigen::Dynamic, Cols> & dFdT,
JacobianMap& jacobians) const {
derived().reverseAD(dFdT, jacobians);
}
virtual void _reverseAD(const Matrix & dFdT, JacobianMap& jacobians) const {
derived().reverseAD(dFdT, jacobians);
}
friend struct internal::ReverseADImplementor<Derived, 1, Cols>;
}; };
/** /**
@ -154,7 +171,7 @@ struct ReverseADImplementor<Derived, 0, Cols> : CallRecord<Cols> {
* delegating to its corresponding (templated) non-virtual methods. * delegating to its corresponding (templated) non-virtual methods.
*/ */
template<typename Derived, int Cols> template<typename Derived, int Cols>
struct CallRecordImplementor: public ReverseADImplementor<Derived, struct CallRecordImplementor: ReverseADImplementor<Derived,
MaxVirtualStaticRows, Cols> { MaxVirtualStaticRows, Cols> {
private: private:
const Derived & derived() const { const Derived & derived() const {
@ -166,14 +183,6 @@ private:
virtual void _startReverseAD(JacobianMap& jacobians) const { virtual void _startReverseAD(JacobianMap& jacobians) const {
derived().startReverseAD(jacobians); derived().startReverseAD(jacobians);
} }
virtual void _reverseAD(
const Eigen::Matrix<double, Eigen::Dynamic, Cols> & dFdT,
JacobianMap& jacobians) const {
derived().reverseAD(dFdT, jacobians);
}
virtual void _reverseAD(const Matrix & dFdT, JacobianMap& jacobians) const {
derived().reverseAD(dFdT, jacobians);
}
}; };
} // internal } // internal