4 ms·
I agree that many words "have meanings", including "matrix" in general, and "CSC matrix" in particular. I think you have the wrong definitions for both. In my
by jholman 12y ago
I agree that many words "have meanings", including "matrix" in general, and "CSC matrix" in particular. I think you have the wrong definitions for both.
In my experience, "matrix" is a mathematical concept, and is independent of the implementation. As such, an extremely sparse matrix, such as your alleged interviewer described, is absolutely a matrix. And for such a matrix (density 10^-9), such a dictionary-style approach seems fairly reasonable.
Next, it seems to me that "CSC matrix" is a particular encoding that works well for sparse matrices, that is not related to the code that you wrote. It contains no index/value tuples, and it consists of three top-level arrays (that, in the general case, are of different lengths).
https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29 https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_spars...
http://netlib.org/linalg/html_templates/node92.html#SECTION00931200000000000000 http://netlib.org/linalg/html_templates/node92.html#SECTION0...
http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.sparse.csc_matrix.html http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/s...
Actually, it's not obvious to me how to do arithmetic on it (without converting to a denser format), though the scipy docs say it's fairly efficient, so I'm having a little think about that. Interesting.
Anyway, sounds like you're glad you didn't get that job, and I'd imagine that they're glad they didn't get you, so everybody wins.
- x0x0 11y ago3 arrays is directly equivalent to an array of 2 arrays or an array of tuples of index,value. As for how it's efficient, that's obvious: column eg 3 will be an array of tuples like [(1,3), (11,17), (9936,3)] so there are nz values in locations [1, 3] = 3 [11, 3] = 17 [9936, 3] = 3 so csc makes it efficient to read down columns, ie right multiply by the transpose. My implementation makes it easier to update in the sense of inserting values at indices where previously the value was empty, since you only have to reorder a single column instead of all following data from top to bottom then left to right. Once finished inserting values, if ever, you may want to move to two packed arrays. What makes me shake my head is you don't understand what csc matrices are but didn't let that stop you from telling me I don't understand them. HN in a nutshell.