search for: szwjf08

Displaying 20 results from an estimated 46 matches for "szwjf08".

2019 Sep 23
2
What is the best way to loop over an ALTREP vector?
...\ } \ else ITERATE_BY_REGION_PARTIAL0(sx, px, idx, nb, etype, vtype, \ strt, nfull, expr); \ } while (0) Best, Jiefei On Mon, Sep 23, 2019 at 3:12 PM Wang Jiefei <szwjf08 at gmail.com> wrote: > Hi Gabriel, > > I have tried the macro and found a small issue, it seems like the macro is > written in C and does an implicit type conversion(const void * to const int > *), see below. While it is allowed in C, C++ seems not happy with it. Is it > possi...
2019 Sep 24
2
What is the best way to loop over an ALTREP vector?
...n Mon, Sep 23, 2019 at 6:12 PM Bob Rudis <bob at rud.is> wrote: > Not sure if you're using just C++ or Rcpp for C++ access but > https://purrple.cat/blog/2018/10/14/altrep-and-cpp/ has some tips on > using C++ w/ALTREP. > > > On Sep 23, 2019, at 3:17 PM, Wang Jiefei <szwjf08 at gmail.com> wrote: > > > > Sorry for post a lot of things, for the first part of code, I copied my > C++ > > iter macro by mistake(and you can see an explicit type casting). Here is > > the macro definition from R_exts/Itermacros.h > > > > #define ITERATE...
2019 Jun 18
2
Fast way to call an R function from C++?
..., evn)) user system elapsed 2.307 0.000 2.313 > system.time(test(C_test3, testFunc, evn$x)) user system elapsed 2.131 0.000 2.138 I?aki On Tue, 18 Jun 2019 at 20:35, I?aki Ucar <iucar at fedoraproject.org> wrote: > > On Tue, 18 Jun 2019 at 19:41, King Jiefei <szwjf08 at gmail.com> wrote: > > > > [...] > > > > It is clear to see that calling an R function in R is the fast one, it is > > about 5X faster than ` R_forceAndCall ` and ` Rf_eval`. the latter two > > functions have a similar performance and using Rcpp is the worst...
2019 Sep 24
0
What is the best way to loop over an ALTREP vector?
Not sure if you're using just C++ or Rcpp for C++ access but https://purrple.cat/blog/2018/10/14/altrep-and-cpp/ has some tips on using C++ w/ALTREP. > On Sep 23, 2019, at 3:17 PM, Wang Jiefei <szwjf08 at gmail.com> wrote: > > Sorry for post a lot of things, for the first part of code, I copied my C++ > iter macro by mistake(and you can see an explicit type casting). Here is > the macro definition from R_exts/Itermacros.h > > #define ITERATE_BY_REGION_PARTIAL(sx, px, idx, n...
2019 Jun 18
3
Fast way to call an R function from C++?
Hi, I'm looking for a most efficient way to call an R function from C++ in a package. I know there are two functions (`R_forceAndCall` and `Rf_eval`) that can do the "call" part, but both are slow compared to calling the same function in R. I also try to use Rcpp and it is the worse one. Here is my test code: C++ code: ``` // [[Rcpp::export]] SEXP C_test1(SEXP f, SEXP x) { SEXP
2020 Oct 19
1
Is there any way to check the class of an ALTREP?
...edfuns.h#L118 > > > > > > The macro is defined here in Rinternals.h: > > > > https://github.com/wch/r-source/blob/abb550c99b3927e5fc03d12f1a8e7593fddc04d2/src/include/Rinternals.h#L325 > > > > > > Den man. 19. okt. 2020 kl. 10.13 skrev Jiefei Wang <szwjf08 at gmail.com > >: > > >> > > >> Hi all, > > >> > > >> I would like to determine if an ALTREP object is from my package, I > see > > >> there is a function `ALTREP_CLASS` defined in RInternal.h but its > return > > >&gt...
2020 Oct 19
2
Is there any way to check the class of an ALTREP?
...a9d3fc63437d9e697f442d32732fb4f443/src/include/Rinlinedfuns.h#L118 > > The macro is defined here in Rinternals.h: > https://github.com/wch/r-source/blob/abb550c99b3927e5fc03d12f1a8e7593fddc04d2/src/include/Rinternals.h#L325 > > Den man. 19. okt. 2020 kl. 10.13 skrev Jiefei Wang <szwjf08 at gmail.com>: >> >> Hi all, >> >> I would like to determine if an ALTREP object is from my package, I see >> there is a function `ALTREP_CLASS` defined in RInternal.h but its return >> value is neither a `R_altrep_class_t` object nor an STRSXP representing a...
2019 Aug 28
3
What is the best way to loop over an ALTREP vector?
Hi devel team, I'm working on C/C++ level ALTREP compatibility for a package. The package previously used pointers to access the data of a SEXP, so it would not work for some ALTREP objects which do not have a pointer. I plan to rewrite the code and use functions like get_elt, get_region, and get_subset to access the values of a vector, so I have a few questions for ALTREP: 1. Since an
2020 Oct 19
2
Is there any way to check the class of an ALTREP?
Hi all, I would like to determine if an ALTREP object is from my package, I see there is a function `ALTREP_CLASS` defined in RInternal.h but its return value is neither a `R_altrep_class_t` object nor an STRSXP representing a class name. I do not know how to correctly use it. Any suggestions? Thanks, Jiefei [[alternative HTML version deleted]]
2019 Dec 08
2
What should dnorm(0, 0, -Inf) return?
...0) ML_ERR_return_NAN; if(!R_FINITE(sigma)) return R_D__0; if(!R_FINITE(x) && mu == x) return ML_NAN;/* x-mu is NaN */ if (sigma == 0) return (x == mu) ? ML_POSINF : R_D__0; x = (x - mu) / sigma; (Ping Martin...) -pd > On 7 Dec 2019, at 23:40 , Wang Jiefei <szwjf08 at gmail.com> wrote: > > Good question, I cannot speak for R's developers but I would like to > provide some information on the problem. Here are the first few lines of > the dnorm function located at src\nmath\dnorm.c: > > ``` > double dnorm4(double x, double mu, doub...
2020 Oct 08
1
Coercion function does not work for the ALTREP object
...em. https://github.com/Jiefei-Wang/testPkg Best, Jiefei On Thu, Oct 8, 2020 at 5:04 AM Gabriel Becker <gabembecker at gmail.com> wrote: > Jiefei, > > Where does the code for your altrep class live? > > Thanks, > ~G > > On Wed, Oct 7, 2020 at 4:25 AM Jiefei Wang <szwjf08 at gmail.com> wrote: > >> Hi all, >> >> The coercion function defined for the ALTREP object will not be called by >> R >> when an assignment operation implicitly introduces coercion for a large >> ALTREP object. >> >> For example, If I create a...
2020 Oct 07
2
Coercion function does not work for the ALTREP object
Hi all, The coercion function defined for the ALTREP object will not be called by R when an assignment operation implicitly introduces coercion for a large ALTREP object. For example, If I create a vector of length 10, the ALTREP coercion function seems to work fine. ``` > x <- 1:10 > y <- wrap_altrep(x) > .Internal(inspect(y)) @0x000000001f9271c0 13 INTSXP g0c0 [REF(2)] I am
2020 Aug 28
2
Evaluate values in `Sys.setenv`
Hi all, I would like to know if there is any way to evaluate the values in `Sys.setenv` before setting the environment variables. For example, if we want to add a path to the environment variable `PATH`, we can do this in a terminal ``` > export PATH=~/mypath:$PATH > echo $PATH /Users/jeff/mypath:... ``` However, this style of assignment is not allowed in `Sys.setenv`, it treats its
2019 May 27
1
"if" function in pure R?
...returning a logical], but both are workaround that I do not find as elegant as a proper control-flow construct. Thus two questions remain: - is it possible to create a control-flow construct in pure R? - if yes, how? Anyone with more insights? Thanks On Mon, 27 May 2019 at 04:27, King Jiefei <szwjf08 at gmail.com> wrote: > Hi Alexandre, > > I'm not an R expert so this is only my personal thought: > > I don't think you can achieve what you want exactly. A possible solution > would be defining a binary operator %*%, where you can replace the asterisk > with any fu...
2019 May 16
3
ALTREP: Bug reports
...wrote: > Hi Jiefei, > > Thanks for tryingout the ALTREP stuff and letting us know how it is going. > That said I don't think either of these are bugs, per se, but rather a > misunderstanding of the API. Details inline. > > > > On Thu, May 16, 2019 at 11:57 AM ??? <szwjf08 at gmail.com> wrote: > >> Hello, >> >> I have encountered two bugs when using ALTREP APIs. >> >> 1. STDVEC_DATAPTR >> >> From RInternal.h file it has a comment: >> >> /* ALTREP support */ >> > void *(STDVEC_DATAPTR)(SEXP x); >&...
2019 Sep 23
0
What is the best way to loop over an ALTREP vector?
...ble sillysum(SEXP x) { double s = 0.0; type_free_iter(x, ptr, ind, nbatch, { for (int i = 0; i < nbatch; i++) { s = s + ptr[i]; } }); return s; } Best, Jiefei On Wed, Aug 28, 2019 at 2:32 PM Wang Jiefei <szwjf08 at gmail.com> wrote: > Thank you, Gabriel. The loop macro is very helpful. It is also exciting to > see that there are lots of changes in ALTREP in R devel version. I really > appreciate your help! > > Best, > Jiefei > > On Wed, Aug 28, 2019 at 7:37 AM Gabriel Becker &lt...
2019 Jul 19
2
ALTREP wrappers and factors
Hi Jiefei and Kylie, Great to see people engaging with the ALTREP framework and identifying places we may need more tooling. Comments inline. On Thu, Jul 18, 2019 at 12:22 PM King Jiefei <szwjf08 at gmail.com> wrote: > > If that is the case and you are 100% sure the reference number should be 1 > for your variable *y*, my solution is to call *SET_NAMED *in C++ to reset > the reference number. Note that you need to unbind your local variable > before you reset the number....
2019 Sep 03
2
[ALTREP] What is the meaning of the return value of Is_sorted and No_NA function?
Hi, I would like to figure out the meaning of the return value of these two functions. Here are the default definitions I find from R source code: static int altreal_Is_sorted_default(SEXP x) { return UNKNOWN_SORTEDNESS; } static int altreal_No_NA_default(SEXP x) { return 0; } I guess the macro *UNKNOWN_SORTEDNESS *in *Is_sorted* and 0 in *No_NA *simply means unknown sorted/NA status of
2020 Mar 11
0
R CMD INSTALL cannot recognize full path on Windows
...sists, find out why it works when invoked from the command line but not from R CMD INSTALL. Best Tomas On 3/10/20 10:15 AM, Wang Jiefei wrote: > ? Oops, I think both of us forget to cite the r-devel channel. > > Best, > Jiefei > > On Tue, Mar 10, 2020 at 5:13 AM Wang Jiefei <szwjf08 at gmail.com > <mailto:szwjf08 at gmail.com>> wrote: > > Thanks for your quick response, Tomas. > > Yes, this is a path issue, I think the problem is related to R, > not the Rtools make. I built an example package for reproducing > the problem: https:/...
2019 May 16
0
ALTREP: Bug reports
Jiefei, Inline. On Thu, May 16, 2019 at 2:30 PM ??? <szwjf08 at gmail.com> wrote: > Hello Luke and Gabriel, > > Thank you very much for your quick responses. The explanation of STDVEC is > very helpful and I appreciate it! For the wrapper, I have a few new > questions. > > > 1. Like Luke said a mutable object is not possible. Howe...