Re: [eigen] update |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
First of all: I forgot to mention, but thought it was obvious, that this is all committed, so you can check it out at /branches/work/eigen2 as usual. With only 714 lines of code it _can't_ be that difficult to get acquainted with! On Wednesday 26 September 2007 21:11:54 Schleimer, Ben wrote: > Wow, nice. Thats a pretty huge drop. Nice job. I guess we'll have plenty of > design wiggle room for implementing specific optimizations... Yes, and first and foremost, we must now unroll loops. I'll look into this soon, probably using template metaprograms. By the way, if anyone feels he can help with that, that's welcome! > > template<typename T, typename U> f(EigenBase<T,U>& m); > Very nice. Can you give a quick example of f? Ok, I made an example, see attached file. > Wow, how did you achieve this black magic? Seems extremely cool though. Each type has static const int members RowsAtCompileTime and ColsAtCompileTime, initialized in the body of the class. Here's as an example the MatrixProduct class: static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, ColsAtCompileTime = Rhs::ColsAtCompileTime; Ultimately, this is set in the Matrix class to be the template parameters _Rows and _Cols of Matrix. In case of dynamic-size, this equals the DynamicSize enum constant, which is -1. Well, I can only encourage you to check out the source code :) > Well if eval is applicable to all eigen expressions, then I don't see why > it shouldn't be in the Eigen2 namespace and be done with it. It seems > reasonable for it to be general, especially if it used for different > expressions. OK. Cheers, Benoit
#include<All> using namespace std; using namespace Eigen; template<typename Scalar, typename Derived> void foo(const EigenBase<Scalar, Derived>& m) { cout << "Here's m:" << endl << m << endl; } template<typename Scalar, typename Derived> ScalarProduct<Derived> twice(const EigenBase<Scalar, Derived>& m) { // note that the static_cast here will soon be unnecessary // but currently it is required. return static_cast<Scalar>(2) * m; } int main(int argc, char**argv) { Matrix2d m; m(0,0)= 1; m(1,0)= 2; m(0,1)= 3; m(1,1)= 4; foo(m); foo(twice(m)); return 0; }
Attachment:
signature.asc
Description: This is a digitally signed message part.
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |