In the experiment, we need to deal with the large sparse matrix, because it is necessary to take block operation to the sparse matrix and search for the index to the row and column operation which is fast.
found that Pi's blog said to the sparse matrix fetch block row is faster than the column, but I actually test found Lebis fast.
Using the number of rows 2x10^7, the number of columns 3x10^5 the sparse matrix, transpose the matrix to find a slightly increased memory footprint, such as 1:
S 22530343x429498 2400827800 double sparse s_transpose 429498x22530343 2577634560 Double Sparse
Take the S matrix before the 10^6,10^5,10^4 line, and the corresponding s_transpose of the former 10^6,10^5,10^4 column, the time used to find Lebis much faster, such as:
>> untitled3elapsed time is 2.170296 seconds. Elapsed time is 0.067666 seconds.>> untitled3elapsed time is 1.799833 seconds. Elapsed time is 0.004293 seconds.>> untitled3elapsed time is 1.690028 seconds. Elapsed time is 0.000631 seconds.
Displaying a sparse matrix of 10*10 in Matlab, and discovering that it is typed as a priority order, then temporarily speculate that its storage is column-first.
temp = (1) 1 ( 1,3) 1 (1,4) 1 (10,4) 1 (1,5) 1 (1,6) 1 (1,7) 1 (5,7) 1 (1,8) 1 (5,8) 1 (1,9) 1 (1,10) 1
I do not know who the great God know everything to explain.
Here's another question: if you need to get some rows of the matrix S, it is more efficient to take the rows in s directly, or to transpose s, then take the corresponding columns, and then transpose the resulting column to a high efficiency, (of course, it does not take the S-transpose time here, because the application scenario here is S-transpose only once, And take some of the lines of S to many times)
The following test takes the former 10^5,10^6,10^7 line of S and takes s_transpose corresponding to the previous 10^5,10^6,10^7 line, then transpose the desired time comparison, finds the fetch line and then transpose the time faster:
>> untitled3elapsed time is 1.869449 seconds. Elapsed time is 0.018637 seconds.>> untitled3elapsed time is 1.958603 seconds. Elapsed time is 0.243565 seconds.>> untitled3elapsed time is 2.541002 seconds. Elapsed time is 2.488429 seconds.
Matlab sparse matrix indexing efficiency comparison