python - Fancy indexing in assignment not supported for csr matrices -
How can I specify a line in a csr_matrix
?
This error returns:
Q [middle ,:] = new_q
Q
The result of csr_matrix
, and new_q
is Q.getrow (i)
.
I am using the latest version of Scipy.
Am I using the correct matrix type?
I want to show the correct matrix type for using two matrix: Q
and b
. I am amending a line of the matrix cue at a time, and am amending one's columns at a time. It seems that I should make a Q
as a lil_matrix
or csr_matrix
. What type of matrix should be B
? A csc_matrix
?
This works fine in 13.2:
& gt; & Gt; & Gt; Sp .__ version__ '0.13.2' & gt; & Gt; & Gt; Imported Sps as SPS & gt; & Gt; & Gt; A = sps.csr_matrix (np.arange (25) .reshap (5, 5)) & gt; & Gt; & Gt; AA array ([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 1] 9], [20, 21, 22, 23, 24]]))); & Gt; & Gt; A [3] = a.getrow (0)> gt; & Gt; & Gt; AA array ([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [0, 1, 2, 3, 4 ], [24, 21, 22, 23, 24]]
To answer your second question, it depends on the fact that you are the scorpion pattern (columns) of rows or No. If you are not, then yes, CSR for the line, CSC for the column, but if you are, CSR and CSC are struggling because each row (column) update every time you copy the data to the entire matrix That's needed In this latter case, you can try to use LIL for both your Q
and B
metrics, but BT
Work with so that you can access rows.
Comments
Post a Comment