Displaying 20 results from an estimated 10000 matches similar to: "Interfacing a C++ class"
2010 Feb 18
3
R CMD check: OK in LINUX. Crashes in Windows!
Hi,
I have followed the recommended steps for creating a package (rctest). As of
now, my goal is simply to understand how various pieces fit together. The
package includes:
(1) C code with source in sub-directories, compiled to create a static
library.
(a) There is a single C-struct (dns) a simple 'matrix': {int m; int n;
double *d;}
(b) C code to create random matrix of a certain size.
2005 Jul 19
1
S4 Dispatching
Is it possible for S4 to (continue) dispatch to a class
created during dispatching? The code below doesn't work;
is this not possible or have I ommitted something?
Concept was to create a SEXP with R_AllocatePtr, give it
a class attribute, and continue dispatch. Example code
below omits multiple parameters that can be different types.
Essentially, any parameter would be converted to an
2011 Sep 20
2
Is it possible to pass a function argument from R to compiled code in C?
I have a function in R that takes another function as argument:
f <- function(g, ...) { #g is expected to be a function
}
I want to see if there is a way to implement "f" in C and calling it from R
using ".C" interface. I know that I can use function pointers for my C
implementation, but I imagine it's going to be nearly impossible to pass a
function from R to C. Are
2016 May 14
2
R external pointer and GPU memory leak problem
My question is based on a project I have partially done, but there is still something I'm not clear.
My goal is to create a R package contains GPU functions (some are from Nividia cuda library, some are my self-defined CUDA functions)
My design is quite different from current R's GPU package, I want to create a R object (external pointer) point to GPU address, and run my GPU function
2020 Jun 29
1
Possible ABI change in R 4.0.1
Hi all,
it seems that from R 4.0.1 EXTPTR_PTR can be either a macro or a
function, depending on whether USE_RINTERNALS is requested.
Jeroen helped me find that this was in 78592:
https://github.com/wch/r-source/commit/c634fec5214e73747b44d7c0e6f047fefe44667d
This is a problem, because binary packages that are built on R 4.0.1
or R 4.0.2 will potentially not load on R 4.0.0, if they use the
2012 Oct 27
2
Class generator functions for reference classes
As of rev. 61035 in r-devel, setRefClass() now returns a generator
function, as setClass() has done since 2.15.0.
The convenient style is now:
mEdit <- setRefClass("mEdit",......)
xx <- mEdit(data = xMat)
instead of
xx <- mEdit$new(data = xMat)
The returned object still has fields and methods accessible as before.
See the "Value" and "Reference Class
2011 Apr 07
2
How to debug reference classes?
How do you debug methods of a reference class? I've been using mtrace, which
is excellent, but i cannot figure out how to mtrace a reference class
method. Maybe there is some other way to debug these, for example with
ordinary trace? for now i am only able to use options(error=recover), which
is not giving me idea where exactly in the code i am once i am stopped on an
error.
--
View this
2011 Apr 20
1
FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code
Hi, apparently I sent my question about using R and C++ to the wrong list,
ironically seeing as that list was called Rcpp. Anyway, I was directed to
post my question here. To summarize my current question, I have found two
commands that I want to be able to put into a package. The commands are 'R
CMD SHLIB X.cc X_main.cc' and
2012 Aug 31
1
Class that wraps Data Frame
Hello,
I have again a "good practices"/programming theory question regarding data.frames.
One of the fundamental objects that I use is the data frame with a particular set of columns that I would fill or get information from, and an entire system would revolve around getting information from or putting information to such data.frame.
On a different OOP programming language I would be
2011 Jun 03
2
S4 Slot assignment within function
Is there a simple way to assign values to S4 slots from within a function?
Doing this doesn't work:
> assign_slot<-function(x){
assign("OBJECT at slot",x,envir=parent.env(environment())
}
>assign_slot(x)
All I get from this is a new object with the name OBJECT at slot, the slot
assignment of OBJECT doesn't change.
I have thought about solutions such as
2012 Dec 04
1
libnutconf: specific C++ accessors technique proposition
?Hello fellow developers,
yesterday, I was thinking about how to implement specific config.
attributes accessors in section-based nut config. files so that
it's nice to use and consistent with NutConfiguration, UpsmonConfiguration
and UpsdConfiguration config. classes (where it's done via Settable attributes).
The GenericConfiguration class provides generic access to name/value
items of
2011 Apr 06
2
S4 generic functions/methods vs enclosures
Apologies for asking something that is probably very obvious, i just started
with S4 classes and i guess i am not finding documentation that lays out the
grammar rules and gives enough examples.
I understand that main method of writing a member function is to write a
generic function and setMethod for this particular class. This, however,
presumes that there is "virtuality" for this
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
2011 Sep 13
1
Getting Rcpp SEXP data in C++
Friends
I am looking at Rcpp and I am a bit stuck on a simple matter.
(I am calling R from c++, if there is a better way...)
Given this simple example using the TTR package and the SMA function which
returns a simple moving average....
Rcpp::NumericVector rv;
for(int i = 0; i < 100; i++){
rv.push_back(rand());
}
Rcpp::Environment TTR("package:TTR");
2009 Oct 27
1
How to reduce key strokes when defining S4 classes?
I feel tedious when I define a S4 class and the methods. For each
method, I have to call both setMethod and setGeneric (or both
setReplaceMethod and setGeneric). I would like a more compact grammar
so that I can reduce the key strokes. I'm wondering if there is a
better way available.
setClass(
Class='A',
representation=representation(
x='numeric'
)
2012 May 15
1
Object-oriented programming (OOP)
Hello everybody, please excuse my bad English. I am Alfredo Naime and
I'm from to Venezuela.
I want to make a lib with tools for simulation (queues, inventories,
factory, etc.) using object-oriented programming (OOP).
You have any manuals on the handling of data types, classes,
inheritance, etc. in R with examples and how to make a R lib.
Thank you, very much.
Alfredo
2012 Jul 30
1
Package index help file question.
Dear R developers,
I come to you because nobody was able to answer the following request yet.
I'm developing a release of BIOMOD package called biomod2
( https://r-forge.r-project.org/R/?group_id=302).
I'm writing my package helps files and I'm not really satisfied by the
visual results.
I would like to make subsections in the package "function help index" file.
I would
2008 Feb 08
2
learning S4
Hi the list.
I try to learn the S4 programming. I find the wiki and several doc. But
I still have few questions...
1. To define 'representation', we can use two syntax :
- representation=list(temps = 'numeric',traj = 'matrix')
- representation(temps = 'numeric',traj = 'matrix')
Is there any difference ?
2. 'validityMethod' check the
2011 Jan 26
1
Problem with "setMethod" in R package
Dear all,
My apologies for re-posting this question, but I have not found any
solution to my problem so far. I also think that my post may have been
overseen due to the posting time and high traffic on this list.
I experience a problem in implementing a S4 class in a package and would
appreciate your help in this matter.
The class is implemented using Rcpp, which works well. I then extend
2011 Jan 20
1
Calling C++ from R
Hi All,
I am new to this area and use Rcpp to call C++ from R and try to build the
package under Windows 7. I use Rtools and R 2.10.1 32bit. Everything works
fine with me, except using R functions like "rnorm" or "runif" in the C++
code. When I use "R CMD check" the package, it always return error
** libs
making DLL ...
g++