dkogan/numpysane

einsum notation

Opened this issue · 1 comments

Hi @dkogan,

Thanks for this very interesting project, I came across it from HN and your talk.

  1. I was looking at the syntax for broadcast_define, which is given by
    @nps.broadcast_define( (('n',), ('n',)) ) or @nps.broadcast_define( (('n',), ('n',), ())) in the examples.

I am not sure whether you are familiar with numpy's einsum function. I quite like the intuitive style of writing indices.

I am wondering whether it could be reused here. In that case, one could write something like:
@nps.broadcast_define('n,n->')
@nps.broadcast_define('n,mn->m')

However, I am not sure how complex the parser of einsum is and whether it can be easily reused here.

  1. Maybe one could also consider a concat/stacking API that is based on einsum notation:
    cat(arr13,arr3) -> einstack(arr13,arr3,'ij,j->kij')
    glue(arr13,arr3) -> einstack(arr13,arr3,'ij,ij->ij')

  2. I am a bit scared of the automatic adding of leading dimensions, because it may hide passing the wrong array. Is there a way to turn it off?

dkogan commented