Reputation: 8792
Scipy has different kind of matrices. Two of them are the column sparse matrix and the row sparse matrix. The column sparse matrix supports fast column slicing operations and the row sparse matrix supports fast row slicing operations.
But I am not if the operation a[i,:] is a column or a row slicing operation. Any help?
Upvotes: 3
Views: 1737
Reputation: 3865
There is nothing like trying it by yourself:
In [1]: import numpy as np
In [2]: np.arange(9).reshape(3,3)
Out[2]:
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
In [3]: a = np.arange(9).reshape(3,3)
In [4]: a[0, :]
Out[4]: array([0, 1, 2])
In [5]: a[:, 0]
Out[5]: array([0, 3, 6])
Ergo, the first index corresponds to the row and the second to the column. a[i, :]
is selecting the row i
, so it is a row slicing operation.
Upvotes: 4