Bugzilla – Attachment 28 Details for
Bug 99
Expression evaluator
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
Test case for NestByValue
nest_by_value.cpp (text/x-c++src), 2.96 KB, created by
Bart Janssens
on 2010-11-02 00:56:22 UTC
(
hide
)
Description:
Test case for NestByValue
Filename:
MIME Type:
Creator:
Bart Janssens
Created:
2010-11-02 00:56:22 UTC
Size:
2.96 KB
patch
obsolete
>#include <iostream> >#include <Eigen/Dense> > >namespace Eigen { > >template<typename Lhs, typename Rhs, int Mode> class NestByValue<GeneralProduct<Lhs,Rhs,Mode> > > : public ProductBase<NestByValue<GeneralProduct<Lhs,Rhs,Mode> >, > typename GeneralProduct<Lhs,Rhs,Mode>::_LhsNested, > typename GeneralProduct<Lhs,Rhs,Mode>::_RhsNested> >{ >public: > > typedef GeneralProduct<Lhs,Rhs,Mode> NestedProduct; > > typedef ProductBase<NestByValue, > typename NestedProduct::_LhsNested, > typename NestedProduct::_RhsNested> Base; > typedef typename Base::Scalar Scalar; > typedef typename Base::PlainObject PlainObject; > > NestByValue(const NestedProduct& prod) > : Base(prod.lhs(),prod.rhs()), m_prod(prod) { } > > template<typename Dest> > inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst,Scalar(1)); } > > template<typename Dest> > inline void addTo(Dest& dst) const { scaleAndAddTo(dst,Scalar(1)); } > > template<typename Dest> > inline void subTo(Dest& dst) const { scaleAndAddTo(dst,-Scalar(1)); } > > template<typename Dest> > inline void scaleAndAddTo(Dest& dst,Scalar alpha) const { m_prod.derived().scaleAndAddTo(dst,Scalar(1)); } > > operator const NestedProduct&() const { return m_prod; } > > protected: > const NestedProduct m_prod; >}; > > >template<typename T> >struct ei_nested< NestByValue<T> > >{ > typedef NestByValue<T> const type; >}; > >} // namespace Eigen > >using namespace Eigen; > >template<typename T> struct product {}; >template<typename T> struct lhs {}; >template<typename T> struct rhs {}; > >/// Produce compiler errors that show the types of T itself, as well as T::LhsNested and T::RhsNested >template<typename T> >void print_types(const T& expr) >{ > product<T>().print(); > lhs<typename T::LhsNested>().print(); > rhs<typename T::RhsNested>().print(); >} > >int main(void) >{ > static const int dimension = 1; > static const int dimensionality = 1; > static const int nb_nodes = 2; > > typedef Matrix<double, 1, nb_nodes> nodes_row_t; > typedef Matrix<double, dimensionality, nb_nodes> gradient_t; > typedef Matrix<double, nb_nodes, dimensionality> gradient_trans_t; > typedef Matrix<double, dimensionality, dimension> jacobian_t; > typedef Matrix<double, dimension, dimensionality> jacobian_trans_t; > typedef Matrix<double, nb_nodes, 1> nodes_col_t; > > nodes_row_t V = nodes_row_t::Constant(2.); > gradient_trans_t A = gradient_trans_t::Constant(2.); > jacobian_trans_t B = jacobian_trans_t::Constant(2.); > jacobian_t C = jacobian_t::Constant(2.); > gradient_t D = gradient_t::Constant(2.); > nodes_col_t Vt = nodes_col_t::Constant(2.); > > std::cout << V*A*B*C*D*Vt << std::endl; > > std::cout << ( ( ( ( (V*A).nestByValue() * B ).nestByValue() * C ).nestByValue() * D ).nestByValue() * Vt ).nestByValue() << std::endl; > > // comment the next line to allow the build to complete > print_types( ( ( ( (V*A).nestByValue() * B ).nestByValue() * C ).nestByValue() * D ).nestByValue() ); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 99
: 28 |
30
|
143
|
156
|
165
|
295
|
400