[Cython] aritmetic with arrays in Cython

Stefan Behnel stefan_ml at behnel.de
Tue Aug 12 07:46:33 CEST 2014


Ian Henriksen schrieb am 12.08.2014 um 04:34:
> On Sun, Aug 10, 2014 at 12:41 PM, Sturla Molden wrote:
>> Ian Henriksen wrote:
>>> Maybe I should clarify a little about why eigen is a good place to start.
>>> According to <a
>>> href="http://eigen.tuxfamily.org/dox/TopicLazyEvaluation.html">
>> http://eigen.tuxfamily.org/dox/TopicLazyEvaluation.html</a>
>>> it
>>> already takes care of things like the elimination of temporary variables
>>> and common subexpression reduction at compile time. This should make it
>>> possible to compile array expressions in Cython without having to
>>> re-implement those sorts of optimizations. Ideally we would just have to
>>> map memory view operations to corresponding equivalents from eigen. It's
>>> not yet clear to me how to do things with arbitrary-dimensional arrays or
>>> broadcasting, but, given some more time, a solution may present itself.
>>> -Ian
>>
>> cilkplus is what you want, not Eigen.
>>
>> But if you are serious about number crunching, learn Fortran 95.
> 
> Cilk Plus would also work really nicely for this. Thanks for the suggestion.
> Fortran is a really great language for this sort of thing, but I don't
> think I'm ready to tackle the difficulties of using it as a backend for
> array arithmetic in Cython. It would be a really great feature to have
> later on though.

That clarifies a bit of the design then: The syntax support should be
somewhat generic, with specialised (sets of) node implementations as
backends that generate code for different libraries/compilers/languages.

It's ok to start only with Eigen, though. We have working example code for
it and everything else has either a much higher entry level for the
implementation or a much lower general availability of the required tools.

For the syntax/type support, a look at the array expressions branch might
also be helpful, although I doubt that there really is all that much to do
on that front.

Stefan



More information about the cython-devel mailing list