I’m just getting used to Julia and therefore have very basic questions:
SparseMatrix
I have a little sparse matrix (only 11 Rows). Since the number of entries for storage as SparseMatrixCSC must be known: Will such a small matrix be stored on the stack or do I have to weigh up whether the SparseMatrix or SArray will bring me greater benefit?
MArray
There is also MArray in the package StaticArrays. When does one use MArray?
specifically, you shouldn’t use SparseMatrixCSC with less than around 10000 elements. If your matrix is small enough to fit in L2 cache, it’s probably not worth the 10x overhead to index. Special types of Sparse matrices (like DiagonalBanded etc) on the other hand are worth it at much smaller sizes.
This actually makes me wonder how and why MMatrix are actually implemented as they are, and if that could not be improved.
(it has not escaped to me that the function above does not mutate the matrix if it is a static matrix, and one may have to appeal to MMatrix if passing it to another code over which one does not have access to define A = mut!(A)) .
Thanks for your help.
I’m afraid I’ve left out an important piece of information:
I have an 11 * 11 matrix with entries only on 3 diagonals. It’s a SparseMatrixCSC but I created it with spdiagm, that’s what I should have said about it. The overhead should therefore be significantly lower.
It’s kind of a diffusion matrix that never gets changed and I was wondering if I couldn’t take advantage of this fact by making it somehow immutable.