pchanial / pyoperators

Operators and solvers for high-performance computing.
http://pchanial.github.com/pyoperators
Other
14 stars 9 forks source link

ENH: Implement context manager for '*' sign #5

Closed pchanial closed 10 years ago

pchanial commented 12 years ago

Currently, the '*' sign stands for operator composition, and it can be confusing when multiplying non-linear operators. Since it is possible to do composition in an alternate way by writing H1(H2), let's have a mode controlled by a context manager, which does something something like :

with times_means_multiplication():
    H = H1(H2*H3)

which would represent the function: h1(h2(x)*h3(x))

pchanial commented 10 years ago

The * sign has been made context dependent : it the two operators are linear, it means composition (matrix multiplication). If any of the operands is non-linear, it means element-wise multiplication.