-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the problem in slot "p" in "dgCMatrix". close #149 #150
Conversation
So ... from the example and tests it looks like you nailed this on the head? Read to merge now? |
I think it is peculiar that Armadillo allows for the column pointers to be decreasing in this case. You may want to check with the author if that is intentional. It is quite common to have code that checks the last element of the column pointers (position n + 1 in R and index n in C++) to determine the number of non-zeros in the sparse matrix. |
d8b4169
to
3a4b69a
Compare
There is some slight difference in column pointers between Armadillo and Matrix pkg in R. In a matrix below: 3 x 5 sparse Matrix of class "dgCMatrix"
[1,] 1 . . . .
[2,] . 1 . . .
[3,] . . 1 . . The I think this can be intentional since we only have three nonzero elements. I will double check with the author. |
Any news on checking with Conrad or other experts on sparse matrices? |
The sparse matrix in armadillo is by Ryan (our MLPACK hero) and he is on travel. |
@thirdwing Where are we on this and the off-list reply from Ryan? What's next to move this forward? |
I am afraid we didn't get any reply from Ryan. |
So what is next? Is it conceivable that Armadillo and Matrix have different ideas about corner cases of the DSC (or other) formats? Shall we document that / create test cases? |
Every description of the compressed sparse row/column format that I have read states that the non-zeros for row/column j are in positions Another way of saying this is that, in 0-based indices the pointer array is recursively defined as
It is common to determine the number of non-zeros in each column as the successive differences in the column pointers, which is why To me the solution is to convince Conrad to modify the Armadillo representation so that it is in keeping with other sparse matrix representations. |
Sure, no problem from my end. |
From an earlier email by @rcurtin :
and by now we already have some new code to test thanks to @conradsnicta. |
I think this has been fixed by conradsnicta/armadillo-code@763ed1a |
That would be awesome. I haven't had a chance to look into the diff but I may then apply this to the pending RcppArmadillo release based on 7.960.0 (as well as all of the changes by @binxiangni). |
I have applied that patch locally. @eddelbuettel |
You mean you added it to this (pending) PR? That's very helpful. And I presume the unit test fails without it, but now passes? |
I add that patch in this PR and it just fixed the problem and passed new tests. |
Please don't merge this. I need to double check the definition of slot "p" and "col_ptrs".
Before this PR:
Now: