[PYTHON MATRIX-SIG] * and / operators (was Re: Let's get going)
Dave Forrest
forrest@rose.rsoc.rockwell.com
Tue, 12 Sep 1995 08:34:38 -0500
[Heartwarming personal intro - skip if you're not interested]
Hi, I'm Dave Forrest with Rockwell Space Ops. Co. A few of you have
met my colleagues Robin Friedrich, Greg Boes, and Charlie Fly. We are
working on ground-based simulation, monitoring, and analysis software
for the Space Shuttle. So, we have mostly an engineering/physics/math
bias in our use of Python - although we're watching the python GUI work
with keen interest. We love this language!
[Real comments - start reading here]
First off I'd like to add another vote for * being a matrix multiply,
rather than elementwise. As for /, however, that doesn't really have
meaning for matrices. When we built a C++ Matrix class, we only
defined / for element-wise division by a scalar. It works quite
nicely. We end up with something like this:
Matrix operator/(Matrix, scalar)
Matrix operator*(Matrix, Matrix)
Matrix operator*(Matrix, scalar) <- elementwise muliplication by scalar
Note that this avoids the sticky situation with inversion of matrices -
we found it better to leave that for derived classes so that people
could implement different inversion routines that capitalize on
any a_priori knowledge of what's in the Matrix.
e.g. class SquareMatrix( Matrix ):
def inv():
...
That being said, I would like to see elementwise multiplication, etc.
in there somewhere - but we use them far less frequently than real
matrix operations.
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================