matrix_1 = matrix_2 * matrix_3

Anton Vredegoor anton at
Mon Aug 26 15:31:01 CEST 2002

On 25 Aug 2002 23:32:01 +0200, Chris Liechti <cliechti at> wrote:

>anton at (Anton Vredegoor) wrote in
>news:akbhl5$m3r$1 at 
>> Is there a module that uses the star operator for matrix
>> multiplication? If not, which module would be suitable to subclass a
>> matrix class from so that it does this?
>Nummeric has everything you need

<numeric docs>
matrixmultiply(m1, m2)
The matrixmultiply(m1, m2) multiplies matrices or matrices and vectors as
matrices rather than ele-mentwise.
>>> print a
[[0 1 2]
[3 4 5]]
>>> print b
[1 2 3]
>>> print a*b
[[ 0 2 6]
[ 3 8 15]]
>>> print matrixmultiply(a,b)
[ 8 26]
</numeric docs>

>From this it seems that redefining the star operator to do what is
called matrixmultiply here could cause problems. But maybe not. Could
someone please inform me whether it would be possible to adapt numeric
to use the star operator for matrixmultiply.

I think numeric is a great package and if it were just for me I would
use the standard package, but since this is not for one of my own
projects I would rather not interfere with design decisions. In fact
it could be that if no python module that uses the star operator for
matrixmultiply can be found, python would not be used at all for
this project.

The main project line is an educational course where students study paper
material (in which matrix multiplications are notated by A = B * C or
something like this) and python would be used to corroborate the results. If
python does not fullfill the need for the star operator things will probably
stay the way they are now.


More information about the Python-list mailing list