My question is regarding the addition of a sparse matrix on to itself. For e.g in the dense sense, performing an operation like A = A + B, where A and B are dense matrices.
Speaking in the sparse CSR sense, A may be represented by ia,ja and aval and B may be represented by ib,jb,bval and C may be represented by ic,jc and cval.
1. operation: A = B + C
Since the number of non-zero entries in A is unknown, mkl_dcsradd is called first with request = 1. After this call is executed, the number of non-zero entries will be known and then mkl_dcsradd is called with request = 2. At this point, the result of the addition is known and stored in ia,ja and aval.
Problem 1: I don't clearly understand the use of pointers here, but what I have seen is that though ia, ja and aval as per the CSR format are arrays, mkl_?csradd accepts and outputs ia, ja and aval as scalars. Printing them gives the notion of them being arrays to the end user, but they actually are scalars.
(code attached with output )
2. Considering operation: A = A + B
Problem 2: Suppose after the operation 1 is performed, I need to perform the operation A = A + B, it wouldn't be possible to do this straight away because the input arguments to the call of mkl_?csradd require the CSR representation of A (3 1D arrays). On the other hand, the data I would have is just 3 scalars (not arrays!). Is there a solution to this problem? Suppose we can circumvent this problem, will it be a problem to then perform A = A + B, because there is an inconsistency in the size of A on LHS and RHS, as mkl would see? From my point of view, I'm trying to just make the matrix A bigger and am wanting to just add all the entries in B to the same number of entries in A, hence no inconsistency, physically speaking.
I hope I have presented the problem clearly. The code and output attached should hopefully make things clear!