I'm working on translating Tim Davis's CSparse library of C functions into templated C++ classes. The purpose is to allow spare matrix manipulation both using Rcpp objects and using other types of vector objects, such as std::vector<double>.
The templates are in terms of the vector objects. The basic representations involve two sets of indices and the contents, all of which are vector objects. In Rcpp we end up with triplet or compressed sparse column matrices defined as typedef CxxSp::spTriplet<Rcpp::IntegerVector, Rcpp::NumericVector> dgTMatrix; typedef CxxSp::spCompCol<Rcpp::IntegerVector, Rcpp::NumericVector> dgCMatrix; At times I want to create a deep copy of a vector object in such a way that it will work for both std::vector<double> and an Rcpp::NumericVector. Assuming that the template parameter for the typename of a vector of data values is Td, I am using Td d_x(x.begin(), x.end()); instead of Td d_x(x); to define the data member d_x from an argument x to the constructor. My impression is that the first form will cause a deep copy for Rcpp::NumericVector objects while the second form will copy the characteristics of the structure but not the contents. For a std::vector<double> I think both forms do a deep copy. Am I correct about shallow copy and deep copy of Rcpp vectors? _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel