# [PYTHON MATRIX-SIG] default axes

**Carlos Fonseca
**
Carlos Fonseca <fonseca@gaivota.demon.co.uk>

*Fri, 16 Aug 1996 19:31:16 +0100 (BST)*

On Fri, 16 Aug 1996, Konrad HINSEN wrote:
>* > I really think dot(a,b) should behave _exactly_ like
*>* >
*>* > add.reduce(a*b,axis=-1)
*>*
*>* Why?
*
Perhaps I should have put it a different way:
I would like the functionality of add.reduce(a*b,axis=-1), but without the
need to allocate memory to store a*b, to be available. Why, because it
appears to be as simple and general as it can get. I also thought that the
name dot() would fit this description, but looking at the definition of
dot() in Numeric.py, perhaps this functionality should simply be provided
by multiarray.innerproduct()
>* > Full rank multiplication of two arrays could be written:
*>* >
*>* > dot(a[...,(n-1)*(NewAxis,)],b,axes=-n)
*
[ actually, it should be dot(a[(Ellipses,)+(n-1)*(NewAxis,)],b,axes=-n) ]
>*
*>* That is a lot too complicated for a frequent operation, especially
*>* considering that n might not be available as a variable or constant,
*>* i.e. it would have to be written as shape(b)[0].
*
I agree, and this is why I wrote further down in the same post that I
agreed with the idea of writing two functions. innerproduct(a,b,axis) as
add.reduce(a*b,axis) provides all the functionality that is needed to
write dot() for general matrix multiplication.
Carlos
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================