[SciPy-User] Sparse matrices and dot product
Sun Nov 28 13:47:35 CST 2010
I apologize for being a little unrelated to the original topic of this
discussion: I don't use sparse matrices a lot, so this specific `dot`
problem is not an issue for me.
However, I noticed that when I first joined this mailing list there
seemed to be a strong agreement among the subscribers that
`A.dot(B)` is "evil". IIRC the argument was something similar to
"there should be only one obvious way".
Now I'm confused that everyone seems to be in favor of the
(re-)addition of `A.dot(B)`:
Consider the following piece of code:
-------------- start code ----------------
A = numpy.ones((2,2))
B = [1,2]
C = generic_func(A,B)
D = generic_func(A,B)
-------------- end code ----------------
This is a rather generic code that can operate on `array_like` objects.
Since `list` does not have a dot method, the use of A.dot(B) would be
Wouldn't it be much more convenient if `numpy.dot` were designed such
that `A` could also be a sparse matrix
instead of adding a `dot` method?
On Sun, Nov 28, 2010 at 4:32 PM, Gael Varoquaux
> On Sun, Nov 28, 2010 at 03:16:19PM +0000, Pauli Virtanen wrote:
>> However, I believe 'dot' should be left to be there. `ndarrays` recently
>> gained the same method for matrix products, so it makes sense to leave it
>> be also for sparse matrices. This has also the advantage that it becomes
>> possible to write generic code that works both on sparse matrices and on
>> So unless objections arise, the 'dot' method will be un-deprecated in 0.9.
> SciPy-User mailing list
More information about the SciPy-User