rcppcore / rcpp Goto Github PK
View Code? Open in Web Editor NEWSeamless R and C++ Integration
Home Page: https://www.rcpp.org
License: GNU General Public License v2.0
Seamless R and C++ Integration
Home Page: https://www.rcpp.org
License: GNU General Public License v2.0
Class inheritance. Reflect C++ inheritance at the R level.
This is partially done.
This is safer
See this thread.
http://thread.gmane.org/gmane.comp.lang.r.rcpp/6119
There is a fix in Rcpp11 in this commit: Rcpp11/Rcpp11@f5e1600
Sugar ops unit tests on +, -, ... need double, fail with int
A factor is not much more than an IntegerVector
with a labels
attribute. We should have a special class like Rcpp::Factor
to deal with it.
In particular, operator[](int)
should return a proxy that knows how to handle strings and integers.
This is a ridiculous consequence of having the unit test vignette.
* checking tests ...
Running ‘doRUnit.R’
* checking running R code from vignettes ...
‘Rcpp-attributes.Rnw’ ... OK
‘Rcpp-extending.Rnw’ ... failed
‘Rcpp-FAQ.Rnw’ ... failed
‘Rcpp-modules.Rnw’ ... OK
‘Rcpp-package.Rnw’ ... OK
‘Rcpp-quickref.Rnw’ ... OK
‘Rcpp-sugar.Rnw’ ... OK
‘Rcpp-introduction.Rnw’ ... OK
‘Rcpp-unitTests.Rnw’ ...
We need to dump Rcpp-unitTests.Rnw
.
void update( SEXP x){
// TODO: check that x is of a reference class
if( ! ::Rf_isS4(x) ) throw not_reference() ;
}
@johnmchambers is there a test for "is this a reference class object"
We should have const and non const versions of proxy classes (attribute, ...) so that we don't need spurious const_cast
for character vectors: nchar, grepl, sub, gsub
other statistical distribution functions:
multinom : this only has dmultinom which is handled in R, so
maybe we can skip it
signrank : has the weird call to .C( "signrank_free" ), need
to understand that
wilcox : has the weird call to .C( "wilcox_free" ), need to
understand that
tukey : only has p and q, no r or d
all r* functions : rnorm, etc ...
Current classes DateVector
and DatetimeVector
should be redesigned into something that feels more like Rcpp's api, i.e. hook back to the internal numeric vector instead of having its own memory.
We might be able to keep Date
and Datetime
as proxy objects but a DateVector
should not be a std::vector<Date>
as it currently is.
R-Forge is mentioned in DESCRIPTION, vignettes and more:
edd@max:~/svn/rcpp/pkg/Rcpp$ grep -lr r-forge
tests/doRUnit.R
inst/announce/ANNOUNCE-0.10.0.txt
inst/announce/ANNOUNCE-0.6.0.txt
inst/announce/ANNOUNCE-0.8.0.txt
inst/announce/ANNOUNCE-0.9.0.txt
DESCRIPTION
debian/copyright
vignettes/Rcpp-FAQ.Rnw
vignettes/rcpp.index.html
ChangeLog
edd@max:~/svn/rcpp/pkg/Rcpp$
I don't think a vignette is the best vehicle for that.
This is bad:
inline NameProxy operator[]( const std::string& name ) const {
return NameProxy( const_cast<Vector_Impl&>(*this), name ) ;
}
inline NameProxy operator()( const std::string& name ) const {
return NameProxy( const_cast<Vector_Impl&>(*this), name ) ;
}
We should have a const_NameProxy
class and avoid doing const_cast
inline SEXP string_to_try_error( const std::string& str){
using namespace Rcpp;
Shield<SEXP> simpleErrorExpr = Rf_lang2(::Rf_install("simpleError"), Rf_mkString(str.c_str()));
Shield<SEXP> simpleError = Rf_eval(simpleErrorExpr, R_GlobalEnv);
Shield<SEXP> tryError = Rf_mkString( str.c_str() ) ;
Rf_setAttrib( tryError, R_ClassSymbol, Rf_mkString("try-error") ) ;
Rf_setAttrib( tryError, Rf_install( "condition") , simpleError ) ;
return tryError;
}
The only reason we call R's simpleError
is to deal with the call
attribute. There is probably a better and less expensive way to handle that.
See https://gist.github.com/romainfrancois/6119995 for an example on how to get internal access to the connection object.
From Murray:
A vector of 64-bit integers in C++ code should be either returned as
An integer vector (if all values are < INT_MAX in the C code) corresponding to R's integer type.
A numeric vector (if all values are < 1L << 53 such that they can be stored precisely in a double without losing any digits of precision) corresponding to R's numeric type.
A vector of strings (if at least 1 value > 1L << 53 such that returning a numeric would lose precision in the result. e.g. 64-bit fingerprints, userids, network addresses or other things can not be stored in a numeric accurately.
Sorry no patch, I work around this in my application code currently before calling Rcpp::wrap().
other random generators:
rmultinom : tricky because it generates a matrix
rnbeta : the R version is implemented in R (not in C),
should we still have it in Rcpp in compile code ?
rnf : idem
rnt : idem
In setting up inherited read-only fields in classModule(), I seemed to get C++ compile errors from a .poperty() w/o either a setter or a document string.
The workaround was to generate a trivial document string, which seems to work fine.
E.g., I generate a line in one example:
.property("size", &module_PopCount_NS::field_size_get, "read-only field")
If I delete the string argument, compile of the resulting .cpp file fails with:
PopCountModule.cpp: In function 'void rcpp_module_class_PopCount_init()':
PopCountModule.cpp:21: error: no matching function for call to 'Rcpp::class::property(const char [5], std::vector<long int, std::allocator > ()(PopCount))'
make: *** [PopCountModule.o] Error 1
logical indexing, ie NumericVector[ LogicalVector ]
.
We should flip the problem and delegate the responsability of extracting to a class. For example do something like this;
template <typename T>
Extractor<Vector,T> operator[]( const T& x) ;
So that we define the meaning in a separate class Extractor
or something. This way we would just have to redefine Extractor
when we want to handle a new extractor type.
Because void&
does not make sense, we need a specialization of XPtr<void>
Taking care of e.g. names. Other attributes ?
We can't really achieve header only, but we can achieve that what the client package sees is only headers. So that we no longer need linking against the Rcpp library, which makes this library useless.
I did this in Rcpp11
Currently it only take one-argument functions - add a variadic extension, to be able to use functions with multiple arguments in addition to just the SEXP.
in #48 @eddelbuettel claims that :
... the undocumented Rcpp:::test() [ seems broken right now even with Sys.setenv("RunAllRcppTests"="yes")
set ]
So we should either fix it or remove it.
not sure rep should be lazy, i.e. rep( x, 4 ) fetches x[i] 4 times,
maybe we should use LazyVector like in outer to somehow cache the
result when it is judged expensive to calculate
Rcpp.package.skeleton()
does not work with supplied functions,
eg Rcpp.package.skeleton("foo", list=c("funA", "funB"))
ends
in error.
Maybe not needed anymore with RcppArmadillo
Similar to #11 but keeping levels ordered.
inline SEXP empty_data_frame(){
SEXP dataFrameSym = ::Rf_install( "data.frame");
return ::Rf_eval( ::Rf_lang1( dataFrameSym ), R_GlobalEnv ) ;
}
we can do better
This has been on the TODO for ages. I don't think it is likely to happen. Maybe we should just close this.
new autogenerated sugar functions: cos, acosh, atan, cos, cosh, log,
log10, sqrt, sin, sinh, tan, tanh
recycling : binary operators and math functions of 2 or more arguments
need to recycle their arguments.
into something we can use here. This needs to be issue by issue if we want this to be any useful
It would be useful for packages to be able to extend attributes. Package foo
could register a foo::bar
attribute to do something about a function, a class, whatever ...
I have one use case in mind for this in dplyr
where it would be nice to be able to register hybrid handlers as:
// [[dplyr::handler(hitchhiker)]]
Result* hitchhiker_handler( SEXP, const LazySubsets&, int ){
return new Hitchhiker ;
}
See the hybrid evaluation vignette for context.
DataFrame::create(Named("a")=b, Named("b")=b)
fails with NumericVectors
inline SEXP get_last_call(){
SEXP sys_calls_symbol = Rf_install( "sys.calls" ) ;
Shield<SEXP> sys_calls_expr = Rf_lang1(sys_calls_symbol);
Shield<SEXP> calls = Rf_eval( sys_calls_expr, R_GlobalEnv ) ;
SEXP res = calls ;
while( !Rf_isNull(CDR(res)) ) res = CDR(res);
return CAR(res) ;
}
We can do this with contexts instead, e.g. rJava
does it
Can we use BH in Rcpp ?
This would give us a few things from boost we would no longer have to reinvent.
This would give us something better than RCPP_UNORDERED_MAP macro and all the dispatch it is involved with. We could just use boost::unordered_map instead
There is a lot of redundancy in proxy classes. There is room for genericity.
The TODO had:
Fast indexing and g++ 4.5.0 or later: open issue of why this compiler
gets upset when the previous version(s) coped just fine
Are we still using this fast indexing we mention there. Is this still an issue ?
many dpq functions have not been tested yet
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.