-
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
Add support for dtCMatrix&dsCMatrix #135
Conversation
|
||
// Setting the sentinel | ||
arma::access::rw(res.col_ptrs[(unsigned) dims[1] + 1]) = | ||
arma::access::rw(res.col_ptrs[static_cast<unsigned>(ncol + 1)]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the static_cast
usage.
inst/include/RcppArmadilloAs.h
Outdated
std::copy(x.begin(), x.end(), arma::access::rwp(res.values)); | ||
// Get the type of sparse matrix | ||
std::string type = Rcpp::as<std::string>(mat.slot("class")); | ||
if (type == "dgCMatrix"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistically... @eddelbuettel will complain that you did not put a space between )
and {
.
Could you add unit tests that verify your assertion? https://github.com/RcppCore/RcppArmadillo/blob/master/inst/unitTests/runit.sparse.R |
Nice! And don't worry too about indentation -- following what is in the other files in the repo is a good plan. |
I am curious about the meaning of the first dot and triple colons in the following codes:
|
Generally, the Regarding the You might want to glance at Double Colon and Triple Colon Operators help doc article for more. |
@@ -77,7 +77,9 @@ namespace traits { | |||
private: | |||
MATRIX mat ; | |||
}; | |||
|
|||
|
|||
// 14 June 2017 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't have time in other place, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just followed the style of the source code. There are also dates there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter. Let's focus on the unit test.
std::copy(p.begin(), p.end(), arma::access::rwp(res.col_ptrs)); | ||
std::copy(x.begin(), x.end(), arma::access::rwp(res.values)); | ||
// Get the type of sparse matrix | ||
std::string type = Rcpp::as<std::string>(mat.slot("class")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can print some message when converting the matrix type?
Like "Converting dgCMatrix into Armadillo type".
What is your opinion? @coatless
IIRC the As for printing message: Hm. Maybe if and only if a |
Perhaps a set of debug macros similar to what Rcpp does for some of the String and general conversions? c.f. So, we would have
Then something print status of conversion to console with |
Let's not get distracted. This is Binxiang's issue ticket on something different. We can always print some debug text during development and clean up before releases. No biggie either way. |
@binxiangni The pull request looks really good. Two more suggestions / requests
Can we add that? |
@eddelbuettel Sorry for delay. I'll do that ASAP. Please do not merge for now. I understand the importance of test. As I mentioned before, my broken laptop quite let me down. Yesterday I tried to use Ubuntu Server in the digitalocean as KK suggests and set up a GUI for further working environment, but GUI didn't work. I'll go to a local dealer to get a new laptop today. After that, I can go back to the right track. Apologize again! |
No worry, you are doing great. We could do it as two PRs as well but may as well have you expand this one. |
Oh, and sorry about the hardware troubles. @coatless Any way a student can access a proper and current dev env on campus? Isn't that what the VM pool is for? But not outside of classes? |
The local dealer also tells me that I can get the laptop after 10 days. 😭
Do you have any idea? |
Sure. Standard RStudio Server use via a webbrowser. See eg https://support.rstudio.com/hc/en-us/articles/200552306-Accessing-RStudio-Server-Open-Source Really no resources on campus? |
I can access the computer in the computer lab, but have no admin right to install package like Armadillo. But for now, I have an old laptop from my friend and at least it can run the |
Also, you could just use GitHub and Travis CI. If you clone RcppArmadillo you have a working |
Just to give a heads up, I've put in a request to get @binxiangni access to a linux machine on campus. I'll let you know what happens. (It likely won't be until Monday since it's almost 5 o'clock.) |
Thanks for adding tests. Looks like one failed ... but I am about to cook dinner so can't check now. I am sure we'll get it sorted out. |
I find where the bug is: |
inst/unitTests/cpp/sparse.cpp
Outdated
int nrow = dims[0]; | ||
int ncol = dims[1]; | ||
|
||
// Creating an empty SpMat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we want to test is arma::sp_mat res = Rcpp::as<arma::sp_mat>(S);
The converting code has been added into the as
implementation and we want to test.
I did unit test locally and it shows |
That usually means a closing I can take a look in a bit. Just in a from a long run... |
Passes with flying colors for me too! |
Now I just add codes for the conversion of dtCMatrix and dsCMatrix here in order to partially solve the issue#17 and issue#114. More conversion of sparse matrix would be added soon. Please do me a favor to check the code style or anything else important.