[eigen] alpha 3.1

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


New since alpha3:

* finally sort out the Eval mess.

---> Eval remains a subclass of Matrix with limited functionality (it's 
read-only, it doesn't have all the assigment operators and constructors).
---> But... Eval now has a public typedef MatrixType which gives the actual 
matrix type it evaluates to!

So if you have an expression type, say Xpr, and want to know what actual 
matrix type should be used to evaluate Xpr, it's:

Eval<Xpr>::MatrixType

Of course you may need to add "typename" if Xpr is a template parameter.

For instance the row-vector-type of a matrix type can be retrieved as follows:

Eval<Row<SomeMatrixType> >::MatrixType

Of course this is nothing but the classical workaround for the absence of 
template typedefs in C++ (they will appear in C++09).

The great thing is that this gives actual typedefs to Matrix<...> instead of 
manipulating the separate Eval class.

* add swap() and findBiggestCoeff()

* Ramon's bugfix (thanks!)

* new demo : echeloning a matrix (training for the GaussianElimination 
module...)

See it in doc/echelon.cpp.

Let me paste the interesting part here:

template<typename Scalar, typename Derived>
void echelon(MatrixBase<Scalar, Derived>& m)
{
  const int N = std::min(m.rows(), m.cols());
  for(int k = 0; k < N; k++)
  {
    int rowOfBiggest, colOfBiggest;
    int cornerRows = m.rows()-k;
    int cornerCols = m.cols()-k;
    m.corner(BottomRight, cornerRows, cornerCols)
     .findBiggestCoeff(&rowOfBiggest, &colOfBiggest);
    m.row(k).swap(m.row(k+rowOfBiggest));
    m.col(k).swap(m.col(k+colOfBiggest));
    for(int r = k+1; r < m.rows(); r++)
      m.row(r).end(cornerCols) -= m.row(k).end(cornerCols) * m(r,k) / m(k,k);
  }
}

Yes, that's it. Eleven lines of code. More importantly, this looks very much 
like the pseudo-code for the algorithm you could find in book.

I hope this shows where I would like us to go with Eigen: provide such a nice 
API that implementing algoritms is almost just copying the pseudocode.

Now I'm probably going to disappear for the next weeks. You can still reach me 
by mail and I'd be happy to help especially if you're coding Eigen modules, 
but I shouldn't be coding myself in the near future.

Cheers,

Benoit

Attachment: signature.asc
Description: This is a digitally signed message part.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/