[Rd] A question about building a package with 2 different types of programs

2024-06-20 Thread Erin Hodgess
Hello everyone: Hope you’re having a good week. I am in the process of building a package for some time series functions. Ideally, I would like to have a setup that runs a CUDA Fortran program (which requires an NVIDIA graphics card), and an Open MP version for no NVIDIA. Is that possible, pleas

[Rd] a question about optim.R and optim.c in R

2014-07-08 Thread Prof J C Nash (U30A)
ols moves into retirement. Off-list communication about such ideas welcome. John Nash On 14-07-08 06:00 AM, r-devel-requ...@r-project.org wrote: > Message: 2 > Date: Mon, 7 Jul 2014 16:34:59 -0400 > From: Zhiyuan Dong > To: r-devel@r-project.org > Subject: [Rd] a question about optim.

Re: [Rd] a question about optim.R and optim.c in R

2014-07-07 Thread Michael Weylandt
> On Jul 7, 2014, at 4:34 PM, Zhiyuan Dong wrote: > > Hi, I am learning R by reading R source code. Here is one question I have > about the optim function in R. > > The context : In the optim.R, after all the prep steps, the main function > call call is made via : > > .External2(C_optim, par,

Re: [Rd] a question about optim.R and optim.c in R

2014-07-07 Thread Sarah Goslee
Hi, On Mon, Jul 7, 2014 at 4:34 PM, Zhiyuan Dong wrote: > Hi, I am learning R by reading R source code. That's very brave of you. You might also try reading some of the documentation and contributed documentation, like: http://adv-r.had.co.nz/C-interface.html and http://cran.r-project.org/doc/m

[Rd] a question about optim.R and optim.c in R

2014-07-07 Thread Zhiyuan Dong
Hi, I am learning R by reading R source code. Here is one question I have about the optim function in R. The context : In the optim.R, after all the prep steps, the main function call call is made via : .External2(C_optim, par, fn1, gr1, method, con, lower, upper). So, it seems to me, to follow

Re: [Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Saptarshi Guha
Hello Simon, Thanks much for the replies. It makes sense now and I'm on the right track. I'll explain why this might happen. I've written a package caller rterra [1] which essentially allows the R user to write extensions in Lua. The extensions are JIT compiled via LuaJIT. For deterministic perfo

Re: [Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Simon Urbanek
On Mar 6, 2014, at 5:32 PM, Saptarshi Guha wrote: > Hello, > > This is a question that probably reveals my lack of understanding. > In a C function (call it cfunc), i created a SEXP, called S, and then > called R_PreserveObject on S. > > I returned the SEXP to the calling R function (call it r

Re: [Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Gabriel Becker
Saptarshi, a will be protected throughout the entirety of any r functions you call in the loop. Do you have evidence that this is not the case? The protect stack is last on first off, so assuming balance, even if UNPROTECT() is called underneath the R functions you are calling, it won't touch a,

Re: [Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Saptarshi Guha
Hello, However, I do need some sort of protection. (pseudo code) SEXP a = Rf_allocVector(STRSXP,) protect a for i = 1 to length of vector SET_STRING_ELT(a,i, Rf_mkChar(...)) end unprotect a return a I _need _that protect because in the for loop i also call some R functions and need the obj

Re: [Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Gabriel Becker
Saptarshi, R_PreserveObject and R_ReleaseObject are, as far as I know, intended for the rare situations where you need to maintain a SEXP in C that is not pointed to by any R level symbols, and across e.g. .Calls. If you are returning an object to R ("v" in this case) and intend to do .Call("cfun

[Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Saptarshi Guha
Hello, This is a question that probably reveals my lack of understanding. In a C function (call it cfunc), i created a SEXP, called S, and then called R_PreserveObject on S. I returned the SEXP to the calling R function (call it rfunc). Note, I didn't call R_ReleaseObject on S. v <- .Call("cfun

[Rd] a question about (

2009-02-23 Thread Wacek Kusnierczyk
i wonder why the following approach to make an 'object' executable could not be made to work: foo = 1:3 class(object) = c('foo', class(foo)) '(.foo' = function(foo, fun) sapply(foo, fun) foo # 1 2 3 foo(function(x) x^2) # error: no function foo defined the actual

Re: [Rd] A question about the API mkchar()

2008-11-03 Thread Prof Brian Ripley
1) 2.7.0 is rather old, and you were asked to update your R before posting. 2) No file was attached. But how to handle encodings is in the 'R Internals' manual. This is a tricky, advanced, topic in C-level R programming. It is your responsibility, not ours, to get yourself up to the level

Re: [Rd] A question about the API mkchar()

2008-11-03 Thread 王永智
Hi, Simon Thanks for your elaborated instruction on mkCharCE. Concerning the UTF-8 Encoding, mkCharCE(X, CE_UTF8) is the correct way in parsing the Unicode string. However, I met another question: My program logic is intended to read the content of a text file r.tmp, which is encoded wi

Re: [Rd] A question about the API mkchar()

2008-10-28 Thread Simon Urbanek
On Oct 28, 2008, at 6:26 , Fán Lóng wrote: Hi guys, Hey guy :) I've got a question about the API mkchar(). I have met some difficulty in parsing utf-8 string to mkchar() in R-2.7.0. There is no mkchar() in R. Did you perhaps mean mkChar()? I was intending to parse an utf-8 string s

[Rd] A question about the API mkchar()

2008-10-28 Thread Fán Lóng
Hi guys, I've got a question about the API mkchar(). I have met some difficulty in parsing utf-8 string to mkchar() in R-2.7.0. I was intending to parse an utf-8 string str_jan (some Japanese characters such asふ, whose utf-8 code is E381B5) to R API SEXP mkChar(const char *name) , we only need