On 9/12/12 5:09 PM, Benjamin Jones wrote:
On Wed, Sep 12, 2012 at 2:04 PM, Jason Grout
<jason-s...@creativetrax.com> wrote:
Fair enough. That's convincing to me. I wish there was a nice notation in
Sage for v.inner_product(w) that wasn't so cumbersome and wordy, then!
Thanks,
Jason
I have wished for the same thing on occasion. One idea would be to
introduce some new abstract binary operators, say <*> and <+> and have
the preparser magic v <*> w into v.__abstract_mul__(w). In Haskell,
arbitrary infix operators can be defined using special characters
(e.g. <++>, +-+, and </> are allowable) and many people find it quite
handy.
Dummy me forgot that we've had this conversation years ago, and I and
others wrote something fairly simple for defining custom infix operators
and it's in Sage [1]. See
http://www.sagemath.org/doc/reference/sage/misc/decorators.html#sage.misc.decorators.infix_operator
It doesn't require preparsing, but does have some oddities because we
are sort of abusing syntax. But it should work fine for casual use.
@infix_operator('multiply')
def H(a,b):
return a.conjugate()*b
v=vector(CDF,[2+I,5])
v *H* v
Thanks,
Jason
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To post to this group, send email to sage-devel@googlegroups.com.
To unsubscribe from this group, send email to
sage-devel+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.