Yes, it helps a lot. This confirms that I've been doing the right workarounds in my code. I thought there was a better way of doing it :-)
Best regards! PS: today I've learned how to strip debug info using Makevars, thanks @Dirk Eddelbuettel <e...@debian.org> :) -- Francisco Bischoff, MD, MSc Faculty of Medicine of the University of Porto, Portugal - Master of Medical Informatics | topic: time series - Research Associate | artificial intelligence for health <https://mailtrack.io/trace/link/9ef37dc54ba00ab7d340b722996cf6daf3e79982?url=http%3A%2F%2Fcintesis.eu%2Fai4health%2F&userId=3785237&signature=697deaf46289f1d7> @ cintesis.eu <https://mailtrack.io/trace/link/d2c9af4c46c5055871a1945a700b99ae5c72fb94?url=http%3A%2F%2Fcintesis.eu&userId=3785237&signature=c78e57822e67732e> - Teaching Assistant | department of community medicine, information and health decision sciences @ med.up.pt <https://mailtrack.io/trace/link/5fda09f77e58c396486a5c7cec1f9b982a334c58?url=http%3A%2F%2Fmed.up.pt&userId=3785237&signature=9bd0b3da0cbd0f7a> ORCID: 0000-0002-5301-8672 | Mendeley: francisco-bischoff | Google: tCeA0uUAAAAJ | ResearcherID: H-8261-2016 | ResearchGate: Francisco_Bischoff | CiênciaID B413-E0A0-DE8D | LinkedIn: franzbischoff On Sat, Jan 16, 2021 at 7:26 PM Balamuta, James Joseph < balam...@illinois.edu> wrote: > Francisco, > > > > Based on the opening post, I’d probably push you more toward Armadillo as > Dirk was in the previous message. Using linspace<>(), may be a drop-in > replacement for seq() with the appropriate helper functions. Long ago (~4+ > years now) I wrote a few, see: > > > > https://github.com/coatless/r-to-armadillo/blob/master/src/seq.cpp > <https://mailtrack.io/trace/link/80d9c725d261dfb303ccd7ab084979cdd2470c1b?url=https%3A%2F%2Fgithub.com%2Fcoatless%2Fr-to-armadillo%2Fblob%2Fmaster%2Fsrc%2Fseq.cpp&userId=3785237&signature=71713cb13a1d39e3> > > > > That said, Range is definitely preferred inside of subsets operations into > Rcpp-like data structures. However, the subset and assign operation is a > bit problematic with template expansion. So, the given example needs to > have an intermediary: > > > > // Initialization: > > Rcpp::NumericVector my_vec = Rcpp::NumericVector::create(1, 2, 3, 4, 5, > 6); > > > > // Subset and Assign to 5: > > Rcpp::IntegerVector subset_idx = Rcpp::Range(0, 3); > > my_vec[subset_idx] = 20; > > > > // Subset Positions: > > Rcpp::NumericVector subset_result = my_vec[Rcpp::Range(4, 5)]; > > > > Hope it helps. > > > > Best, > > > > JJB > > > > *From: *Rcpp-devel <rcpp-devel-boun...@lists.r-forge.r-project.org> on > behalf of Francisco Bischoff <fbisch...@med.up.pt> > *Date: *Friday, January 15, 2021 at 8:05 PM > *To: *Dirk Eddelbuettel <e...@debian.org> > *Cc: *"rcpp-devel@lists.r-forge.r-project.org" < > rcpp-devel@lists.r-forge.r-project.org> > *Subject: *Re: [Rcpp-devel] Ranges and Casting > > > > Thanks for the tips. > > > > Still, Range() is the correct way to write: > > > > NumericVector my_vec(200); > > > > my_vec(Range(0,10)) = 10; > > > > ? > > > > Thanks in advance > > > > > > > > > -- > Francisco Bischoff, MD, MSc > > Faculty of Medicine of the University of Porto, Portugal > > > > - Master of Medical Informatics | topic: time series > - Research Associate | artificial intelligence for health > <https://mailtrack.io/trace/link/81d202d5907c5004ac87fa7189a5f43096f298cb?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2Fmailtrack.io%2Ftrace%2Flink%2F1765b288bbce44d233e851a8d862ec594378aa04%3Furl%3Dhttp*3A*2F*2Fcintesis.eu*2Fai4health*2F%26userId%3D3785237%26signature%3D1b62d7a180130981__%3BJSUlJSU!!DZ3fjg!oa0yWHu4WaDeqycuBEcPRuw3vEvJrYARPPIAzJNsnxdet6loFCJ7O95nLR4ByfJyNzg%24&userId=3785237&signature=6f861a4b397dfc79> > @ cintesis.eu > <https://mailtrack.io/trace/link/5daf3fbe3ec2bde304cedb67b9c667f32b984de5?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2Fmailtrack.io%2Ftrace%2Flink%2F89b15c4212d5d6c8d4ba354ec92ab002ba9a96ef%3Furl%3Dhttp*3A*2F*2Fcintesis.eu%26userId%3D3785237%26signature%3D5fa97b31373fa664__%3BJSUl!!DZ3fjg!oa0yWHu4WaDeqycuBEcPRuw3vEvJrYARPPIAzJNsnxdet6loFCJ7O95nLR4B0QFIUzg%24&userId=3785237&signature=df96e330eb4e5915> > - Teaching Assistant | department of community medicine, information and > health decision sciences @ med.up.pt > <https://mailtrack.io/trace/link/83fdd729acfe28d35a79adba75b6427b6c655131?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2Fmailtrack.io%2Ftrace%2Flink%2F32f5f446b7bc0d597241524764b3636b5a75d466%3Furl%3Dhttp*3A*2F*2Fmed.up.pt%26userId%3D3785237%26signature%3Dcfbca25f5fe210b3__%3BJSUl!!DZ3fjg!oa0yWHu4WaDeqycuBEcPRuw3vEvJrYARPPIAzJNsnxdet6loFCJ7O95nLR4BoT_L--M%24&userId=3785237&signature=cb0c4f80c0dd44f2> > > ORCID: 0000-0002-5301-8672 | Mendeley: francisco-bischoff | Google: > tCeA0uUAAAAJ | ResearcherID: H-8261-2016 | ResearchGate: Francisco_Bischoff > | CiênciaID B413-E0A0-DE8D | LinkedIn: franzbischoff > > > > > > On Sat, Jan 16, 2021 at 1:54 AM Dirk Eddelbuettel <e...@debian.org> wrote: > > > On 16 January 2021 at 01:35, Francisco Bischoff wrote: > | About the Range() function, I think it should handle decreasing ranges > | too... > | But, idk if using Matlabs approach or R approach: > | > | R's: > | > | a <- 1 > | b <- 10 > | > | print(a:b) > | 1 2 3 4 5 6 7 8 9 10 > | print(b:a) > | 10 9 8 7 6 5 4 3 2 1 > | > | Matlab's > | a = 1; > | b = 10; > | disp(a:b); > | 1 2 3 4 5 6 7 8 9 10 > | disp(b:a); > | numeric(0) > | disp(b:-1:a) > | 10 9 8 7 6 5 4 3 2 1 > | > | I think that we are in the R domain, so we should use Range(b, a) > normally > | (my humble opinion). > > Hm but I think the Range class in Rcpp is not the same as R's seq(). It is > used internally in a few places and may not generalize well to the 'b:-1:a' > use. > > I had a quick look, and Armadillo may not have anything directly relevant > either. linspace() is close but not quite the same. > > I would probably just write myself a little helper function. > > | About Casting, this is a good example: > | > | Rcout << Range(0, 10) << std::endl; > | > | This does not compute... > | > | What should I do? > | > | Rcout << as<IntegerVector>(Range(0, 10)) << std::endl; > | or > | Rcout << (IntegerVector)(Range(0, 10)) << std::endl; > > That can happen as template expressions can get in the way. Alternatives > are > maybe using Armadillo types for, again, just using a quick loop and > printing > elements. > > Rcpp has a lot of functions. But it doesn't have "all of R's functions" and > should not be seen as aiming for that. > > Dirk > > -- > https://dirk.eddelbuettel.com > <https://mailtrack.io/trace/link/6980bfa152de9cac3c6fdf921fa97bf34670a814?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2Fmailtrack.io%2Ftrace%2Flink%2Fec16eaacf00108f6b925d8cd55d469ea736d3313%3Furl%3Dhttps*3A*2F*2Fdirk.eddelbuettel.com%26userId%3D3785237%26signature%3D5ff5161e5ff16475__%3BJSUl!!DZ3fjg!oa0yWHu4WaDeqycuBEcPRuw3vEvJrYARPPIAzJNsnxdet6loFCJ7O95nLR4BxG2v_1M%24&userId=3785237&signature=6c0196f400190f18> > | @eddelbuettel | e...@debian.org > > [image: Image removed by sender.] >
_______________________________________________ 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