OT: excellent book on information theory
Terry Hancock
hancock at anansispaceworks.com
Thu Jan 19 13:18:43 EST 2006
On 19 Jan 2006 13:57:06 +0100
Anton Vredegoor <anton.vredegoor at gmail.com> wrote:
> Some time ago I tried to 'sell' Python to a mathematician.
> The crucial point was that it was not (in standard Python)
> possible to have a matrix A and a matrix B and then do for
> example:
>
> A = A * B
>
> and have a matrix multiplication performed.
Um, why not? I'm trying to think what would be the stumbling
block. I don't use matrix multiplies much, but I have
implemented 3D vector math so that "*" is the "dot product"
and "%" is the "cross product", which is pretty trivial to
do.
The only obstacle I've run into is that you can't
(easily) define *new* operators and precedence levels.
There *is* a trick for doing this that was posted on
the list some time back, which involved overloading an
operator to "apply an operator":
It would've allowed you to do something like this:
a |dot| b
a |cross| b
or perhaps
a <dot> b
a <cross> b
I don't remember where this is posted. The trick was in
overloading the <, >, or | to interact specially with
"operator" objects.
--
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com
More information about the Python-list
mailing list