Re: [eigen] EigenLab: C++ run-time matrix math ala MATLAB.

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


Thanks for the comments Ilja. As you have shown, my goal with EigenLab was not brute efficiency at simple numeric expressions, but to provide a parser that can handle matrix operations and also provide an simple intuitive interface. If your equations do not require matrices, then something like muParser may be better for you. That said, if you are interested in increasing EigenLab's efficiency in this regard, that would be great. Regarding parsing an equation once and reusing it with new values, EigenLab currently does not do this. However, it would not be hard to store the parsed chunks and then rerun an evaluation on them with new variable values. For my uses, the matrix operations take way longer than parsing the equation, so I never bothered to do anything like this, but it's fairly easily implemented if needed. I'll add it to the list of things for the next version. This might also go a long way to closing the performance gap you've shown in your examples assuming EigenLab is parsing the equation 1e6 times whereas muParser is parsing it only once. I'll also see about putting a custom error message in for bad indices rather than using Eigen's error messages.

Cheers,
Marcel

On Wed, Sep 24, 2014 at 3:11 PM, Ilja Honkonen <ilja.j.honkonen@xxxxxxxx> wrote:
Hello
On 31/8/14, 10:18, Marcel Goldschen wrote:
Hi all,
I've created a header only library called
EigenLab (https://github.com/marcel-goldschen-ohm/EigenLab
<https://github.com/marcel-goldschen-ohm/EigenLab>) which provides
run-time parsing/evaluation of matrix math expressions in C++ with a
....
what you think. Also, if anyone knows how I could improve its
performance by using Eigen's _expression_ templates, I'd love to hear
about it.

I finally had time to try it out and it seems quite nice except it's very slow compared to muparserx. Parsing a simple _expression_ (i + 1) 1e6 times on my laptop takes about 0.07 s with muparserx and 4.7 s with EigenLab using these test programs:
https://github.com/nasailja/pamhd/blob/master/tests/eigenlab/performance1.cpp
https://github.com/nasailja/pamhd/blob/master/tests/muparserx/performance1.cpp

The muparserx test only has to parse the _expression_ once, would it be possible to do a similar optimization in eigenlab if the _expression_ doesn't change but only the value(s) of variable(s)?

Also it would be nice to have a better error message for using a wrong index [v1(1) instead of v1(0)] in an _expression_ than: Assertion failed: (a_startRow >= 0 && blockRows >= 0 && a_startRow <= xpr.rows() - blockRows && a_startCol >= 0 && blockCols >= 0 && a_startCol <= xpr.cols() - blockCols), function Block, file /Users/iljah/libraries/eigen/Eigen/src/Core/Block.h, line 146. This is far less important than performance though as currently I don't think I could use eigenlab in my program because even muparserx takes a few seconds.

Ilja





--
Marcel Goldschen-Ohm, PhD
Postdoctoral fellow, Chanda laboratory


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