From noreply at r-forge.r-project.org Fri Feb 1 14:37:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 1 Feb 2013 14:37:58 +0100 (CET) Subject: [Rcpp-commits] r4228 - pkg/Rcpp Message-ID: <20130201133758.65B221842A8@r-forge.r-project.org> Author: romain Date: 2013-02-01 14:37:57 +0100 (Fri, 01 Feb 2013) New Revision: 4228 Modified: pkg/Rcpp/ChangeLog Log: changelog for commit 4171 Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-01-31 03:45:51 UTC (rev 4227) +++ pkg/Rcpp/ChangeLog 2013-02-01 13:37:57 UTC (rev 4228) @@ -80,6 +80,40 @@ * NAMESPACE : remove C++ObjectS3 and C++ClassRepresentation classes * R/00_classes.R: remove unused S4 classes + * src/internal.h: added Rcpp_PreserveObject, Rcpp_ReleaseObject and + Rcpp_ReplaceObject as replacements to R_ versions. The back end of the Rcpp_ + version is a list (generic vector) instead of a linked list and + is faster + * src/Module.cpp: more debugging + * src/barrier.cpp: added get_Rcpp_protection_stack used in the new + stack system for protecting/releasing objects in Rcpp + * src/api.cpp: implemetation of Rcpp_PreserveObject, Rcpp_ReleaseObject + and Rcpp_ReplaceObject. RObject::setSEXP now uses the new system. + The RObject(SEXP) constructor now directly uses Rcpp_PreserveObject + More debugging for the RObject class + Changes in api classes to better use the new protection system + * unitTests/cpp/language.cpp: hosting unit test in sourceCpp form + * unitTests/runit.Language.R: update unit tests + * unitTests/runit.Module.client.package.R: remove code that has been + commented for ages + * include/Rcpp/DottedPair.h: better use of the RObject constructor + * include/Rcpp/vector/Vector.h: better use of the RObject constructor + * include/Rcpp/vector/Matrix.h: Using update_matrix instead of the virtual + update which has been removed. + * include/Rcpp/Module.h : more careful about types and constructors + * include/Rcpp/XPtr.h: more debugging + * include/Rcpp/macros/debug.h: more debugging macros + * include/Rcpp/module/class_Base.h: using classes instead of SEXP + * include/Rcpp/module/class.h: using classes instead of SEXP + * include/Rcpp/generated/Language__ctors.h : using update_language_object + instead of the virtual update which has been removed. + * include/Rcpp/api/meat/Vector.h : using update_vector instead of the + virtual update that has been removed, more debugging + * include/Rcpp/api/meat/Matrix.h : more debugging, using update_matrix + instead of the virtual update which has been removed + * include/Rcpp/Language.h : added update_language_object to + replace update which was virtual + * include/Rcpp/RObject.h : only keep declarations here 2012-12-21 Dirk Eddelbuettel From noreply at r-forge.r-project.org Fri Feb 1 14:41:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 1 Feb 2013 14:41:50 +0100 (CET) Subject: [Rcpp-commits] r4229 - pkg/Rcpp/inst Message-ID: <20130201134150.A7D3F1842A8@r-forge.r-project.org> Author: romain Date: 2013-02-01 14:41:50 +0100 (Fri, 01 Feb 2013) New Revision: 4229 Modified: pkg/Rcpp/inst/NEWS.Rd Log: news for commit 4171 Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-02-01 13:37:57 UTC (rev 4228) +++ pkg/Rcpp/inst/NEWS.Rd 2013-02-01 13:41:50 UTC (rev 4229) @@ -23,6 +23,11 @@ } \item Changes in Rcpp API: \itemize{ + \item The very central use of R API R_PreserveObject and + R_ReleaseObject has been replaced by a new system based on the + functions Rcpp_PreserveObject, Rcpp_ReleaseObject and Rcpp_ReplaceObject + which shows better performance and is implemented using a generic vector + treated as a stack instead of a pairlist in the R implementation \item Platform-dependent code in Timer.cpp now recognises a few more BSD variants thanks to contributed defined() test suggestions } From noreply at r-forge.r-project.org Sat Feb 2 17:09:41 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 2 Feb 2013 17:09:41 +0100 (CET) Subject: [Rcpp-commits] r4230 - in pkg/Rcpp: . inst/include/Rcpp/internal inst/include/Rcpp/sugar inst/include/Rcpp/sugar/tools inst/include/Rcpp/vector inst/unitTests inst/unitTests/cpp src Message-ID: <20130202160942.09F8F183DDF@r-forge.r-project.org> Author: romain Date: 2013-02-02 17:09:41 +0100 (Sat, 02 Feb 2013) New Revision: 4230 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/internal/Proxy_Iterator.h pkg/Rcpp/inst/include/Rcpp/sugar/Range.h pkg/Rcpp/inst/include/Rcpp/sugar/tools/iterator.h pkg/Rcpp/inst/include/Rcpp/vector/MatrixBase.h pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h pkg/Rcpp/inst/unitTests/cpp/Vector.cpp pkg/Rcpp/inst/unitTests/runit.Vector.R pkg/Rcpp/src/api.cpp Log: correct operator++ and -- Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/ChangeLog 2013-02-02 16:09:41 UTC (rev 4230) @@ -1,3 +1,15 @@ +2013-02-02 Romain Francois + + * include/Rcpp/vector/MatrixRow.h: correct operator++(int) and operator--(int) + * include/Rcpp/internal/Proxy_Iterator.h: correct operators ++ and -- + * include/Rcpp/sugar/Range.h: correct operators ++ and -- + * include/Rcpp/sugar/tools/iterator.h: correct operators ++ and -- + * include/Rcpp/vector/MatrixBase.h : correct operators ++ and -- + * include/Rcpp/vector/VectorBase.h : correct operators ++ and -- + * unitTests/cpp/Vector.cpp: new unit tests + * unitTests/runit.Vector.R: new unit tests + * src/api.cpp: comment dropTrailing0 which is not used anymore + 2013-01-15 Dirk Eddelbuettel * src/api.cpp (Rcpp): Commented-out coerce_to_string() for real and Modified: pkg/Rcpp/inst/include/Rcpp/internal/Proxy_Iterator.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/Proxy_Iterator.h 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/inst/include/Rcpp/internal/Proxy_Iterator.h 2013-02-02 16:09:41 UTC (rev 4230) @@ -3,7 +3,7 @@ // // Proxy_Iterator.h: Rcpp R/C++ interface class library -- // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -48,18 +48,20 @@ proxy.move(1) ; return *this ; } - inline Proxy_Iterator& operator++(int){ - proxy.move(1) ; - return *this ; + inline Proxy_Iterator operator++(int){ + Proxy_Iterator orig(*this) ; + ++(*this) ; + return orig ; } inline Proxy_Iterator& operator--(){ proxy.move(-1) ; return *this ; } - inline Proxy_Iterator& operator--(int){ - proxy.move(-1) ; - return *this ; + inline Proxy_Iterator operator--(int){ + Proxy_Iterator orig(*this) ; + --(*this) ; + return orig ; } inline Proxy_Iterator operator+(difference_type n) const { Modified: pkg/Rcpp/inst/include/Rcpp/sugar/Range.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/Range.h 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/inst/include/Rcpp/sugar/Range.h 2013-02-02 16:09:41 UTC (rev 4230) @@ -2,7 +2,7 @@ // // Range.h: Rcpp R/C++ interface class library -- // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -44,18 +44,20 @@ start++ ; end_++ ; return *this ; } - Range& operator++(int) { - start++ ; end_++ ; - return *this ; + Range operator++(int) { + Range orig(*this) ; + ++(*this); + return orig ; } Range& operator--() { start-- ; end_-- ; return *this ; } - Range& operator--(int) { - start-- ; end_-- ; - return *this ; + Range operator--(int) { + Range orig(*this) ; + --(*this); + return orig ; } Range& operator+=(int n) { Modified: pkg/Rcpp/inst/include/Rcpp/sugar/tools/iterator.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/tools/iterator.h 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/inst/include/Rcpp/sugar/tools/iterator.h 2013-02-02 16:09:41 UTC (rev 4230) @@ -2,7 +2,7 @@ // // iterator.h: Rcpp R/C++ interface class library -- // -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -42,9 +42,17 @@ SugarIterator( const SugarIterator& other) : ref(other.ref), index(other.index){} inline iterator& operator++(){ index++; return *this ; } - inline iterator& operator++(int){ index++; return *this ; } + inline iterator operator++(int){ + iterator orig(*this) ; + ++(*this); + return orig ; + } inline iterator& operator--(){ index--; return *this ; } - inline iterator& operator--(int){ index--; return *this ; } + inline iterator operator--(int){ + iterator orig(*this) ; + --(*this); + return orig ; + } inline iterator operator+(difference_type n) const { return iterator( ref, index+n ) ; } Modified: pkg/Rcpp/inst/include/Rcpp/vector/MatrixBase.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/MatrixBase.h 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/inst/include/Rcpp/vector/MatrixBase.h 2013-02-02 16:09:41 UTC (rev 4230) @@ -2,7 +2,7 @@ // // MatrixBase.h: Rcpp R/C++ interface class library -- // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -72,13 +72,10 @@ } return *this ; } - inline iterator& operator++(int){ - i++ ; - if( i == nr ){ - j++ ; - i=0 ; - } - return *this ; + inline iterator operator++(int){ + iterator orig(*this) ; + ++(*this) ; + return orig ; } inline iterator& operator--(){ @@ -89,13 +86,10 @@ } return *this ; } - inline iterator& operator--(int){ - i-- ; - if( i == -1 ){ - j-- ; - i = nr - 1 ; - } - return *this ; + inline iterator operator--(int){ + iterator orig(*this) ; + --(*this) ; + return orig ; } inline iterator operator+(difference_type n) const { @@ -115,9 +109,6 @@ } inline reference operator*() { - // TODO: it might be better to call object( i, j ) - // as in many cases the sugar expression - // is faster with two indexes return object(i,j) ; } inline pointer operator->(){ Modified: pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h 2013-02-02 16:09:41 UTC (rev 4230) @@ -2,7 +2,7 @@ // // MatrixRow.h: Rcpp R/C++ interface class library -- matrices row // -// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -40,25 +40,28 @@ typedef typename std::iterator_traits::pointer pointer ; typedef std::random_access_iterator_tag iterator_category ; - + + iterator( const iterator& other) : row(other.row), index(other.index){} iterator( MatrixRow& row_, int index_ ) : row(row_), index(index_){} iterator& operator++(){ index++; return *this ; } - iterator& operator++(int) { - index++; - return *this ; + iterator operator++(int) { + iterator orig(*this); + index++ ; + return orig ; } iterator& operator--(){ index-- ; return *this ; } - iterator& operator--(int){ + iterator operator--(int){ + iterator orig(*this); index-- ; - return *this ; + return orig ; } iterator operator+(difference_type n) const { return iterator( row, index + n ) ; } Modified: pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h 2013-02-02 16:09:41 UTC (rev 4230) @@ -2,7 +2,7 @@ // // VectorBase.h: Rcpp R/C++ interface class library -- // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -63,18 +63,20 @@ index++ ; return *this ; } - inline iterator& operator++(int){ - index++; - return *this ; + inline iterator operator++(int){ + iterator orig(*this); + ++(*this) ; + return orig ; } inline iterator& operator--(){ index-- ; return *this ; } - inline iterator& operator--(int){ - index--; - return *this ; + inline iterator operator--(int){ + iterator orig(*this); + --(*this) ; + return orig ; } inline iterator operator+(difference_type n) const { Modified: pkg/Rcpp/inst/unitTests/cpp/Vector.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/Vector.cpp 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/inst/unitTests/cpp/Vector.cpp 2013-02-02 16:09:41 UTC (rev 4230) @@ -2,7 +2,7 @@ // // Vector.cpp: Rcpp R/C++ interface class library -- Vector unit tests // -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -456,6 +456,32 @@ } // [[Rcpp::export]] +CharacterVector character_matrix_row_iteration_incr( CharacterMatrix m ){ + std::string pasted_row; + CharacterMatrix::Row row(m(1, _)); + CharacterMatrix::Row::iterator i_row(row.begin()); + for( size_t i=0 ; i<4; i++){ + pasted_row += *i_row++; + } + return wrap( pasted_row ) ; +} + +// [[Rcpp::export]] +CharacterVector character_matrix_row_iteration_decr( CharacterMatrix m ){ + std::string pasted_row; + CharacterMatrix::Row row(m(1, _)); + CharacterMatrix::Row::iterator i_row(row.end()); + i_row--; // Step back from 'one past the end' to 'last element'. + // Only copy the last three elements, to avoid creating an invalid + // 'one before the beginning' iterator: + for( size_t i=0 ; i<3; i++){ + pasted_row += *i_row--; + } + return wrap( pasted_row ) ; +} + + +// [[Rcpp::export]] CharacterVector character_assign1(){ const char* x[] = { "foo", "bar", "bling", "boom" } ; CharacterVector y ; Modified: pkg/Rcpp/inst/unitTests/runit.Vector.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.Vector.R 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/inst/unitTests/runit.Vector.R 2013-02-02 16:09:41 UTC (rev 4230) @@ -1,7 +1,7 @@ #!/usr/bin/r -t # hey emacs, please make this use -*- tab-width: 4 -*- # -# Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -426,6 +426,16 @@ checkEquals( diag(fun(x)), rep("foo", 4) , msg = "matrix indexing lhs" ) } +test.CharacterVector.matrix.row.iteration <- function() { + x <- matrix(letters[1:16], nrow = 4) + + fun <- character_matrix_row_iteration_incr + checkEquals( fun(x), "bfjn", msg = "matrix row iteration post-incr" ) + + fun <- character_matrix_row_iteration_decr + checkEquals( fun(x), "njf", msg = "matrix row iteration post-decr" ) +} + test.CharacterVector.assign <- function(){ fun <- character_assign1 checkEquals( fun(), c("foo", "bar", "bling", "boom"), msg = "assign(char**, char**)" ) Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-02-01 13:41:50 UTC (rev 4229) +++ pkg/Rcpp/src/api.cpp 2013-02-02 16:09:41 UTC (rev 4230) @@ -1655,23 +1655,23 @@ } -static const char* dropTrailing0(char *s, char cdec) { - /* Note that 's' is modified */ - char *p = s; - for (p = s; *p; p++) { - if(*p == cdec) { - char *replace = p++; - while ('0' <= *p && *p <= '9') - if(*(p++) != '0') - replace = p; - if(replace != p) - while((*(replace++) = *(p++))) - ; - break; - } - } - return s; -} +// static const char* dropTrailing0(char *s, char cdec) { +// /* Note that 's' is modified */ +// char *p = s; +// for (p = s; *p; p++) { +// if(*p == cdec) { +// char *replace = p++; +// while ('0' <= *p && *p <= '9') +// if(*(p++) != '0') +// replace = p; +// if(replace != p) +// while((*(replace++) = *(p++))) +// ; +// break; +// } +// } +// return s; +// } // template <> const char* coerce_to_string(double x){ // int w,d,e ; From noreply at r-forge.r-project.org Sat Feb 2 17:17:21 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 2 Feb 2013 17:17:21 +0100 (CET) Subject: [Rcpp-commits] r4231 - pkg/Rcpp/inst/include/Rcpp Message-ID: <20130202161721.ADC5A183DDF@r-forge.r-project.org> Author: romain Date: 2013-02-02 17:17:21 +0100 (Sat, 02 Feb 2013) New Revision: 4231 Modified: pkg/Rcpp/inst/include/Rcpp/String.h Log: add Rice University copyright for 2012 Modified: pkg/Rcpp/inst/include/Rcpp/String.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/String.h 2013-02-02 16:09:41 UTC (rev 4230) +++ pkg/Rcpp/inst/include/Rcpp/String.h 2013-02-02 16:17:21 UTC (rev 4231) @@ -3,6 +3,7 @@ // String.h: Rcpp R/C++ interface class library -- single string // // Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 Rice University // // This file is part of Rcpp. // From noreply at r-forge.r-project.org Sat Feb 2 17:44:13 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 2 Feb 2013 17:44:13 +0100 (CET) Subject: [Rcpp-commits] r4232 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/traits Message-ID: <20130202164413.4ECBC183DDF@r-forge.r-project.org> Author: romain Date: 2013-02-02 17:44:13 +0100 (Sat, 02 Feb 2013) New Revision: 4232 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/as.h pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h Log: support for as Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-02 16:17:21 UTC (rev 4231) +++ pkg/Rcpp/ChangeLog 2013-02-02 16:44:13 UTC (rev 4232) @@ -8,7 +8,8 @@ * include/Rcpp/vector/VectorBase.h : correct operators ++ and -- * unitTests/cpp/Vector.cpp: new unit tests * unitTests/runit.Vector.R: new unit tests - * src/api.cpp: comment dropTrailing0 which is not used anymore + * src/api.cpp: comment dropTrailing0 which is not used anymore + * include/Rcpp/as.h: support for as 2013-01-15 Dirk Eddelbuettel Modified: pkg/Rcpp/inst/include/Rcpp/as.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/as.h 2013-02-02 16:17:21 UTC (rev 4231) +++ pkg/Rcpp/inst/include/Rcpp/as.h 2013-02-02 16:44:13 UTC (rev 4232) @@ -2,7 +2,8 @@ // // as.h: Rcpp R/C++ interface class library -- convert SEXP to C++ objects // -// Copyright (C) 2009 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2013 Rice University // // This file is part of Rcpp. // @@ -43,15 +44,23 @@ } template T as(SEXP x, ::Rcpp::traits::r_type_string_tag ) { - if( ! ::Rf_isString(x) ){ + if( ! ::Rf_isString(x) ) throw ::Rcpp::not_compatible( "expecting a string" ) ; - } - if (Rf_length(x) != 1) { + if (Rf_length(x) != 1) throw ::Rcpp::not_compatible( "expecting a single value"); - } return T( CHAR( STRING_ELT( ::Rcpp::r_cast(x) ,0 ) ) ) ; } + template T as(SEXP x, ::Rcpp::traits::r_type_wstring_tag ) { + if( ! ::Rf_isString(x) ) + throw ::Rcpp::not_compatible( "expecting a string" ) ; + if (Rf_length(x) != 1) + throw ::Rcpp::not_compatible( "expecting a single value"); + const char* y = CHAR( STRING_ELT( ::Rcpp::r_cast(x) ,0 ) ) ; + // TODO: deal about encoding + return std::wstring( y, y+strlen(y)) ; + } + template T as(SEXP x, ::Rcpp::traits::r_type_RcppString_tag ) { if( ! ::Rf_isString(x) ){ throw ::Rcpp::not_compatible( "expecting a string" ) ; Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2013-02-02 16:17:21 UTC (rev 4231) +++ pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2013-02-02 16:44:13 UTC (rev 4232) @@ -3,7 +3,8 @@ // // r_type_traits.h: Rcpp R/C++ interface class library -- traits to help wrap // -// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2013 Rice University // // This file is part of Rcpp. // @@ -39,6 +40,12 @@ struct r_type_string_tag{} ; /** + * Identifies that the associated type can be implicitely converted + * to a std::wstring + */ +struct r_type_wstring_tag{} ; + +/** * Default */ struct r_type_generic_tag{} ; @@ -110,11 +117,14 @@ template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; +template<> struct r_type_traits{ typedef r_type_wstring_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; +template<> struct r_type_traits{ typedef r_type_wstring_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; +template<> struct r_type_traits{ typedef r_type_wstring_tag r_category ; } ; /* long */ template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; From noreply at r-forge.r-project.org Sat Feb 2 21:06:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 2 Feb 2013 21:06:04 +0100 (CET) Subject: [Rcpp-commits] r4233 - in pkg/RcppEigen: . inst man Message-ID: <20130202200604.B3375184BAE@r-forge.r-project.org> Author: edd Date: 2013-02-02 21:06:04 +0100 (Sat, 02 Feb 2013) New Revision: 4233 Added: pkg/RcppEigen/inst/CITATION Modified: pkg/RcppEigen/ChangeLog pkg/RcppEigen/man/RcppEigen-package.Rd pkg/RcppEigen/man/fastLm.Rd Log: reversed commit 4223 Modified: pkg/RcppEigen/ChangeLog =================================================================== --- pkg/RcppEigen/ChangeLog 2013-02-02 16:44:13 UTC (rev 4232) +++ pkg/RcppEigen/ChangeLog 2013-02-02 20:06:04 UTC (rev 4233) @@ -3,11 +3,6 @@ * vignettes/jss835/: Regroup all related files in this directory * .Rbuildignore: Ignore vignettes/jss835 -2013-01-24 Douglas Bates - - * man/RcppEigen-package.Rd, man/fastlm.Rd, DESCRIPTION: Remove - references to JSS paper - 2013-01-14 Dirk Eddelbuettel * inst/CITATION: Added as provided by JSS editor Copied: pkg/RcppEigen/inst/CITATION (from rev 4222, pkg/RcppEigen/inst/CITATION) =================================================================== --- pkg/RcppEigen/inst/CITATION (rev 0) +++ pkg/RcppEigen/inst/CITATION 2013-02-02 20:06:04 UTC (rev 4233) @@ -0,0 +1,19 @@ +citHeader("To cite RcppEigen in publications use:") + +citEntry(entry = "Article", + title = "Fast and Elegant Numerical Linear Algebra Using the {RcppEigen} Package", + author = personList(as.person("Douglas Bates"), + as.person("Dirk Eddelbuettel")), + journal = "Journal of Statistical Software", + year = "2013", + volume = "52", + number = "5", + pages = "1--24", + url = "http://www.jstatsoft.org/v52/i05/", + + textVersion = + paste("Douglas Bates, Dirk Eddelbuettel (2013).", + "Fast and Elegant Numerical Linear Algebra Using the RcppEigen Package.", + "Journal of Statistical Software, 52(5), 1-24.", + "URL http://www.jstatsoft.org/v52/i05/.") +) Modified: pkg/RcppEigen/man/RcppEigen-package.Rd =================================================================== --- pkg/RcppEigen/man/RcppEigen-package.Rd 2013-02-02 16:44:13 UTC (rev 4232) +++ pkg/RcppEigen/man/RcppEigen-package.Rd 2013-02-02 20:06:04 UTC (rev 4233) @@ -20,4 +20,10 @@ \url{http://eigen.tuxfamily.org}, Eigen is a versatile, fast, reliable and elegant collection of C++ classes for linear algebra. } +\references{ + Douglas Bates and Dirk Eddelbuettel (2013). Fast and Elegant Numerical + Linear Algebra Using the \pkg{RcppEigen} Package. \emph{Journal of + Statistical Software}, \bold{52(5)}, 1-24. + URL http://www.jstatsoft.org/v52/i05/. +} \keyword{ package } Modified: pkg/RcppEigen/man/fastLm.Rd =================================================================== --- pkg/RcppEigen/man/fastLm.Rd 2013-02-02 16:44:13 UTC (rev 4232) +++ pkg/RcppEigen/man/fastLm.Rd 2013-02-02 20:06:04 UTC (rev 4233) @@ -83,6 +83,12 @@ \code{\link[MASS]{rlm}} functions.. } \seealso{\code{\link{lm}}, \code{\link{lm.fit}}} +\references{ + Douglas Bates and Dirk Eddelbuettel (2013). Fast and Elegant Numerical + Linear Algebra Using the \pkg{RcppEigen} Package. \emph{Journal of + Statistical Software}, \bold{52(5)}, 1-24. + URL http://www.jstatsoft.org/v52/i05/. +} \author{ Eigen is described at \url{http://eigen.tuxfamily.org}. RcppEigen is written by Douglas Bates, Dirk Eddelbuettel and Romain Francois. From noreply at r-forge.r-project.org Sun Feb 3 12:19:09 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 3 Feb 2013 12:19:09 +0100 (CET) Subject: [Rcpp-commits] r4234 - in pkg/Rcpp: . inst/include inst/include/Rcpp/internal inst/include/Rcpp/traits src Message-ID: <20130203111909.ACC4B1848C1@r-forge.r-project.org> Author: romain Date: 2013-02-03 12:19:09 +0100 (Sun, 03 Feb 2013) New Revision: 4234 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/internal/export.h pkg/Rcpp/inst/include/Rcpp/internal/wrap.h pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h pkg/Rcpp/inst/include/RcppCommon.h pkg/Rcpp/src/api.cpp Log: support for wrap( wstring ) and wrap( container of wstring ) Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-02 20:06:04 UTC (rev 4233) +++ pkg/Rcpp/ChangeLog 2013-02-03 11:19:09 UTC (rev 4234) @@ -1,3 +1,11 @@ +2013-02-03 Romain Francois + + * include/Rcpp/traits/wrap_type_traits.h : support for wrap( wstring ) + * include/Rcpp/internal/export.h : exporting wstring and containers of wstring + * include/Rcpp/internal/wrap.h : support for wrap( wstring ) and containers of wstring + * include/RcppCommon.h : definition of charsexp_from_wstring + * src/api.cpp: implementation of charsexp_from_wstring + 2013-02-02 Romain Francois * include/Rcpp/vector/MatrixRow.h: correct operator++(int) and operator--(int) @@ -10,6 +18,7 @@ * unitTests/runit.Vector.R: new unit tests * src/api.cpp: comment dropTrailing0 which is not used anymore * include/Rcpp/as.h: support for as + * include/Rcpp/internal/export.h: more support for wstring 2013-01-15 Dirk Eddelbuettel Modified: pkg/Rcpp/inst/include/Rcpp/internal/export.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/export.h 2013-02-02 20:06:04 UTC (rev 4233) +++ pkg/Rcpp/inst/include/Rcpp/internal/export.h 2013-02-03 11:19:09 UTC (rev 4234) @@ -3,7 +3,8 @@ // // export.h: Rcpp R/C++ interface class library -- // -// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2013 Rice University // // This file is part of Rcpp. // @@ -29,107 +30,130 @@ /* iterating */ template - void export_range__impl( SEXP x, InputIterator first, ::Rcpp::traits::false_type ) { - const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype ; - typedef typename ::Rcpp::traits::storage_type::type STORAGE ; - SEXP y = PROTECT( ::Rcpp::r_cast(x) ) ; - STORAGE* start = ::Rcpp::internal::r_vector_start(y) ; - std::copy( start, start + ::Rf_length(y), first ) ; - UNPROTECT(1) ; + void export_range__impl( SEXP x, InputIterator first, ::Rcpp::traits::false_type ) { + const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype ; + typedef typename ::Rcpp::traits::storage_type::type STORAGE ; + SEXP y = PROTECT( ::Rcpp::r_cast(x) ) ; + STORAGE* start = ::Rcpp::internal::r_vector_start(y) ; + std::copy( start, start + ::Rf_length(y), first ) ; + UNPROTECT(1) ; } template void export_range__impl( SEXP x, InputIterator first, ::Rcpp::traits::true_type ) { - const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype ; - typedef typename ::Rcpp::traits::storage_type::type STORAGE ; - SEXP y = PROTECT( ::Rcpp::r_cast(x) ) ; - STORAGE* start = ::Rcpp::internal::r_vector_start(y) ; - std::transform( start, start + ::Rf_length(y) , first, caster ) ; - UNPROTECT(1) ; + const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype ; + typedef typename ::Rcpp::traits::storage_type::type STORAGE ; + SEXP y = PROTECT( ::Rcpp::r_cast(x) ) ; + STORAGE* start = ::Rcpp::internal::r_vector_start(y) ; + std::transform( start, start + ::Rf_length(y) , first, caster ) ; + UNPROTECT(1) ; } template void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_primitive_tag ) { - export_range__impl( - x, - first, - typename ::Rcpp::traits::r_sexptype_needscast() ); - } + export_range__impl( + x, + first, + typename ::Rcpp::traits::r_sexptype_needscast() + ); + } - template - void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_string_tag ) { - if( ! ::Rf_isString( x) ) throw ::Rcpp::not_compatible( "expecting a string vector" ) ; - std::string buf ; - R_len_t n = ::Rf_length(x) ; - for( R_len_t i=0; i + void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_string_tag ) { + if( ! ::Rf_isString( x) ) throw ::Rcpp::not_compatible( "expecting a string vector" ) ; + R_len_t n = ::Rf_length(x) ; + for( R_len_t i=0; i - void export_range( SEXP x, InputIterator first ) { - export_range__dispatch::value_type>( - x, - first, - typename ::Rcpp::traits::r_type_traits::value_type>::r_category() - ); - } + // InputIterator is an iterator over std::wstring + template + void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_wstring_tag ) { + if( ! ::Rf_isString( x) ) throw ::Rcpp::not_compatible( "expecting a string vector" ) ; + R_len_t n = ::Rf_length(x) ; + for( R_len_t i=0; i + void export_range( SEXP x, InputIterator first ) { + export_range__dispatch::value_type>( + x, + first, + typename ::Rcpp::traits::r_type_traits::value_type>::r_category() + ); + } + /* indexing */ - template - void export_indexing__impl( SEXP x, T& res, ::Rcpp::traits::false_type ) { - const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype ; - typedef typename ::Rcpp::traits::storage_type::type STORAGE ; - SEXP y = PROTECT( ::Rcpp::r_cast(x) ) ; - STORAGE* start = ::Rcpp::internal::r_vector_start(y) ; - R_len_t size = ::Rf_length(y) ; - for( R_len_t i=0; i + void export_indexing__impl( SEXP x, T& res, ::Rcpp::traits::false_type ) { + const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype ; + typedef typename ::Rcpp::traits::storage_type::type STORAGE ; + SEXP y = PROTECT( ::Rcpp::r_cast(x) ) ; + STORAGE* start = ::Rcpp::internal::r_vector_start(y) ; + R_len_t size = ::Rf_length(y) ; + for( R_len_t i=0; i - void export_indexing__impl( SEXP x, T& res, ::Rcpp::traits::true_type ) { - const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype ; - typedef typename ::Rcpp::traits::storage_type::type STORAGE ; - SEXP y = PROTECT( ::Rcpp::r_cast(x) ) ; - STORAGE* start = ::Rcpp::internal::r_vector_start(y) ; - R_len_t size = ::Rf_length(y) ; - for( R_len_t i=0; i(start[i]) ; - } - UNPROTECT(1) ; /* y */ - } + template + void export_indexing__impl( SEXP x, T& res, ::Rcpp::traits::true_type ) { + const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype ; + typedef typename ::Rcpp::traits::storage_type::type STORAGE ; + SEXP y = PROTECT( ::Rcpp::r_cast(x) ) ; + STORAGE* start = ::Rcpp::internal::r_vector_start(y) ; + R_len_t size = ::Rf_length(y) ; + for( R_len_t i=0; i(start[i]) ; + } + UNPROTECT(1) ; /* y */ + } - template - void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_primitive_tag ) { - export_indexing__impl( - x, - res, - typename ::Rcpp::traits::r_sexptype_needscast() ); - } + template + void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_primitive_tag ) { + export_indexing__impl( + x, + res, + typename ::Rcpp::traits::r_sexptype_needscast() + ); + } - template - void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_string_tag ) { - if( ! ::Rf_isString( x) ) throw Rcpp::not_compatible( "expecting a string vector" ) ; - std::string buf ; - R_len_t n = ::Rf_length(x) ; - for( R_len_t i=0; i + void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_string_tag ) { + if( ! ::Rf_isString( x) ) throw Rcpp::not_compatible( "expecting a string vector" ) ; + R_len_t n = ::Rf_length(x) ; + for( R_len_t i=0; i - void export_indexing( SEXP x, T& res ) { - export_indexing__dispatch( - x, - res, - typename ::Rcpp::traits::r_type_traits::r_category() ); - } + // T is an array of wstring + template + void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_wstring_tag ) { + if( ! ::Rf_isString( x) ) throw Rcpp::not_compatible( "expecting a string vector" ) ; + R_len_t n = ::Rf_length(x) ; + for( R_len_t i=0; i + void export_indexing( SEXP x, T& res ) { + export_indexing__dispatch( + x, + res, + typename ::Rcpp::traits::r_type_traits::r_category() + ); + } + } } Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-02 20:06:04 UTC (rev 4233) +++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-03 11:19:09 UTC (rev 4234) @@ -3,7 +3,8 @@ // // wrap.h: Rcpp R/C++ interface class library -- wrap implementations // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2013 Rice University // // This file is part of Rcpp. // @@ -172,6 +173,28 @@ UNPROTECT(1) ; return x ; } + +/** + * Range based wrap implementation for iterators over std::wstring + * + * This produces an unnamed character vector + */ +template +inline SEXP range_wrap_dispatch___impl( InputIterator first, InputIterator last, ::Rcpp::traits::r_type_wstring_tag ){ + size_t size = std::distance( first, last ) ; + SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ) ; + size_t i = 0 ; + std::wstring buffer ; + while( i < size ){ + buffer = *first ; + SET_STRING_ELT( x, i, charsexp_from_wstring(buffer) ) ; + i++ ; + ++first ; + } + UNPROTECT(1) ; + return x ; +} + // }}} // {{{ named range wrap @@ -386,8 +409,22 @@ UNPROTECT(1) ; return x; } +/** + * primitive wrap for types that can be converted implicitely to std::wstring + * + * This produces a character vector of length 1 containing the std::wstring + */ +template +inline SEXP primitive_wrap__impl( const T& object, ::Rcpp::traits::r_type_wstring_tag){ + SEXP x = PROTECT( ::Rf_allocVector( STRSXP, 1) ) ; + SET_STRING_ELT( x, 0, charsexp_from_wstring(object) ) ; + UNPROTECT(1) ; + return x; +} + + /** * called when T is a primitive type : int, bool, double, std::string, etc ... * This uses the Rcpp::traits::r_type_traits on the type T to perform @@ -515,7 +552,25 @@ UNPROTECT(2) ; return res ; } +template +inline SEXP wrap_dispatch_matrix_not_logical( const T& object, ::Rcpp::traits::r_type_wstring_tag ){ + int nr = object.nrow(), nc = object.ncol() ; + SEXP res = PROTECT( Rf_allocVector( STRSXP, nr*nc ) ) ; + + int k=0 ; + for( int j=0; j inline SEXP wrap_dispatch_matrix_not_logical( const T& object, ::Rcpp::traits::r_type_generic_tag ){ int nr = object.nrow(), nc = object.ncol() ; @@ -609,6 +664,18 @@ UNPROTECT(1) ; return x ; } +template +inline SEXP wrap_dispatch_importer__impl( const T& object, ::Rcpp::traits::r_type_wstring_tag ){ + int size = object.size() ; + SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ); + std::wstring buf ; + for( int i=0; i inline SEXP wrap_dispatch_importer__impl( const T& object, ::Rcpp::traits::r_type_generic_tag ){ @@ -740,6 +807,24 @@ UNPROTECT(2); /* out, dims */ return out ; } +template +inline SEXP rowmajor_wrap__dispatch( InputIterator first, int nrow, int ncol, ::Rcpp::traits::r_type_wstring_tag ){ + SEXP out = PROTECT( ::Rf_allocVector( STRSXP, nrow * ncol) ); + int i=0, j=0 ; + std::wstring buffer ; + for( j=0; j inline SEXP primitive_rowmajor_wrap__dispatch( InputIterator first, int nrow, int ncol, ::Rcpp::traits::false_type ){ @@ -804,6 +889,7 @@ */ template inline SEXP wrap(const T& object){ + RCPP_DEBUG_1( "inline SEXP wrap<%s>(const T& object)", DEMANGLE(T) ) return internal::wrap_dispatch( object, typename ::Rcpp::traits::wrap_type_traits::wrap_category() ) ; } Modified: pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h 2013-02-02 20:06:04 UTC (rev 4233) +++ pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h 2013-02-03 11:19:09 UTC (rev 4234) @@ -3,7 +3,7 @@ // // wrap_type_traits.h: Rcpp R/C++ interface class library -- traits to help wrap // -// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -74,8 +74,10 @@ template <> struct wrap_type_traits { typedef wrap_type_primitive_tag wrap_category; } ; template <> struct wrap_type_traits { typedef wrap_type_primitive_tag wrap_category; } ; template <> struct wrap_type_traits { typedef wrap_type_primitive_tag wrap_category; } ; +template <> struct wrap_type_traits { typedef wrap_type_primitive_tag wrap_category; } ; template <> struct wrap_type_traits { typedef wrap_type_primitive_tag wrap_category; } ; template <> struct wrap_type_traits { typedef wrap_type_primitive_tag wrap_category; } ; +template <> struct wrap_type_traits { typedef wrap_type_primitive_tag wrap_category; } ; template <> struct wrap_type_traits { typedef wrap_type_primitive_tag wrap_category; } ; template <> struct wrap_type_traits< std::complex > { typedef wrap_type_primitive_tag wrap_category; } ; Modified: pkg/Rcpp/inst/include/RcppCommon.h =================================================================== --- pkg/Rcpp/inst/include/RcppCommon.h 2013-02-02 20:06:04 UTC (rev 4233) +++ pkg/Rcpp/inst/include/RcppCommon.h 2013-02-03 11:19:09 UTC (rev 4234) @@ -3,7 +3,7 @@ // RcppCommon.h: Rcpp R/C++ interface class library -- common include and defines statements // // Copyright (C) 2008 - 2009 Dirk Eddelbuettel -// Copyright (C) 2009 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -30,6 +30,7 @@ #include // include R headers, but set R_NO_REMAP and access everything via Rf_ prefixes +#define MAXELTSIZE 8192 #define R_NO_REMAP #include #include @@ -89,6 +90,8 @@ class String ; namespace internal{ template SEXP make_new_object( Class* ptr ) ; + + SEXP charsexp_from_wstring( const std::wstring& s) ; } } Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-02-02 20:06:04 UTC (rev 4233) +++ pkg/Rcpp/src/api.cpp 2013-02-03 11:19:09 UTC (rev 4234) @@ -3,7 +3,7 @@ // // api.cpp: Rcpp R/C++ interface class library -- Rcpp api // -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -1654,6 +1654,11 @@ return buff ; } +SEXP charsexp_from_wstring( const std::wstring& s){ + static char buffer[MAXELTSIZE]; + wcstombs( buffer, s.data(), MAXELTSIZE ) ; + return Rf_mkChar(buffer) ; +} // static const char* dropTrailing0(char *s, char cdec) { // /* Note that 's' is modified */ From noreply at r-forge.r-project.org Sun Feb 3 14:33:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 3 Feb 2013 14:33:37 +0100 (CET) Subject: [Rcpp-commits] r4235 - pkg/RcppEigen Message-ID: <20130203133337.24A63181205@r-forge.r-project.org> Author: edd Date: 2013-02-03 14:33:36 +0100 (Sun, 03 Feb 2013) New Revision: 4235 Modified: pkg/RcppEigen/ChangeLog pkg/RcppEigen/NEWS pkg/RcppEigen/NEWS.org Log: Update ChangeLog and NEWS for release requested by Achim Modified: pkg/RcppEigen/ChangeLog =================================================================== --- pkg/RcppEigen/ChangeLog 2013-02-03 11:19:09 UTC (rev 4234) +++ pkg/RcppEigen/ChangeLog 2013-02-03 13:33:36 UTC (rev 4235) @@ -1,3 +1,9 @@ +2013-02-03 Dirk Eddelbuettel + + * DESCRIPTION: New minor version 0.3.1.2.1 for upload to CRAN and JSS + + * NEWS.org: Updated + 2013-01-26 Dirk Eddelbuettel * vignettes/jss835/: Regroup all related files in this directory Modified: pkg/RcppEigen/NEWS =================================================================== --- pkg/RcppEigen/NEWS 2013-02-03 11:19:09 UTC (rev 4234) +++ pkg/RcppEigen/NEWS 2013-02-03 13:33:36 UTC (rev 4235) @@ -2,18 +2,33 @@ ======================== Author: Douglas Bates -Date: 2012-06-26 Tue +Date: 2013-02-02 Sun Table of Contents ================= -1 New features visible to users -2 New features visible to users in RcppEigen-0.2.0 -3 New features not visible to users in RcppEigen-0.2.0 +1 New features visible to users in RcppEigen-0.3.1.2 +2 New features visible to users in RcppEigen-0.3.1 +3 New features visible to users in RcppEigen-0.2.0 +4 New features not visible to users in RcppEigen-0.2.0 -1 New features visible to users --------------------------------- +1 New features visible to users in RcppEigen-0.3.1.2 +----------------------------------------------------- + + Upgraded to Eigen 3.1.2 + + Fixes to RcppEigenWrap.h and adjustment of tests accordingly. + The changes allow RowMajor matrices to be wrapped (thanks to Gael + Guennebaud) but cannot handle RowVector types. There will need to be + more template metaprogramming done to redirect the case of RowVector, + which cannot be changed to a ColMajor form. + + Because of changes in R, -DNDEBUG is automatic. One must override it with + -UNDEBUG in the local ~/.R/Makevars to activate the debugging code. + + New (unexported) functions CxxFlags() and RcppEigenCxxFlags() for use in + Makefiles + + Fixes related to Rcpp 0.10.* + +2 New features visible to users in RcppEigen-0.3.1 +--------------------------------------------------- + Upgraded to Eigen 3.1.0 + Removed the "unsupported" Eigen module AutoDiff which defined a macro "sign" that conflicted with a function in the R API (which @@ -24,7 +39,7 @@ conflicting definitions in the std:: namespace and the R API and Eigen, which I don't have time to investigate. -2 New features visible to users in RcppEigen-0.2.0 +3 New features visible to users in RcppEigen-0.2.0 --------------------------------------------------- + Upgraded the version of Eigen to 3.1.0-alpha2, in which the sparse matrix modules are now in the "supported" tree. @@ -51,7 +66,7 @@ + The ability to wrap RowMajor sparse matrices and to use as etc. -3 New features not visible to users in RcppEigen-0.2.0 +4 New features not visible to users in RcppEigen-0.2.0 ------------------------------------------------------- + Migrated some tests to the testthat package. Currently there is some difficulty with combining testthat, inline and R CMD check. Modified: pkg/RcppEigen/NEWS.org =================================================================== --- pkg/RcppEigen/NEWS.org 2013-02-03 11:19:09 UTC (rev 4234) +++ pkg/RcppEigen/NEWS.org 2013-02-03 13:33:36 UTC (rev 4235) @@ -1,12 +1,25 @@ #+TITLE: NEWS for RcppEigen-0.3.0 #+AUTHOR: Douglas Bates #+EMAIL: bates at stat.wisc.edu -#+DATE: 2012-06-26 Tue +#+DATE: 2013-02-02 Sun #+DESCRIPTION: News regarding the latest version of RcppEigen #+KEYWORDS: #+LANGUAGE: en -* New features visible to users +* New features visible to users in RcppEigen-0.3.1.2 + + Upgraded to Eigen 3.1.2 + + Fixes to RcppEigenWrap.h and adjustment of tests accordingly. + The changes allow RowMajor matrices to be wrapped (thanks to Gael + Guennebaud) but cannot handle RowVector types. There will need to be + more template metaprogramming done to redirect the case of RowVector, + which cannot be changed to a ColMajor form. + + Because of changes in R, -DNDEBUG is automatic. One must override it with + -UNDEBUG in the local ~/.R/Makevars to activate the debugging code. + + New (unexported) functions CxxFlags() and RcppEigenCxxFlags() for use in + Makefiles + + Fixes related to Rcpp 0.10.* + +* New features visible to users in RcppEigen-0.3.1 + Upgraded to Eigen 3.1.0 + Removed the "unsupported" Eigen module AutoDiff which defined a macro "sign" that conflicted with a function in the R API (which From noreply at r-forge.r-project.org Mon Feb 4 12:36:27 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 12:36:27 +0100 (CET) Subject: [Rcpp-commits] r4236 - in pkg/Rcpp: . inst/include inst/include/Rcpp/internal inst/include/Rcpp/traits src Message-ID: <20130204113627.A805F183C62@r-forge.r-project.org> Author: romain Date: 2013-02-04 12:36:27 +0100 (Mon, 04 Feb 2013) New Revision: 4236 Added: pkg/Rcpp/inst/include/Rcpp/traits/is_wide_string.h Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/internal/wrap.h pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h pkg/Rcpp/inst/include/Rcpp/traits/traits.h pkg/Rcpp/inst/include/RcppCommon.h pkg/Rcpp/src/api.cpp Log: move some logic about making CHARSXP to lower level to help more generic code Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-03 13:33:36 UTC (rev 4235) +++ pkg/Rcpp/ChangeLog 2013-02-04 11:36:27 UTC (rev 4236) @@ -1,3 +1,10 @@ +2013-02-04 Romain Francois + + * include/Rcpp/traits/r_type_traits.h : added the r_type_pairstring_wstring_tag tag + that is used to detect iterators over pair + * include/Rcpp/internal/wrap.h : using make_charsexp, a more generic version + of charsexp_from_wstring. + 2013-02-03 Romain Francois * include/Rcpp/traits/wrap_type_traits.h : support for wrap( wstring ) Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-03 13:33:36 UTC (rev 4235) +++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-04 11:36:27 UTC (rev 4236) @@ -40,6 +40,38 @@ namespace internal{ + char* get_string_buffer() ; + + inline SEXP make_charsexp__impl__wstring( const wchar_t* data ){ + char* buffer = get_string_buffer() ; + wcstombs( buffer, data, MAXELTSIZE ) ; + return Rf_mkChar(buffer) ; + } + inline SEXP make_charsexp__impl__wstring( const std::wstring& st ){ + return make_charsexp__impl__wstring( st.data()) ; + } + inline SEXP make_charsexp__impl__cstring( const char* data ){ + return Rf_mkChar( data ) ; + } + inline SEXP make_charsexp__impl__cstring( const std::string& st ){ + return make_charsexp__impl__cstring( st.c_str() ) ; + } + + template + inline SEXP make_charsexp__impl( const T& s, Rcpp::traits::true_type ){ + return make_charsexp__impl__wstring(s) ; + } + + template + inline SEXP make_charsexp__impl( const T& s, Rcpp::traits::false_type ){ + return make_charsexp__impl__cstring(s) ; + } + + template + inline SEXP make_charsexp( const T& s) { + return make_charsexp__impl( s, typename Rcpp::traits::is_wide_string::type() ) ; + } + template SEXP range_wrap(InputIterator first, InputIterator last) ; template SEXP rowmajor_wrap(InputIterator first, int nrow, int ncol) ; @@ -163,10 +195,8 @@ size_t size = std::distance( first, last ) ; SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ) ; size_t i = 0 ; - std::string buffer ; while( i < size ){ - buffer = *first ; - SET_STRING_ELT( x, i, Rf_mkChar( buffer.c_str()) ) ; + SET_STRING_ELT( x, i, make_charsexp(*first) ) ; i++ ; ++first ; } @@ -184,10 +214,8 @@ size_t size = std::distance( first, last ) ; SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ) ; size_t i = 0 ; - std::wstring buffer ; while( i < size ){ - buffer = *first ; - SET_STRING_ELT( x, i, charsexp_from_wstring(buffer) ) ; + SET_STRING_ELT( x, i, make_charsexp(*first) ) ; i++ ; ++first ; } @@ -320,13 +348,10 @@ SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ) ; SEXP names = PROTECT( Rf_allocVector( STRSXP, size ) ) ; size_t i = 0 ; - std::string buffer ; while( i < size ){ - buffer = first->second ; - SET_STRING_ELT( x, i, Rf_mkChar( buffer.c_str()) ) ; + SET_STRING_ELT( x, i, make_charsexp( first->second ) ) ; - buffer = first->first ; - SET_STRING_ELT( names, i, Rf_mkChar( buffer.c_str()) ) ; + SET_STRING_ELT( names, i, make_charsexp( first->first) ) ; i++ ; ++first ; @@ -335,6 +360,37 @@ UNPROTECT(2) ; /* x, names */ return x ; } +/** + * Range based wrap for iterators over std::pair + * + * This is mainly used for wrapping map and friends + * which happens to produce iterators over pair + * + * This produces a character vector containing copies of the + * string iterated over. The names of the vector is set to the keys + * of the pair + */ +template +inline SEXP range_wrap_dispatch___impl( InputIterator first, InputIterator last, ::Rcpp::traits::r_type_pairstring_wstring_tag ){ + size_t size = std::distance( first, last ) ; + SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ) ; + SEXP names = PROTECT( Rf_allocVector( STRSXP, size ) ) ; + size_t i = 0 ; + while( i < size ){ + // a wstring + SET_STRING_ELT( x, i, make_charsexp(first->second) ) ; + + // a string + SET_STRING_ELT( names, i, make_charsexp(first->first) ) ; + + i++ ; + ++first ; + } + ::Rf_setAttrib( x, R_NamesSymbol, names ) ; + UNPROTECT(2) ; /* x, names */ + return x ; +} + // }}} /** @@ -405,10 +461,11 @@ inline SEXP primitive_wrap__impl( const T& object, ::Rcpp::traits::r_type_string_tag){ SEXP x = PROTECT( ::Rf_allocVector( STRSXP, 1) ) ; std::string y = object ; /* give a chance to implicit conversion */ - SET_STRING_ELT( x, 0, Rf_mkChar(y.c_str()) ) ; + SET_STRING_ELT( x, 0, make_charsexp(y) ) ; UNPROTECT(1) ; return x; } + /** * primitive wrap for types that can be converted implicitely to std::wstring * @@ -417,7 +474,7 @@ template inline SEXP primitive_wrap__impl( const T& object, ::Rcpp::traits::r_type_wstring_tag){ SEXP x = PROTECT( ::Rf_allocVector( STRSXP, 1) ) ; - SET_STRING_ELT( x, 0, charsexp_from_wstring(object) ) ; + SET_STRING_ELT( x, 0, make_charsexp(object) ) ; UNPROTECT(1) ; return x; } @@ -544,7 +601,7 @@ int k=0 ; for( int j=0; j. + +#ifndef Rcpp__traits__is_wide_string__h +#define Rcpp__traits__is_wide_string__h + +namespace Rcpp{ +namespace traits{ + + template + struct is_wide_string : public same_type< typename T::value_type, wchar_t > {} ; + + template <> struct is_wide_string< const wchar_t* > : public true_type{} ; + template <> struct is_wide_string< const char* > : public false_type{} ; + +} // traits +} // Rcpp + +#endif Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2013-02-03 13:33:36 UTC (rev 4235) +++ pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2013-02-04 11:36:27 UTC (rev 4236) @@ -62,6 +62,11 @@ struct r_type_pairstring_string_tag{} ; /** + * Identifies that the associated type is pair + */ +struct r_type_pairstring_wstring_tag{} ; + +/** * Indentifies pair */ struct r_type_pairstring_generic_tag{} ; @@ -105,7 +110,9 @@ template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_primitive_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_primitive_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_string_tag r_category ; } ; +template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_wstring_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_string_tag r_category ; } ; +template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_wstring_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_primitive_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_primitive_tag r_category ; } ; Modified: pkg/Rcpp/inst/include/Rcpp/traits/traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-02-03 13:33:36 UTC (rev 4235) +++ pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-02-04 11:36:27 UTC (rev 4236) @@ -25,6 +25,7 @@ #include #include +#include #include #include #include Modified: pkg/Rcpp/inst/include/RcppCommon.h =================================================================== --- pkg/Rcpp/inst/include/RcppCommon.h 2013-02-03 13:33:36 UTC (rev 4235) +++ pkg/Rcpp/inst/include/RcppCommon.h 2013-02-04 11:36:27 UTC (rev 4236) @@ -90,8 +90,6 @@ class String ; namespace internal{ template SEXP make_new_object( Class* ptr ) ; - - SEXP charsexp_from_wstring( const std::wstring& s) ; } } Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-02-03 13:33:36 UTC (rev 4235) +++ pkg/Rcpp/src/api.cpp 2013-02-04 11:36:27 UTC (rev 4236) @@ -1654,10 +1654,9 @@ return buff ; } -SEXP charsexp_from_wstring( const std::wstring& s){ +char* get_string_buffer(){ static char buffer[MAXELTSIZE]; - wcstombs( buffer, s.data(), MAXELTSIZE ) ; - return Rf_mkChar(buffer) ; + return buffer ; } // static const char* dropTrailing0(char *s, char cdec) { From noreply at r-forge.r-project.org Mon Feb 4 15:43:57 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 15:43:57 +0100 (CET) Subject: [Rcpp-commits] r4237 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/internal inst/include/Rcpp/traits Message-ID: <20130204144357.4C3A4183EB7@r-forge.r-project.org> Author: romain Date: 2013-02-04 15:43:57 +0100 (Mon, 04 Feb 2013) New Revision: 4237 Added: pkg/Rcpp/inst/include/Rcpp/traits/char_type.h Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/as.h pkg/Rcpp/inst/include/Rcpp/internal/export.h pkg/Rcpp/inst/include/Rcpp/internal/wrap.h pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h pkg/Rcpp/inst/include/Rcpp/traits/traits.h Log: rework the wstring support to avoid having extra tag traits, the support is now handled at a lower level Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-04 11:36:27 UTC (rev 4236) +++ pkg/Rcpp/ChangeLog 2013-02-04 14:43:57 UTC (rev 4237) @@ -1,9 +1,14 @@ 2013-02-04 Romain Francois - * include/Rcpp/traits/r_type_traits.h : added the r_type_pairstring_wstring_tag tag - that is used to detect iterators over pair + * include/Rcpp/traits/r_type_traits.h : make the r_type_pairstring_string_tag tag + more general, handling wstring as well as string * include/Rcpp/internal/wrap.h : using make_charsexp, a more generic version of charsexp_from_wstring. + * include/Rcpp/as.h : more support fot wstring + * include/Rcpp/internal/wrap.h : rework the support of wstring + * include/Rcpp/internal/export.h : added as_string_elt to rework the support + of wstring + * include/Rcpp/traits/char_type.h : new trait to help the wstring support 2013-02-03 Romain Francois Modified: pkg/Rcpp/inst/include/Rcpp/as.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/as.h 2013-02-04 11:36:27 UTC (rev 4236) +++ pkg/Rcpp/inst/include/Rcpp/as.h 2013-02-04 14:43:57 UTC (rev 4237) @@ -43,24 +43,28 @@ return primitive_as(x) ; } - template T as(SEXP x, ::Rcpp::traits::r_type_string_tag ) { + inline const char* check_single_string( SEXP x){ if( ! ::Rf_isString(x) ) throw ::Rcpp::not_compatible( "expecting a string" ) ; if (Rf_length(x) != 1) throw ::Rcpp::not_compatible( "expecting a single value"); - return T( CHAR( STRING_ELT( ::Rcpp::r_cast(x) ,0 ) ) ) ; + return CHAR( STRING_ELT( ::Rcpp::r_cast(x) ,0 ) ) ; } - template T as(SEXP x, ::Rcpp::traits::r_type_wstring_tag ) { - if( ! ::Rf_isString(x) ) - throw ::Rcpp::not_compatible( "expecting a string" ) ; - if (Rf_length(x) != 1) - throw ::Rcpp::not_compatible( "expecting a single value"); - const char* y = CHAR( STRING_ELT( ::Rcpp::r_cast(x) ,0 ) ) ; - // TODO: deal about encoding + + template T as_string( SEXP x, Rcpp::traits::true_type){ + const char* y = check_single_string(x) ; return std::wstring( y, y+strlen(y)) ; } + template T as_string( SEXP x, Rcpp::traits::false_type){ + return check_single_string(x) ; + } + + template T as(SEXP x, ::Rcpp::traits::r_type_string_tag ) { + return as_string( x, typename Rcpp::traits::is_wide_string::type() ); + } + template T as(SEXP x, ::Rcpp::traits::r_type_RcppString_tag ) { if( ! ::Rf_isString(x) ){ throw ::Rcpp::not_compatible( "expecting a string" ) ; Modified: pkg/Rcpp/inst/include/Rcpp/internal/export.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/export.h 2013-02-04 11:36:27 UTC (rev 4236) +++ pkg/Rcpp/inst/include/Rcpp/internal/export.h 2013-02-04 14:43:57 UTC (rev 4237) @@ -27,6 +27,24 @@ namespace Rcpp{ namespace internal{ + + template + std::wstring as_string_elt__impl( SEXP x, R_len_t i, Rcpp::traits::true_type ){ + const char* y = char_get_string_elt( x, i ) ; + return std::wstring(y, y+strlen(y) ) ; + } + + template + std::string as_string_elt__impl( SEXP x, R_len_t i, Rcpp::traits::false_type ){ + return char_get_string_elt( x, i ) ; + } + + template + const std::basic_string< typename Rcpp::traits::char_type::type > + as_string_elt( SEXP x, R_len_t i ){ + return as_string_elt__impl( x, i, typename Rcpp::traits::is_wide_string::type() ) ; + } + /* iterating */ template @@ -63,21 +81,10 @@ if( ! ::Rf_isString( x) ) throw ::Rcpp::not_compatible( "expecting a string vector" ) ; R_len_t n = ::Rf_length(x) ; for( R_len_t i=0; i::value_type> ( x, i ) ; } } - // InputIterator is an iterator over std::wstring - template - void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_wstring_tag ) { - if( ! ::Rf_isString( x) ) throw ::Rcpp::not_compatible( "expecting a string vector" ) ; - R_len_t n = ::Rf_length(x) ; - for( R_len_t i=0; i void export_range( SEXP x, InputIterator first ) { export_range__dispatch::value_type>( @@ -130,22 +137,11 @@ if( ! ::Rf_isString( x) ) throw Rcpp::not_compatible( "expecting a string vector" ) ; R_len_t n = ::Rf_length(x) ; for( R_len_t i=0; i( x, i) ; } } - - // T is an array of wstring + template - void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_wstring_tag ) { - if( ! ::Rf_isString( x) ) throw Rcpp::not_compatible( "expecting a string vector" ) ; - R_len_t n = ::Rf_length(x) ; - for( R_len_t i=0; i void export_indexing( SEXP x, T& res ) { export_indexing__dispatch( x, Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-04 11:36:27 UTC (rev 4236) +++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-04 14:43:57 UTC (rev 4237) @@ -204,25 +204,6 @@ return x ; } -/** - * Range based wrap implementation for iterators over std::wstring - * - * This produces an unnamed character vector - */ -template -inline SEXP range_wrap_dispatch___impl( InputIterator first, InputIterator last, ::Rcpp::traits::r_type_wstring_tag ){ - size_t size = std::distance( first, last ) ; - SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ) ; - size_t i = 0 ; - while( i < size ){ - SET_STRING_ELT( x, i, make_charsexp(*first) ) ; - i++ ; - ++first ; - } - UNPROTECT(1) ; - return x ; -} - // }}} // {{{ named range wrap @@ -332,8 +313,9 @@ return x ; } + /** - * Range based wrap for iterators over std::pair + * Range based wrap for iterators over std::pair * * This is mainly used for wrapping map and friends * which happens to produce iterators over pair @@ -347,50 +329,15 @@ size_t size = std::distance( first, last ) ; SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ) ; SEXP names = PROTECT( Rf_allocVector( STRSXP, size ) ) ; - size_t i = 0 ; - while( i < size ){ + for( size_t i = 0; i < size ; i++, ++first){ SET_STRING_ELT( x, i, make_charsexp( first->second ) ) ; - SET_STRING_ELT( names, i, make_charsexp( first->first) ) ; - - i++ ; - ++first ; } ::Rf_setAttrib( x, R_NamesSymbol, names ) ; UNPROTECT(2) ; /* x, names */ return x ; -} -/** - * Range based wrap for iterators over std::pair - * - * This is mainly used for wrapping map and friends - * which happens to produce iterators over pair - * - * This produces a character vector containing copies of the - * string iterated over. The names of the vector is set to the keys - * of the pair - */ -template -inline SEXP range_wrap_dispatch___impl( InputIterator first, InputIterator last, ::Rcpp::traits::r_type_pairstring_wstring_tag ){ - size_t size = std::distance( first, last ) ; - SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ) ; - SEXP names = PROTECT( Rf_allocVector( STRSXP, size ) ) ; - size_t i = 0 ; - while( i < size ){ - // a wstring - SET_STRING_ELT( x, i, make_charsexp(first->second) ) ; - - // a string - SET_STRING_ELT( names, i, make_charsexp(first->first) ) ; - - i++ ; - ++first ; - } - ::Rf_setAttrib( x, R_NamesSymbol, names ) ; - UNPROTECT(2) ; /* x, names */ - return x ; -} +} // }}} /** @@ -453,35 +400,19 @@ } /** - * primitive wrap for types that can be converted implicitely to std::string + * primitive wrap for types that can be converted implicitely to std::string or std::wstring * - * This produces a character vector of length 1 containing the std::string + * This produces a character vector of length 1 containing the std::string or wstring */ template inline SEXP primitive_wrap__impl( const T& object, ::Rcpp::traits::r_type_string_tag){ SEXP x = PROTECT( ::Rf_allocVector( STRSXP, 1) ) ; - std::string y = object ; /* give a chance to implicit conversion */ - SET_STRING_ELT( x, 0, make_charsexp(y) ) ; - UNPROTECT(1) ; - return x; -} - -/** - * primitive wrap for types that can be converted implicitely to std::wstring - * - * This produces a character vector of length 1 containing the std::wstring - */ -template -inline SEXP primitive_wrap__impl( const T& object, ::Rcpp::traits::r_type_wstring_tag){ - SEXP x = PROTECT( ::Rf_allocVector( STRSXP, 1) ) ; SET_STRING_ELT( x, 0, make_charsexp(object) ) ; UNPROTECT(1) ; return x; } - - /** * called when T is a primitive type : int, bool, double, std::string, etc ... * This uses the Rcpp::traits::r_type_traits on the type T to perform @@ -609,25 +540,7 @@ UNPROTECT(2) ; return res ; } -template -inline SEXP wrap_dispatch_matrix_not_logical( const T& object, ::Rcpp::traits::r_type_wstring_tag ){ - int nr = object.nrow(), nc = object.ncol() ; - SEXP res = PROTECT( Rf_allocVector( STRSXP, nr*nc ) ) ; - - int k=0 ; - for( int j=0; j inline SEXP wrap_dispatch_matrix_not_logical( const T& object, ::Rcpp::traits::r_type_generic_tag ){ int nr = object.nrow(), nc = object.ncol() ; @@ -719,16 +632,6 @@ UNPROTECT(1) ; return x ; } -template -inline SEXP wrap_dispatch_importer__impl( const T& object, ::Rcpp::traits::r_type_wstring_tag ){ - int size = object.size() ; - SEXP x = PROTECT( Rf_allocVector( STRSXP, size ) ); - for( int i=0; i inline SEXP wrap_dispatch_importer__impl( const T& object, ::Rcpp::traits::r_type_generic_tag ){ @@ -858,22 +761,6 @@ UNPROTECT(2); /* out, dims */ return out ; } -template -inline SEXP rowmajor_wrap__dispatch( InputIterator first, int nrow, int ncol, ::Rcpp::traits::r_type_wstring_tag ){ - SEXP out = PROTECT( ::Rf_allocVector( STRSXP, nrow * ncol) ); - int i=0, j=0 ; - for( j=0; j inline SEXP primitive_rowmajor_wrap__dispatch( InputIterator first, int nrow, int ncol, ::Rcpp::traits::false_type ){ Added: pkg/Rcpp/inst/include/Rcpp/traits/char_type.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/char_type.h (rev 0) +++ pkg/Rcpp/inst/include/Rcpp/traits/char_type.h 2013-02-04 14:43:57 UTC (rev 4237) @@ -0,0 +1,45 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */ +// +// char_type.h: Rcpp R/C++ interface class library -- +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2013 Rice University +// +// This file is part of Rcpp. +// +// Rcpp is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// Rcpp is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Rcpp. If not, see . + +#ifndef Rcpp__traits__char_type__h +#define Rcpp__traits__char_type__h + +namespace Rcpp{ +namespace traits{ + + template + struct char_type { + typedef typename T::value_type type ; + } ; + + template <> struct char_type< const wchar_t* > { + typedef wchar_t type ; + } ; + template <> struct char_type< const char* > { + typedef char type ; + } ; + +} // traits +} // Rcpp + +#endif Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2013-02-04 11:36:27 UTC (rev 4236) +++ pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h 2013-02-04 14:43:57 UTC (rev 4237) @@ -40,12 +40,6 @@ struct r_type_string_tag{} ; /** - * Identifies that the associated type can be implicitely converted - * to a std::wstring - */ -struct r_type_wstring_tag{} ; - -/** * Default */ struct r_type_generic_tag{} ; @@ -57,16 +51,11 @@ struct r_type_pairstring_primitive_tag{} ; /** - * Identifies that the associated type is pair + * Identifies that the associated type is pair */ struct r_type_pairstring_string_tag{} ; /** - * Identifies that the associated type is pair - */ -struct r_type_pairstring_wstring_tag{} ; - -/** * Indentifies pair */ struct r_type_pairstring_generic_tag{} ; @@ -110,9 +99,9 @@ template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_primitive_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_primitive_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_string_tag r_category ; } ; -template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_wstring_tag r_category ; } ; +template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_string_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_string_tag r_category ; } ; -template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_wstring_tag r_category ; } ; +template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_string_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_primitive_tag r_category ; } ; template<> struct r_type_traits< std::pair >{ typedef r_type_pairstring_primitive_tag r_category ; } ; @@ -124,14 +113,14 @@ template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; -template<> struct r_type_traits{ typedef r_type_wstring_tag r_category ; } ; +template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; -template<> struct r_type_traits{ typedef r_type_wstring_tag r_category ; } ; +template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; -template<> struct r_type_traits{ typedef r_type_wstring_tag r_category ; } ; +template<> struct r_type_traits{ typedef r_type_string_tag r_category ; } ; /* long */ template<> struct r_type_traits{ typedef r_type_primitive_tag r_category ; } ; Modified: pkg/Rcpp/inst/include/Rcpp/traits/traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-02-04 11:36:27 UTC (rev 4236) +++ pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-02-04 14:43:57 UTC (rev 4237) @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include From noreply at r-forge.r-project.org Mon Feb 4 16:16:02 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 16:16:02 +0100 (CET) Subject: [Rcpp-commits] r4238 - in pkg/Rcpp: . inst/include/Rcpp Message-ID: <20130204151602.D41CD184B7C@r-forge.r-project.org> Author: romain Date: 2013-02-04 16:16:01 +0100 (Mon, 04 Feb 2013) New Revision: 4238 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/String.h Log: added support for wstring in Rcpp::String Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-04 14:43:57 UTC (rev 4237) +++ pkg/Rcpp/ChangeLog 2013-02-04 15:16:01 UTC (rev 4238) @@ -8,7 +8,8 @@ * include/Rcpp/internal/wrap.h : rework the support of wstring * include/Rcpp/internal/export.h : added as_string_elt to rework the support of wstring - * include/Rcpp/traits/char_type.h : new trait to help the wstring support + * include/Rcpp/traits/char_type.h : new trait to help the wstring support + * include/Rcpp/String.h : added some support for wstring 2013-02-03 Romain Francois Modified: pkg/Rcpp/inst/include/Rcpp/String.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/String.h 2013-02-04 14:43:57 UTC (rev 4237) +++ pkg/Rcpp/inst/include/Rcpp/String.h 2013-02-04 15:16:01 UTC (rev 4238) @@ -2,8 +2,8 @@ // // String.h: Rcpp R/C++ interface class library -- single string // -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois -// Copyright (C) 2012 Rice University +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2013 Rice University // // This file is part of Rcpp. // @@ -77,11 +77,20 @@ RCPP_STRING_DEBUG( "String(const std::string& )" ) ; } + String( const std::wstring& s) : data(internal::make_charsexp(s)), valid(true), buffer_ready(false) { + RCPP_STRING_DEBUG( "String(const std::wstring& )" ) ; + } + /** from a const char* */ String( const char* s) : buffer(s), valid(false), buffer_ready(true){ RCPP_STRING_DEBUG( "String(const char*)" ) ; } + String( const wchar_t* s) : data(internal::make_charsexp(s)), valid(true), buffer_ready(false) { + RCPP_STRING_DEBUG( "String(const wchar_t* s)" ) ; + } + + /** constructors from R primitives */ String( int x ) : data( internal::r_coerce(x) ), valid(true), buffer_ready(false) {} String( double x ) : data( internal::r_coerce(x) ), valid(true), buffer_ready(false){} @@ -96,11 +105,25 @@ inline String& operator=( bool x ){ data = internal::r_coerce( x ) ; valid = true ; buffer_ready = false ; return *this ; } inline String& operator=( Rcomplex x){ data = internal::r_coerce( x ) ; valid = true ; buffer_ready = false ; return *this ; } inline String& operator=( SEXP x){ data = x ; valid = true ; buffer_ready = false ; return *this ; } + inline String& operator=( const StringProxy& proxy){ data = proxy.get() ; valid = true ; buffer_ready=false ; return *this ; } + inline String& operator=( const String& other ){ data = other.get_sexp() ; valid = true ; buffer_ready = false ; return *this ; } inline String& operator=( const std::string& s){ buffer = s ; valid = false ; buffer_ready = true ; return *this ; } inline String& operator=( const char* s){ buffer = s ; valid = false ; buffer_ready = true ; return *this ; } - inline String& operator=( const StringProxy& proxy){ data = proxy.get() ; valid = true ; buffer_ready=false ; return *this ; } - inline String& operator=( const String& other ){ data = other.get_sexp() ; valid = true ; buffer_ready = false ; return *this ; } + private: + template + inline String& assign_wide_string( const T& s){ + data = internal::make_charsexp( s ) ; + valid = true ; + buffer_ready = false ; + return *this ; + } + + public: + inline String& operator=( const std::wstring& s){ return assign_wide_string(s) ; } + inline String& operator=( const wchar_t* s){ return assign_wide_string(s) ; } + + inline String& operator+=( const std::string& s){ RCPP_STRING_DEBUG( "String::operator+=( std::string )" ) ; if( is_na() ) return *this ; @@ -112,7 +135,27 @@ if( is_na() ) return *this ; setBuffer() ; buffer += s ; valid = false ; return *this ; - } + } + private: + template + inline String& append_wide_string( const T& s){ + RCPP_STRING_DEBUG_1( "String::operator+=( %s )", DEMANGLE(T) ) ; + setData() ; + if( is_na() ) return *this ; + const char* buf = CHAR( data ); + std::wstring tmp( buf, buf + strlen(buf ) ) ; + tmp += s ; + data = internal::make_charsexp( tmp ) ; + valid = true ; + buffer_ready = false ; + return *this ; + } + + public: + + inline String& operator+=( const std::wstring& s){ return append_wide_string( s ); } + inline String& operator+=( const wchar_t* s){ return append_wide_string( s ); } + inline String& operator+=( const String& other ){ RCPP_STRING_DEBUG( "String::operator+=( const char*)" ) ; if( is_na() ) return *this ; @@ -271,6 +314,12 @@ return get_cstring() ; } + inline operator std::wstring() const { + const char* s = get_cstring() ; + return std::wstring( s, s + strlen(s) ); + } + + inline const char* get_cstring() const { return buffer_ready ? buffer.c_str() : CHAR(data) ; } From noreply at r-forge.r-project.org Mon Feb 4 16:54:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 16:54:58 +0100 (CET) Subject: [Rcpp-commits] r4239 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/internal inst/include/Rcpp/vector Message-ID: <20130204155458.C4A181811AF@r-forge.r-project.org> Author: romain Date: 2013-02-04 16:54:58 +0100 (Mon, 04 Feb 2013) New Revision: 4239 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/String.h pkg/Rcpp/inst/include/Rcpp/internal/wrap.h pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h Log: more wstring support in String and CharacterVector Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-04 15:16:01 UTC (rev 4238) +++ pkg/Rcpp/ChangeLog 2013-02-04 15:54:58 UTC (rev 4239) @@ -10,6 +10,7 @@ of wstring * include/Rcpp/traits/char_type.h : new trait to help the wstring support * include/Rcpp/String.h : added some support for wstring + * include/Rcpp/vector/string_proxy.h : adapt to add wstring support 2013-02-03 Romain Francois Modified: pkg/Rcpp/inst/include/Rcpp/String.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/String.h 2013-02-04 15:16:01 UTC (rev 4238) +++ pkg/Rcpp/inst/include/Rcpp/String.h 2013-02-04 15:54:58 UTC (rev 4239) @@ -384,7 +384,12 @@ RCPP_DEBUG( "string_element_converter::get< Rcpp::String >()" ) return input.get_sexp() ; } - + + template <> + inline SEXP make_charsexp( const Rcpp::String& s){ + return s.get_sexp() ; + } + } template <> @@ -397,6 +402,7 @@ return res ; } + } // Rcpp #endif Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-04 15:16:01 UTC (rev 4238) +++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-04 15:54:58 UTC (rev 4239) @@ -71,6 +71,8 @@ inline SEXP make_charsexp( const T& s) { return make_charsexp__impl( s, typename Rcpp::traits::is_wide_string::type() ) ; } + template <> + inline SEXP make_charsexp( const Rcpp::String& ); template SEXP range_wrap(InputIterator first, InputIterator last) ; template SEXP rowmajor_wrap(InputIterator first, int nrow, int ncol) ; Modified: pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h 2013-02-04 15:16:01 UTC (rev 4238) +++ pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h 2013-02-04 15:54:58 UTC (rev 4239) @@ -2,7 +2,8 @@ // // string_proxy.h: Rcpp R/C++ interface class library -- // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2013 Rice University // // This file is part of Rcpp. // @@ -67,8 +68,9 @@ * * @param rhs new content for the element referred by this proxy */ - string_proxy& operator=(const std::string& rhs){ - set( Rf_mkChar( rhs.c_str() ) ) ; + template + string_proxy& operator=(const std::basic_string& rhs){ + set( rhs ) ; return *this ; } @@ -77,7 +79,12 @@ return *this ; } + string_proxy& operator=(const wchar_t* rhs){ + set( internal::make_charsexp( rhs ) ) ; + return *this ; + } + string_proxy& operator=(SEXP rhs){ // TODO: check this is a CHARSXP set( rhs ) ; @@ -89,28 +96,19 @@ index = other.index ; } - /** - * lhs use. Adds the content of the rhs proxy to the - * element this proxy refers to. - */ - string_proxy& operator+=(const string_proxy& rhs){ - buffer = CHAR(STRING_ELT(*parent,index)) ; - buffer += CHAR(STRING_ELT( *(rhs.parent), rhs.index)) ; - SET_STRING_ELT( *parent, index, Rf_mkChar(buffer.c_str()) ) ; - return *this ; - } + /** + * lhs use. Adds the content of the rhs proxy to the + * element this proxy refers to. + */ + template + string_proxy& operator+=(const T& rhs){ + String tmp = get() ; + tmp += rhs ; + set( tmp ) ; + return *this ; + } /** - * lhs use. Adds the string to the element this proxy refers to - */ - string_proxy& operator+=(const std::string& rhs){ - buffer = CHAR(STRING_ELT(*parent,index)) ; - buffer += rhs ; - SET_STRING_ELT( *parent, index, Rf_mkChar(buffer.c_str()) ) ; - return *this ; - } - - /** * rhs use. Retrieves the current value of the * element this proxy refers to. */ @@ -151,12 +149,13 @@ inline SEXP get() const { return STRING_ELT( *parent, index ) ; } + template + inline void set( const T& x ){ + set( internal::make_charsexp(x) ) ; + } inline void set(SEXP x){ SET_STRING_ELT( *parent, index, x ) ; } - inline void set( const std::string& x ){ - set( ::Rf_mkChar(x.c_str()) ) ; - } inline iterator begin() const { return CHAR( STRING_ELT( *parent, index ) ) ; } inline iterator end() const { return begin() + size() ; } From noreply at r-forge.r-project.org Mon Feb 4 17:47:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 17:47:39 +0100 (CET) Subject: [Rcpp-commits] r4240 - in pkg/Rcpp: . inst/unitTests inst/unitTests/cpp Message-ID: <20130204164739.849E3184BAA@r-forge.r-project.org> Author: romain Date: 2013-02-04 17:47:39 +0100 (Mon, 04 Feb 2013) New Revision: 4240 Added: pkg/Rcpp/inst/unitTests/cpp/wstring.cpp pkg/Rcpp/inst/unitTests/runit.wstring.R Modified: pkg/Rcpp/ChangeLog Log: added unit tests for wstring support Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-04 15:54:58 UTC (rev 4239) +++ pkg/Rcpp/ChangeLog 2013-02-04 16:47:39 UTC (rev 4240) @@ -11,6 +11,8 @@ * include/Rcpp/traits/char_type.h : new trait to help the wstring support * include/Rcpp/String.h : added some support for wstring * include/Rcpp/vector/string_proxy.h : adapt to add wstring support + * unitTests/runit.wstring.R : unit tests for wstring support + * unitTests/cpp/wstring.cpp : unit tests for wstring support 2013-02-03 Romain Francois Added: pkg/Rcpp/inst/unitTests/cpp/wstring.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/wstring.cpp (rev 0) +++ pkg/Rcpp/inst/unitTests/cpp/wstring.cpp 2013-02-04 16:47:39 UTC (rev 4240) @@ -0,0 +1,27 @@ +#include +using namespace Rcpp ; + +// [[Rcpp::export]] +CharacterVector CharacterVector_wstring( ){ + CharacterVector res(2) ; + res[0] = L"foo" ; + res[0] += L"bar" ; + + res[1] = std::wstring( L"foo" ) ; + res[1] += std::wstring( L"bar" ) ; + + return res ; +} + +// [[Rcpp::export]] +std::wstring wstring_return(){ + return L"foo" ; +} + +// [[Rcpp::export]] +String wstring_param(const std::wstring& s1, const std::wstring& s2){ + String s = s1 ; + s += s2 ; + return s ; +} + Added: pkg/Rcpp/inst/unitTests/runit.wstring.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.wstring.R (rev 0) +++ pkg/Rcpp/inst/unitTests/runit.wstring.R 2013-02-04 16:47:39 UTC (rev 4240) @@ -0,0 +1,43 @@ +#!/usr/bin/r -t +# -*- mode: R; tab-width: 4; -*- +# +# Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2013 Rice University +# +# This file is part of Rcpp. +# +# Rcpp is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# Rcpp is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Rcpp. If not, see . + +.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes" + +if (.runThisTest) { + +.setUp <- function(){ + sourceCpp(file.path(pathRcppTests, "cpp/wstring.cpp")) +} + +test.CharacterVector_wstring <- function(){ + res <- CharacterVector_wstring() + checkEquals( res, c("foobar", "foobar" ) ) +} + +test.wstring_return <- function(){ + checkEquals( wstring_return(), "foo" ) +} + +test.wstring_param <- function(){ + checkEquals( wstring_param( "foo", "bar" ), "foobar" ) +} + +} From noreply at r-forge.r-project.org Mon Feb 4 17:56:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Feb 2013 17:56:19 +0100 (CET) Subject: [Rcpp-commits] r4241 - in pkg/Rcpp/inst/unitTests: . cpp Message-ID: <20130204165619.CBE2E184BAA@r-forge.r-project.org> Author: romain Date: 2013-02-04 17:56:19 +0100 (Mon, 04 Feb 2013) New Revision: 4241 Modified: pkg/Rcpp/inst/unitTests/cpp/wstring.cpp pkg/Rcpp/inst/unitTests/runit.wstring.R Log: more unit tests Modified: pkg/Rcpp/inst/unitTests/cpp/wstring.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/wstring.cpp 2013-02-04 16:47:39 UTC (rev 4240) +++ pkg/Rcpp/inst/unitTests/cpp/wstring.cpp 2013-02-04 16:56:19 UTC (rev 4241) @@ -25,3 +25,19 @@ return s ; } +// [[Rcpp::export]] +std::vector wrap_vector_wstring(){ + std::vector res(2 ); + res[0] = L"foo" ; + res[1] = L"bar" ; + return res; +} + +// [[Rcpp::export]] +std::vector as_vector_wstring( std::vector x){ + for( size_t i=0; i Author: jjallaire Date: 2013-02-05 12:15:10 +0100 (Tue, 05 Feb 2013) New Revision: 4242 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/NEWS.Rd pkg/Rcpp/src/attributes.cpp Log: ensure that line comments invalidate block comments when parsing for attributes Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-04 16:56:19 UTC (rev 4241) +++ pkg/Rcpp/ChangeLog 2013-02-05 11:15:10 UTC (rev 4242) @@ -1,3 +1,8 @@ +2013-02-05 JJ Allaire + + * src/attributes.cpp : ensure that line comments invalidate block + comments when parsing for attributes + 2013-02-04 Romain Francois * include/Rcpp/traits/r_type_traits.h : make the r_type_pairstring_string_tag tag Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-02-04 16:56:19 UTC (rev 4241) +++ pkg/Rcpp/inst/NEWS.Rd 2013-02-05 11:15:10 UTC (rev 4242) @@ -20,6 +20,8 @@ \item Stop with an error if the file name passed to \code{sourceCpp} has spaces in it \item Return invisibly from void functions + \item Ensure that line comments invalidate block comments when + parsing for attributes } \item Changes in Rcpp API: \itemize{ Modified: pkg/Rcpp/src/attributes.cpp =================================================================== --- pkg/Rcpp/src/attributes.cpp 2013-02-04 16:56:19 UTC (rev 4241) +++ pkg/Rcpp/src/attributes.cpp 2013-02-05 11:15:10 UTC (rev 4242) @@ -1245,9 +1245,21 @@ void CommentState::submitLine(const std::string& line) { std::size_t pos = 0; while (pos != std::string::npos) { + + // check for a // which would invalidate any other token found + std::size_t lineCommentPos = line.find("//", pos); + + // look for the next token std::string token = inComment() ? "*/" : "/*"; pos = line.find(token, pos); + + // process the comment token if found if (pos != std::string::npos) { + + // break if the line comment precedes the comment token + if (lineCommentPos != std::string::npos && lineCommentPos < pos) + break; + inComment_ = !inComment_; pos += token.size(); } From noreply at r-forge.r-project.org Tue Feb 5 15:24:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 15:24:37 +0100 (CET) Subject: [Rcpp-commits] r4243 - in pkg/Rcpp: . inst/include inst/include/Rcpp inst/include/Rcpp/vector inst/unitTests inst/unitTests/cpp Message-ID: <20130205142437.827E918454C@r-forge.r-project.org> Author: romain Date: 2013-02-05 15:24:36 +0100 (Tue, 05 Feb 2013) New Revision: 4243 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/XPtr.h pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h pkg/Rcpp/inst/include/RcppCommon.h pkg/Rcpp/inst/unitTests/cpp/wstring.cpp pkg/Rcpp/inst/unitTests/runit.Module.R pkg/Rcpp/inst/unitTests/runit.XPTr.R pkg/Rcpp/inst/unitTests/runit.wstring.R Log: more wstring support Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-05 11:15:10 UTC (rev 4242) +++ pkg/Rcpp/ChangeLog 2013-02-05 14:24:36 UTC (rev 4243) @@ -1,3 +1,8 @@ +2013-02-05 Romain Francois + + * include/Rcpp/vector/string_proxy.h : more wstring support + * include/Rcpp/XPtr.h : more debugging + 2013-02-05 JJ Allaire * src/attributes.cpp : ensure that line comments invalidate block Modified: pkg/Rcpp/inst/include/Rcpp/XPtr.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/XPtr.h 2013-02-05 11:15:10 UTC (rev 4242) +++ pkg/Rcpp/inst/include/Rcpp/XPtr.h 2013-02-05 14:24:36 UTC (rev 4243) @@ -30,6 +30,7 @@ void delete_finalizer(SEXP p){ if( TYPEOF(p) == EXTPTRSXP ){ T* ptr = (T*) R_ExternalPtrAddr(p) ; + RCPP_DEBUG_3( "delete_finalizer<%s>(SEXP p = <%p>). ptr = %p", DEMANGLE(T), p, ptr ) delete ptr ; } } @@ -75,7 +76,7 @@ * this way (has to be a C++ object) */ explicit XPtr(T* p, bool set_delete_finalizer = true, SEXP tag = R_NilValue, SEXP prot = R_NilValue){ - RCPP_DEBUG( "XPtr(T* p, bool set_delete_finalizer = true, SEXP tag = R_NilValue, SEXP prot = R_NilValue)" ) + RCPP_DEBUG_2( "XPtr(T* p = <%p>, bool set_delete_finalizer = %s, SEXP tag = R_NilValue, SEXP prot = R_NilValue)", p, ( set_delete_finalizer ? "true" : "false" ) ) SEXP x = PROTECT( R_MakeExternalPtr( (void*)p , tag, prot) ) ; #if RCPP_DEBUG_LEVEL > 0 Rf_PrintValue( x ) ; Modified: pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h 2013-02-05 11:15:10 UTC (rev 4242) +++ pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h 2013-02-05 14:24:36 UTC (rev 4243) @@ -121,9 +121,14 @@ * element this proxy refers to and convert it to a * C string */ - operator /*const */ char*() const { + operator /* const */ char*() const { return const_cast( CHAR(get()) ); } + + // operator std::wstring() const { + // const char* st = CHAR(get()) ; + // return std::wstring( st, st+strlen(st) ) ; + // } /** * Prints the element this proxy refers to to an Modified: pkg/Rcpp/inst/include/RcppCommon.h =================================================================== --- pkg/Rcpp/inst/include/RcppCommon.h 2013-02-05 11:15:10 UTC (rev 4242) +++ pkg/Rcpp/inst/include/RcppCommon.h 2013-02-05 14:24:36 UTC (rev 4243) @@ -23,7 +23,7 @@ #ifndef RcppCommon_h #define RcppCommon_h -// #define RCPP_DEBUG_LEVEL 0 +// #define RCPP_DEBUG_LEVEL 0 #include #include Modified: pkg/Rcpp/inst/unitTests/cpp/wstring.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/wstring.cpp 2013-02-05 11:15:10 UTC (rev 4242) +++ pkg/Rcpp/inst/unitTests/cpp/wstring.cpp 2013-02-05 14:24:36 UTC (rev 4243) @@ -6,7 +6,7 @@ CharacterVector res(2) ; res[0] = L"foo" ; res[0] += L"bar" ; - + res[1] = std::wstring( L"foo" ) ; res[1] += std::wstring( L"bar" ) ; Modified: pkg/Rcpp/inst/unitTests/runit.Module.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.Module.R 2013-02-05 11:15:10 UTC (rev 4242) +++ pkg/Rcpp/inst/unitTests/runit.Module.R 2013-02-05 14:24:36 UTC (rev 4243) @@ -96,9 +96,9 @@ checkEquals( mod$bar( 2L ), 4L ) checkEquals( mod$foo( 2L, 10.0 ), 20.0 ) checkEquals( mod$hello(), "hello" ) - checkEquals( capture.output( mod$bla() ), "hello" ) - checkEquals( capture.output( mod$bla1(2L) ), "hello (x = 2)" ) - checkEquals( capture.output( mod$bla2(2L, 5.0) ), "hello (x = 2, y = 5.00)" ) + # checkEquals( capture.output( mod$bla() ), "hello" ) + # checkEquals( capture.output( mod$bla1(2L) ), "hello (x = 2)" ) + # checkEquals( capture.output( mod$bla2(2L, 5.0) ), "hello (x = 2, y = 5.00)" ) World <- mod$World w <- new( World ) Modified: pkg/Rcpp/inst/unitTests/runit.XPTr.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.XPTr.R 2013-02-05 11:15:10 UTC (rev 4242) +++ pkg/Rcpp/inst/unitTests/runit.XPTr.R 2013-02-05 14:24:36 UTC (rev 4243) @@ -29,12 +29,12 @@ std::vector* v = new std::vector ; v->push_back( 1 ) ; v->push_back( 2 ) ; - + /* wrap the pointer as an external pointer */ /* this automatically protected the external pointer from R garbage collection until p goes out of scope. */ - Rcpp::XPtr< std::vector > p(v, true) ; - + Rcpp::XPtr< std::vector > p(v) ; + /* return it back to R, since p goes out of scope after the return the external pointer is no more protected by p, but it gets protected by being on the R side */ @@ -54,7 +54,7 @@ and return something else to R, you need to protect the external pointer, by using the protect member function */ Rcpp::XPtr< std::vector > p(x) ; - + /* just return the front of the vector as a SEXP */ return( Rcpp::wrap( p->front() ) ) ; ', plugin = "Rcpp" ) Modified: pkg/Rcpp/inst/unitTests/runit.wstring.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.wstring.R 2013-02-05 11:15:10 UTC (rev 4242) +++ pkg/Rcpp/inst/unitTests/runit.wstring.R 2013-02-05 14:24:36 UTC (rev 4243) @@ -28,7 +28,8 @@ } test.CharacterVector_wstring <- function(){ - res <- CharacterVector_wstring() + res <- CharacterVector_wstring() + print(res) checkEquals( res, c("foobar", "foobar" ) ) } From noreply at r-forge.r-project.org Tue Feb 5 15:36:49 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Feb 2013 15:36:49 +0100 (CET) Subject: [Rcpp-commits] r4244 - in pkg/Rcpp: . inst/include/Rcpp Message-ID: <20130205143649.4939F18454C@r-forge.r-project.org> Author: romain Date: 2013-02-05 15:36:48 +0100 (Tue, 05 Feb 2013) New Revision: 4244 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/XPtr.h Log: cleaning Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-05 14:24:36 UTC (rev 4243) +++ pkg/Rcpp/ChangeLog 2013-02-05 14:36:48 UTC (rev 4244) @@ -1,7 +1,8 @@ 2013-02-05 Romain Francois * include/Rcpp/vector/string_proxy.h : more wstring support - * include/Rcpp/XPtr.h : more debugging + * include/Rcpp/XPtr.h : more debugging. removed delete_finalizer which is + no longer used 2013-02-05 JJ Allaire Modified: pkg/Rcpp/inst/include/Rcpp/XPtr.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/XPtr.h 2013-02-05 14:24:36 UTC (rev 4243) +++ pkg/Rcpp/inst/include/Rcpp/XPtr.h 2013-02-05 14:36:48 UTC (rev 4244) @@ -2,7 +2,7 @@ // // XPtr.h: Rcpp R/C++ interface class library -- smart external pointers // -// Copyright (C) 2009 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -27,15 +27,6 @@ namespace Rcpp{ template -void delete_finalizer(SEXP p){ - if( TYPEOF(p) == EXTPTRSXP ){ - T* ptr = (T*) R_ExternalPtrAddr(p) ; - RCPP_DEBUG_3( "delete_finalizer<%s>(SEXP p = <%p>). ptr = %p", DEMANGLE(T), p, ptr ) - delete ptr ; - } -} - -template void standard_delete_finalizer(T* obj){ delete obj ; } @@ -44,6 +35,7 @@ void finalizer_wrapper(SEXP p){ if( TYPEOF(p) == EXTPTRSXP ){ T* ptr = (T*) R_ExternalPtrAddr(p) ; + RCPP_DEBUG_3( "finalizer_wrapper<%s>(SEXP p = <%p>). ptr = %p", DEMANGLE(T), p, ptr ) Finalizer(ptr) ; } } From noreply at r-forge.r-project.org Thu Feb 7 20:14:29 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Feb 2013 20:14:29 +0100 (CET) Subject: [Rcpp-commits] r4245 - in pkg/Rcpp: . inst Message-ID: <20130207191430.1574818074A@r-forge.r-project.org> Author: edd Date: 2013-02-07 20:14:29 +0100 (Thu, 07 Feb 2013) New Revision: 4245 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/THANKS Log: adding Ben North for the help / bug report on iterators Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-05 14:36:48 UTC (rev 4244) +++ pkg/Rcpp/ChangeLog 2013-02-07 19:14:29 UTC (rev 4245) @@ -1,3 +1,7 @@ +2013-02-07 Dirk Eddelbuettel + + * inst/THANKS: Adding Ben North for the help / bug report on iterators + 2013-02-05 Romain Francois * include/Rcpp/vector/string_proxy.h : more wstring support Modified: pkg/Rcpp/inst/THANKS =================================================================== --- pkg/Rcpp/inst/THANKS 2013-02-05 14:36:48 UTC (rev 4244) +++ pkg/Rcpp/inst/THANKS 2013-02-07 19:14:29 UTC (rev 4245) @@ -14,6 +14,7 @@ Tama Ma for a patch that extends Module constructors Karl Millar for a patch helping with a non-g++ compiler Anirban Mukherjee for reporting more clang++ warnings we had not seen +Ben North for a bug report and patch concerning iterators Martyn Plummer for help and patches regarding Solaris build issues David Reiss for the first-ever contributed patch (Rcpp*View) Brian Ripley for help with Win64 + Solaris build issues From noreply at r-forge.r-project.org Fri Feb 8 09:34:09 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Feb 2013 09:34:09 +0100 (CET) Subject: [Rcpp-commits] r4246 - in pkg/Rcpp: . inst/include/Rcpp Message-ID: <20130208083409.BDAA11841F0@r-forge.r-project.org> Author: romain Date: 2013-02-08 09:34:09 +0100 (Fri, 08 Feb 2013) New Revision: 4246 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/as.h Log: reenable std::string( CharacterVector[int] ) Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-07 19:14:29 UTC (rev 4245) +++ pkg/Rcpp/ChangeLog 2013-02-08 08:34:09 UTC (rev 4246) @@ -1,3 +1,7 @@ +2013-02-08 Romain Francois + + * include/Rcpp/as.h: re-enable as( CharacterVector[int] ) + 2013-02-07 Dirk Eddelbuettel * inst/THANKS: Adding Ben North for the help / bug report on iterators Modified: pkg/Rcpp/inst/include/Rcpp/as.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/as.h 2013-02-07 19:14:29 UTC (rev 4245) +++ pkg/Rcpp/inst/include/Rcpp/as.h 2013-02-08 08:34:09 UTC (rev 4246) @@ -44,6 +44,7 @@ } inline const char* check_single_string( SEXP x){ + if( TYPEOF(x) == CHARSXP ) return CHAR( x ) ; if( ! ::Rf_isString(x) ) throw ::Rcpp::not_compatible( "expecting a string" ) ; if (Rf_length(x) != 1) From noreply at r-forge.r-project.org Sun Feb 10 12:07:33 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 10 Feb 2013 12:07:33 +0100 (CET) Subject: [Rcpp-commits] r4247 - pkg/Rcpp Message-ID: <20130210110734.13276183B58@r-forge.r-project.org> Author: jjallaire Date: 2013-02-10 12:07:33 +0100 (Sun, 10 Feb 2013) New Revision: 4247 Modified: pkg/Rcpp/TODO Log: add todos for attributes Modified: pkg/Rcpp/TODO =================================================================== --- pkg/Rcpp/TODO 2013-02-08 08:34:09 UTC (rev 4246) +++ pkg/Rcpp/TODO 2013-02-10 11:07:33 UTC (rev 4247) @@ -114,6 +114,12 @@ o Allow sourceCpp to build an entire directory + o Consider allowing local includes in sourceCpp (but compilation cache + must pay mind to any local includes) + + o Support persistence of sourceCpp created functions across sessions + (either via long-lived temp dir or via environment persistence) + Testing o all r* functions : rnorm, etc ... From noreply at r-forge.r-project.org Mon Feb 11 03:22:45 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 03:22:45 +0100 (CET) Subject: [Rcpp-commits] r4248 - in pkg/RcppSMC: . R Message-ID: <20130211022245.CD17B18127E@r-forge.r-project.org> Author: edd Date: 2013-02-11 03:22:41 +0100 (Mon, 11 Feb 2013) New Revision: 4248 Modified: pkg/RcppSMC/ChangeLog pkg/RcppSMC/R/pfNonlinBS.R Log: corrected test for missing data in call of pfNonlinBS() while at it, also (ahem) reindented to default Emacs preferences (a la R Core) Modified: pkg/RcppSMC/ChangeLog =================================================================== --- pkg/RcppSMC/ChangeLog 2013-02-10 11:07:33 UTC (rev 4247) +++ pkg/RcppSMC/ChangeLog 2013-02-11 02:22:41 UTC (rev 4248) @@ -1,3 +1,9 @@ +2013-02-10 Dirk Eddelbuettel + + * DESCRIPTION: Version 0.1.1.1 as minor dev version, next release as 0.1.2 + + * R/pfNonlinBS.R: Corrected test for missing data in call + 2012-05-14 Dirk Eddelbuettel * DESCRIPTION: Version 0.1.1 Modified: pkg/RcppSMC/R/pfNonlinBS.R =================================================================== --- pkg/RcppSMC/R/pfNonlinBS.R 2013-02-10 11:07:33 UTC (rev 4247) +++ pkg/RcppSMC/R/pfNonlinBS.R 2013-02-11 02:22:41 UTC (rev 4248) @@ -1,17 +1,24 @@ -pfNonlinBS <- function(data=c(), particles=500, plot=FALSE) { - if (length(data == 0)) { - #Include some error handling here - return; +pfNonlinBS <- function(data, particles=500, plot=FALSE) { + if (missing(data)) { + warning("data argument contained no data, returning...") + return; } res <- .Call("pfNonlinBS", data, particles, package="RcppSMC") time <- 1:length(data); if (plot) { - with(res, plot(time,mean,type='l',main='Filtering Mean and +/- 1,2 - standard deviation intervals', xlab='time',ylab='estimate',xlim = c(0,length(data)), ylim = c(min(mean-2.1*sd),max(mean+2.1*sd)))) - with(res,polygon(c(time,seq(length(data),1,-1)),c(mean-2*sd,(mean+2*sd)[seq(length(data),1,-1)]),col='palegreen1',border=NA)) - with(res,polygon(c(time,seq(length(data),1,-1)),c(mean-1*sd,(mean+1*sd)[seq(length(data),1,-1)]),col='palegreen3',border=NA)) - with(res,lines(time,mean, lwd=2, col='darkblue')) + with(res, plot(time,mean,type='l', + main='Filtering Mean and +/- 1,2 standard deviation intervals', + xlab='time',ylab='estimate', + xlim = c(0,length(data)), + ylim = c(min(mean-2.1*sd),max(mean+2.1*sd)))) + with(res,polygon(c(time,seq(length(data),1,-1)), + c(mean-2*sd,(mean+2*sd)[seq(length(data),1,-1)]), + col='palegreen1',border=NA)) + with(res,polygon(c(time,seq(length(data),1,-1)), + c(mean-1*sd,(mean+1*sd)[seq(length(data),1,-1)]), + col='palegreen3',border=NA)) + with(res,lines(time,mean, lwd=2, col='darkblue')) } invisible(res) From noreply at r-forge.r-project.org Mon Feb 11 03:23:45 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 03:23:45 +0100 (CET) Subject: [Rcpp-commits] r4249 - pkg/RcppSMC/src Message-ID: <20130211022345.4B36318127E@r-forge.r-project.org> Author: edd Date: 2013-02-11 03:23:45 +0100 (Mon, 11 Feb 2013) New Revision: 4249 Modified: pkg/RcppSMC/src/pfnonlinbs.cpp Log: reindented to default Emacs preferences (a la R Core) Modified: pkg/RcppSMC/src/pfnonlinbs.cpp =================================================================== --- pkg/RcppSMC/src/pfnonlinbs.cpp 2013-02-11 02:22:41 UTC (rev 4248) +++ pkg/RcppSMC/src/pfnonlinbs.cpp 2013-02-11 02:23:45 UTC (rev 4249) @@ -7,8 +7,8 @@ // Bayesian state estimation", Gordon Salmond and Smith, // IEE PROCEEDINGS-F 140(2):107-113, 1993 // -// Copyright (C) 2008-2009 Adam Johansen -// Copyright (C) 2012 Dirk Eddelbuettel and Adam Johansen +// Copyright (C) 2008 - 2009 Adam Johansen +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Adam Johansen // // This file is part of RcppSMC. // @@ -32,98 +32,92 @@ #include namespace nonlinbs { -const double std_x0 = 2; -const double var_x0 = std_x0 * std_x0; -const double std_x = sqrt(10.0); -const double var_x = std_x * std_x; -const double var_y = 1.0; + const double std_x0 = 2; + const double var_x0 = std_x0 * std_x0; + const double std_x = sqrt(10.0); + const double var_x = std_x * std_x; + const double var_y = 1.0; -const double scale_y = 1.0 / 20.0; + const double scale_y = 1.0 / 20.0; -///The observations -Rcpp::NumericVector y; + ///The observations + Rcpp::NumericVector y; } using namespace std; using namespace nonlinbs; -extern "C" SEXP pfNonlinBS(SEXP dataS, SEXP partS) -{ - long lNumber = Rcpp::as(partS); +extern "C" SEXP pfNonlinBS(SEXP dataS, SEXP partS) { + long lNumber = Rcpp::as(partS); - y = Rcpp::NumericVector(dataS); - long lIterates = y.size(); + y = Rcpp::NumericVector(dataS); + long lIterates = y.size(); - //Initialise and run the sampler - smc::sampler Sampler(lNumber, SMC_HISTORY_NONE); - smc::moveset Moveset(fInitialise, fMove, NULL); + //Initialise and run the sampler + smc::sampler Sampler(lNumber, SMC_HISTORY_NONE); + smc::moveset Moveset(fInitialise, fMove, NULL); - Sampler.SetResampleParams(SMC_RESAMPLE_MULTINOMIAL, 1.01 * lNumber); - Sampler.SetMoveSet(Moveset); - Sampler.Initialise(); + Sampler.SetResampleParams(SMC_RESAMPLE_MULTINOMIAL, 1.01 * lNumber); + Sampler.SetMoveSet(Moveset); + Sampler.Initialise(); - Rcpp::NumericVector resMean = Rcpp::NumericVector(lIterates); - Rcpp::NumericVector resSD = Rcpp::NumericVector(lIterates); - for(int n=0 ; n < lIterates ; ++n) { - if(n > 0) - Sampler.Iterate(); + Rcpp::NumericVector resMean = Rcpp::NumericVector(lIterates); + Rcpp::NumericVector resSD = Rcpp::NumericVector(lIterates); + for(int n=0 ; n < lIterates ; ++n) { + if(n > 0) + Sampler.Iterate(); - resMean(n) = Sampler.Integrate(integrand_mean_x,NULL); - resSD(n) = sqrt(Sampler.Integrate(integrand_var_x, (void*)&resSD(n))); - } + resMean(n) = Sampler.Integrate(integrand_mean_x,NULL); + resSD(n) = sqrt(Sampler.Integrate(integrand_var_x, (void*)&resSD(n))); + } - return Rcpp::List::create(Rcpp::_["mean"] = resMean, - Rcpp::_["sd"] = resSD); + return Rcpp::List::create(Rcpp::_["mean"] = resMean, + Rcpp::_["sd"] = resSD); } namespace nonlinbs { -///The function corresponding to the log likelihood at specified time and position (up to normalisation) + ///The function corresponding to the log likelihood at specified time and position (up to normalisation) -/// \param lTime The current time (i.e. the index of the current distribution) -/// \param X The state to consider -double logLikelihood(long lTime, const double & x) -{ - return -0.5 * pow(y[int(lTime)] - x*x*scale_y,2) / var_y; -} + /// \param lTime The current time (i.e. the index of the current distribution) + /// \param X The state to consider + double logLikelihood(long lTime, const double & x) { + return -0.5 * pow(y[int(lTime)] - x*x*scale_y,2) / var_y; + } -///A function to initialise particles - -/// \param pRng A pointer to the random number generator which is to be used -smc::particle fInitialise(smc::rng *pRng) -{ - double x; + ///A function to initialise particles + + /// \param pRng A pointer to the random number generator which is to be used + smc::particle fInitialise(smc::rng *pRng) { + double x; - x = pRng->Normal(0,std_x0); + x = pRng->Normal(0,std_x0); - return smc::particle(x,logLikelihood(0,x)); -} + return smc::particle(x,logLikelihood(0,x)); + } -///The proposal function. + ///The proposal function. -///\param lTime The sampler iteration. -///\param pFrom The particle to move. -///\param pRng A random number generator. -void fMove(long lTime, smc::particle & pFrom, smc::rng *pRng) -{ - double *to = pFrom.GetValuePointer(); + ///\param lTime The sampler iteration. + ///\param pFrom The particle to move. + ///\param pRng A random number generator. + void fMove(long lTime, smc::particle & pFrom, smc::rng *pRng) { + double *to = pFrom.GetValuePointer(); - double x = 0.5 * (*to) + 25.0*(*to) / (1.0 + (*to) * (*to)) + 8.0 * cos(1.2 * ( lTime)) + pRng->Normal(0.0,std_x); + double x = 0.5 * (*to) + 25.0*(*to) / (1.0 + (*to) * (*to)) + 8.0 * cos(1.2 * ( lTime)) + pRng->Normal(0.0,std_x); + + *to = x; - *to = x; + pFrom.AddToLogWeight(logLikelihood(lTime, *to)); + } + - pFrom.AddToLogWeight(logLikelihood(lTime, *to)); -} + double integrand_mean_x(const double& x, void *) { + return x; + } - -double integrand_mean_x(const double& x, void *) -{ - return x; + double integrand_var_x(const double& x, void* vmx) { + double* dmx = (double*)vmx; + double d = (x - (*dmx)); + return d*d; + } } - -double integrand_var_x(const double& x, void* vmx) -{ - double* dmx = (double*)vmx; - double d = (x - (*dmx)); - return d*d; -} -} From noreply at r-forge.r-project.org Mon Feb 11 03:26:33 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 03:26:33 +0100 (CET) Subject: [Rcpp-commits] r4250 - pkg/RcppSMC Message-ID: <20130211022633.8582D18127E@r-forge.r-project.org> Author: edd Date: 2013-02-11 03:26:33 +0100 (Mon, 11 Feb 2013) New Revision: 4250 Modified: pkg/RcppSMC/ pkg/RcppSMC/.Rbuildignore Log: updated some meta files as local directory contains some RStudio project files Property changes on: pkg/RcppSMC ___________________________________________________________________ Added: svn:ignore + .Rproj.user .Rhistory .RData RcppSMC.Rproj Modified: pkg/RcppSMC/.Rbuildignore =================================================================== --- pkg/RcppSMC/.Rbuildignore 2013-02-11 02:23:45 UTC (rev 4249) +++ pkg/RcppSMC/.Rbuildignore 2013-02-11 02:26:33 UTC (rev 4250) @@ -1,2 +1,4 @@ src/compareGSLtoR deprecated +^.*\.Rproj$ +^\.Rproj\.user$ From noreply at r-forge.r-project.org Mon Feb 11 03:46:49 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 03:46:49 +0100 (CET) Subject: [Rcpp-commits] r4251 - pkg/RcppSMC Message-ID: <20130211024649.9667118479F@r-forge.r-project.org> Author: edd Date: 2013-02-11 03:46:48 +0100 (Mon, 11 Feb 2013) New Revision: 4251 Modified: pkg/RcppSMC/DESCRIPTION Log: as promised in ChangeLog: Version 0.1.1.1 as minor dev version, next release as 0.1.2 Modified: pkg/RcppSMC/DESCRIPTION =================================================================== --- pkg/RcppSMC/DESCRIPTION 2013-02-11 02:26:33 UTC (rev 4250) +++ pkg/RcppSMC/DESCRIPTION 2013-02-11 02:46:48 UTC (rev 4251) @@ -1,7 +1,7 @@ Package: RcppSMC Type: Package Title: Rcpp bindings for Sequential Monte Carlo -Version: 0.1.1 +Version: 0.1.1.1 Date: $Date$ Author: Dirk Eddelbuettel and Adam M. Johansen Maintainer: Dirk Eddelbuettel From noreply at r-forge.r-project.org Mon Feb 11 21:06:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Feb 2013 21:06:37 +0100 (CET) Subject: [Rcpp-commits] r4252 - in pkg/RcppSMC: . R Message-ID: <20130211200637.276E5184602@r-forge.r-project.org> Author: adamj Date: 2013-02-11 21:06:36 +0100 (Mon, 11 Feb 2013) New Revision: 4252 Modified: pkg/RcppSMC/ChangeLog pkg/RcppSMC/R/pfNonlinBS.R Log: Added simulation of default data when no data supplied.` Modified: pkg/RcppSMC/ChangeLog =================================================================== --- pkg/RcppSMC/ChangeLog 2013-02-11 02:46:48 UTC (rev 4251) +++ pkg/RcppSMC/ChangeLog 2013-02-11 20:06:36 UTC (rev 4252) @@ -1,3 +1,9 @@ +2013-02-11 Adam Johansen + + * DESCRIPTION: Version 0.1.1.2 as minor dev version, next release as 0.1.2 + + * R/pfNonlinBS.R: Automatically simulate data, and warn, if none supplied. + 2013-02-10 Dirk Eddelbuettel * DESCRIPTION: Version 0.1.1.1 as minor dev version, next release as 0.1.2 Modified: pkg/RcppSMC/R/pfNonlinBS.R =================================================================== --- pkg/RcppSMC/R/pfNonlinBS.R 2013-02-11 02:46:48 UTC (rev 4251) +++ pkg/RcppSMC/R/pfNonlinBS.R 2013-02-11 20:06:36 UTC (rev 4252) @@ -1,7 +1,7 @@ pfNonlinBS <- function(data, particles=500, plot=FALSE) { if (missing(data)) { - warning("data argument contained no data, returning...") - return; + warning("data argument contained no data, using data simulated from the model.") + data <- simNonlin(len=50)$data } res <- .Call("pfNonlinBS", data, particles, package="RcppSMC") From noreply at r-forge.r-project.org Tue Feb 12 16:52:30 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Feb 2013 16:52:30 +0100 (CET) Subject: [Rcpp-commits] r4253 - in pkg/Rcpp: . inst/unitTests src Message-ID: <20130212155231.0A0AE183E7A@r-forge.r-project.org> Author: romain Date: 2013-02-12 16:52:30 +0100 (Tue, 12 Feb 2013) New Revision: 4253 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/unitTests/runit.Module.R pkg/Rcpp/src/api.cpp Log: more careful about stack Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-11 20:06:36 UTC (rev 4252) +++ pkg/Rcpp/ChangeLog 2013-02-12 15:52:30 UTC (rev 4253) @@ -1,3 +1,7 @@ +2013-02-12 Romain Francois + + * src/api.cpp : More careful about RCPP_PROTECTION_STACK init + 2013-02-08 Romain Francois * include/Rcpp/as.h: re-enable as( CharacterVector[int] ) Modified: pkg/Rcpp/inst/unitTests/runit.Module.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.Module.R 2013-02-11 20:06:36 UTC (rev 4252) +++ pkg/Rcpp/inst/unitTests/runit.Module.R 2013-02-12 15:52:30 UTC (rev 4253) @@ -22,7 +22,8 @@ gc() } -.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes" +# .runThisTest <- Sys.getenv("RunAllRcppTests") == "yes" +.runThisTest <- FALSE if( .runThisTest && Rcpp:::capabilities()[["Rcpp modules"]] ) { Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-02-11 20:06:36 UTC (rev 4252) +++ pkg/Rcpp/src/api.cpp 2013-02-12 15:52:30 UTC (rev 4253) @@ -34,14 +34,16 @@ // {{{ SexpStack static SEXP RCPP_PROTECTION_STACK = R_NilValue ; static SEXP* RCPP_PROTECTION_STACK_PTR = 0 ; + static bool RCPP_PROTECTION_STACK_READY = false ; #define GET_TOP() TRUELENGTH(RCPP_PROTECTION_STACK) #define SET_TOP(TOP) SET_TRUELENGTH(RCPP_PROTECTION_STACK, TOP) inline void init_ProtectionStack(){ - if(RCPP_PROTECTION_STACK == R_NilValue){ + if(!RCPP_PROTECTION_STACK_READY){ RCPP_PROTECTION_STACK = get_Rcpp_protection_stack() ; RCPP_PROTECTION_STACK_PTR = get_vector_ptr(RCPP_PROTECTION_STACK) ; + RCPP_PROTECTION_STACK_READY = true ; } } From noreply at r-forge.r-project.org Fri Feb 15 12:00:15 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 15 Feb 2013 12:00:15 +0100 (CET) Subject: [Rcpp-commits] r4254 - in pkg/Rcpp: . R inst Message-ID: <20130215110016.69D7A184C93@r-forge.r-project.org> Author: jjallaire Date: 2013-02-15 12:00:14 +0100 (Fri, 15 Feb 2013) New Revision: 4254 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/R/Attributes.R pkg/Rcpp/TODO pkg/Rcpp/inst/NEWS.Rd Log: Merge existing values of build related environment variables for sourceCpp Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-12 15:52:30 UTC (rev 4253) +++ pkg/Rcpp/ChangeLog 2013-02-15 11:00:14 UTC (rev 4254) @@ -1,3 +1,8 @@ +2013-02-15 JJ Allaire + + * R/Attributes.R: Merge existing values of build related + environment variables for sourceCpp + 2013-02-12 Romain Francois * src/api.cpp : More careful about RCPP_PROTECTION_STACK init Modified: pkg/Rcpp/R/Attributes.R =================================================================== --- pkg/Rcpp/R/Attributes.R 2013-02-12 15:52:30 UTC (rev 4253) +++ pkg/Rcpp/R/Attributes.R 2013-02-15 11:00:14 UTC (rev 4254) @@ -438,10 +438,32 @@ # changes that were made .setupBuildEnvironment <- function(depends, plugins, sourceFile) { - # discover dependencies + # setup buildEnv <- list() linkingToPackages <- c("Rcpp") + # merge values into the buildEnv + mergeIntoBuildEnv <- function(name, value) { + + # protect against null or empty string + if (is.null(value) || !nzchar(value)) + return; + + # if it doesn't exist already just set it + if (is.null(buildEnv[[name]])) { + buildEnv[[name]] <<- value + } + # if it's not identical then append + else if (!identical(buildEnv[[name]], value)) { + buildEnv[[name]] <<- paste(buildEnv[[name]], value); + } + else { + # it already exists and it's the same value, this + # likely means it's a flag-type variable so we + # do nothing rather than appending it + } + } + # update dependencies from a plugin setDependenciesFromPlugin <- function(plugin) { @@ -451,21 +473,7 @@ # merge environment variables pluginEnv <- settings$env for (name in names(pluginEnv)) { - # if it doesn't exist already just set it - if (is.null(buildEnv[[name]])) { - buildEnv[[name]] <<- pluginEnv[[name]] - } - # if it's not identical then append - else if (!identical(buildEnv[[name]], - pluginEnv[[name]])) { - buildEnv[[name]] <<- paste(buildEnv[[name]], - pluginEnv[[name]]); - } - else { - # it already exists and it's the same value, this - # likely means it's a flag-type variable so we - # do nothing rather than appending it - } + mergeIntoBuildEnv(name, pluginEnv[[name]]) } # capture any LinkingTo elements defined by the plugin @@ -520,6 +528,10 @@ collapse=" ") } + # merge existing environment variables + for (name in names(buildEnv)) + mergeIntoBuildEnv(name, Sys.getenv(name)) + # add cygwin message muffler buildEnv$CYGWIN = "nodosfilewarning" Modified: pkg/Rcpp/TODO =================================================================== --- pkg/Rcpp/TODO 2013-02-12 15:52:30 UTC (rev 4253) +++ pkg/Rcpp/TODO 2013-02-15 11:00:14 UTC (rev 4254) @@ -120,6 +120,9 @@ o Support persistence of sourceCpp created functions across sessions (either via long-lived temp dir or via environment persistence) + o Additional high-level mechanism for specifying additional build + configuration (perhaps cxxflags and libs attributes) + Testing o all r* functions : rnorm, etc ... Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-02-12 15:52:30 UTC (rev 4253) +++ pkg/Rcpp/inst/NEWS.Rd 2013-02-15 11:00:14 UTC (rev 4254) @@ -17,6 +17,8 @@ the new \code{registerPlugin} function. \item Added built-in \code{cpp11} plugin for specifying the use of C++11 in a translation unit + \item Merge existing values of build related environment + variables for sourceCpp \item Stop with an error if the file name passed to \code{sourceCpp} has spaces in it \item Return invisibly from void functions From noreply at r-forge.r-project.org Sun Feb 17 13:27:42 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 17 Feb 2013 13:27:42 +0100 (CET) Subject: [Rcpp-commits] r4255 - pkg/Rcpp/inst Message-ID: <20130217122742.AD4751813E7@r-forge.r-project.org> Author: romain Date: 2013-02-17 13:27:42 +0100 (Sun, 17 Feb 2013) New Revision: 4255 Modified: pkg/Rcpp/inst/NEWS.Rd Log: mention wide character string support Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-02-15 11:00:14 UTC (rev 4254) +++ pkg/Rcpp/inst/NEWS.Rd 2013-02-17 12:27:42 UTC (rev 4255) @@ -34,6 +34,9 @@ treated as a stack instead of a pairlist in the R implementation \item Platform-dependent code in Timer.cpp now recognises a few more BSD variants thanks to contributed defined() test suggestions + \item support for wide character strings has been added throughout the + API. In particular String, CharacterVector, wrap and as are aware of + wide character strings } } } From noreply at r-forge.r-project.org Sun Feb 17 22:13:32 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 17 Feb 2013 22:13:32 +0100 (CET) Subject: [Rcpp-commits] r4256 - / scripts testlogs Message-ID: <20130217211332.F03A9184648@r-forge.r-project.org> Author: edd Date: 2013-02-17 22:13:32 +0100 (Sun, 17 Feb 2013) New Revision: 4256 Added: scripts/runRcppDepends.r testlogs/ testlogs/Rcpp-Summary-20130217.R testlogs/Rcpp-check-20130217-0745.txt Log: new (simple) script to run dependency checks, and a directory to collect logs Added: scripts/runRcppDepends.r =================================================================== --- scripts/runRcppDepends.r (rev 0) +++ scripts/runRcppDepends.r 2013-02-17 21:13:32 UTC (rev 4256) @@ -0,0 +1,41 @@ +#!/usr/bin/r + +cat("Started at ", format(Sys.time()), "\n") +library(parallel) + +setwd("/tmp/RcppDepends") + +AP <- available.packages(contrib.url("http://cran.r-project.org"),filter=list()) # available package at CRAN +rcppset <- sort(unname(AP[unique(c(grep("Rcpp", as.character(AP[,"Depends"])), + grep("Rcpp", as.character(AP[,"LinkingTo"])), + grep("Rcpp", as.character(AP[,"Imports"])))),"Package"])) +if (grep("transnet", rcppset)) { + print( rcppset[ ! grepl("transnet", rcppset) ]) +} else { + print( rcppset ) +} + +rcppset <- rcppset +res <- data.frame(pkg=rcppset, res=NA) + +#for (pi in 1:nrow(res)) { +#lres <- mclapply(1:nrow(res), mc.cores = 4, FUN=function(pi) { +lres <- lapply(1:nrow(res), FUN=function(pi) { + + p <- rcppset[pi] + i <- which(AP[,"Package"]==p) + pkg <- paste(AP[i,"Package"], "_", AP[i,"Version"], ".tar.gz", sep="") + pathpkg <- paste(AP[i,"Repository"], "/", pkg, sep="") + #print(pathpkg) + if (!file.exists(pkg)) download.file(pathpkg, pkg, quiet=TRUE) + rc <- system(paste("R CMD check --no-manual --no-vignettes ", pkg, " > ", pkg, ".log", sep="")) + res[pi, "res"] <- rc + cat(rc, ":", pkg, "\n") + res[pi, ] +}) + +res <- do.call(rbind, lres) +print(res) +write.table(res, file=paste("result-", strftime(Sys.time(), "%Y%m%d-%H%M%S"), ".txt", sep=""), sep=",") +save(res, file=paste("result-", strftime(Sys.time(), "%Y%m%d-%H%M%S"), ".RData", sep="")) +cat("Ended at ", format(Sys.time()), "\n") Property changes on: scripts/runRcppDepends.r ___________________________________________________________________ Added: svn:executable + * Added: testlogs/Rcpp-Summary-20130217.R =================================================================== --- testlogs/Rcpp-Summary-20130217.R (rev 0) +++ testlogs/Rcpp-Summary-20130217.R 2013-02-17 21:13:32 UTC (rev 4256) @@ -0,0 +1,64 @@ + +goodPkg <- c("acer", "ALKr", "Amelia", "apcluster", "bcp", "bfa", + "bfp", "bifactorial", "ccaPP", "cda", "clusteval", + "ConConPiWiFun", "ecp", "ExactNumCI", "fastGHQuad", "fdaMixed", "gof", + "growcurves", "GUTS", "KernSmoothIRT", "LaF", "minqa", + "multmod", "mvabund", "MVB", "NetworkAnalysis", "oem", + "openair", "parser", "phom", "phylobase", "planar", + "psgp", "quadrupen", "Rchemcpp", "Rclusterpp", + "RcppArmadillo", "RcppBDT", "rcppbugs", "RcppClassic", + "RcppClassicExamples", "RcppCNPy", "RcppDE", "RcppEigen", + "RcppExamples", "RcppGSL", "RcppOctave", "RcppRoll", + "RcppSMC", "RcppXts", "rexpokit", "rforensicbatwing", + "rgam", "RInside", "Rmalchains", "Rmessenger", "Rmixmod", + "robustgam", "robustHD", "rococo", "RProtoBuf", + "RQuantLib", "RSNNS", "RSofia", "rugarch", + "RVowpalWabbit", "SBSA", "simFrame", "sparseHessianFD", + "SpatialTools", "stochvol", "survSNP", "termstrc", "tmg", + "transmission", "transnet", "trustOptim", "unmarked", + "waffect", "wordcloud", "zic" ) + +badPkg <- c("auteur", "blockcluster", "classify", "EpiContactTrace", + "forecast", "fugeR", "GeneticTools", "gMWT", + "gRbase", "gRim", "jaatha", "marked", "maxent", "mets", + "mirt", "mMRMe", "ngspatial", "orQA", "pbdBASE", + "pbdDMAT", "PReMiuM", "sdcMicro", "sdcTable", "spacodir", + "sparseLTSEigen", "surveillance", "VIM", "WideLM" ) + +bad4missing <- c("auteur", # geiger + "classify", # R2WinBugs, R2jags + "EpiContactTrace", # ?igraph0? ?R2HTML? + "fugeR", # snowfall + "GeneticTools", # ?gMWT? ?snpStats? + "gMWT", # clinfun + "gRbase", # fastmatch RBGL + "gRim", # ?gRbase? ?gRain? ?doBy? + "jaatha", # ?phyclust? + "marked", # ?optimx? ?R2admb? + "maxent", # tm + "mets", # ?lava? ?timereg? ?prodlim? + "mirt", # ?psych? ?GPArotation? + "ngspatial", # ?batchmeans? + "orQA", # ?genefilter? + "pbdBASE", # ?pbdMPI? ?pbdSLAP? + "pdbDMAT", # ?pbdMPI? ?pbdSLAP? ?pbdBASE? + "PReMiuM", # clue + "sdcTable", # lpSolveAPI + "spacodir", # picante + "surveillance", # spatstat + "VIM" # vcd + ) + +bad4error <- c("blockcluster", # Eigen templates + "forecast", # REAL() mixup + "mMRMe", # SET_VECTOR_ELT() can only be applied to a 'list', not a 'integer' + "sdcMicro", # REAL() can only be applied to a 'numeric', not a 'character' + "sparseLTSEigen", # segfault in examples() + "WideLM") # CUDA needs gcc/g++ 4.5 + +cat("Good ", length(goodPkg), "\n") +cat("Bad ", length(badPkg), "\n") +cat(" MissDep ", length(bad4missing), "\n") +cat(" Errors ", length(bad4error), "\n") +cat("Total ", length(goodPkg)+length(badPkg), "\n") +cat("Error Pct ", length(bad4error)/(length(bad4error)+length(goodPkg)), "\n") Added: testlogs/Rcpp-check-20130217-0745.txt =================================================================== --- testlogs/Rcpp-check-20130217-0745.txt (rev 0) +++ testlogs/Rcpp-check-20130217-0745.txt 2013-02-17 21:13:32 UTC (rev 4256) @@ -0,0 +1,257 @@ +Started at 2013-02-17 07:46:30 + [1] "acer" "ALKr" "Amelia" + [4] "apcluster" "auteur" "bcp" + [7] "bfa" "bfp" "bifactorial" + [10] "blockcluster" "ccaPP" "cda" + [13] "classify" "clusteval" "ConConPiWiFun" + [16] "ecp" "EpiContactTrace" "ExactNumCI" + [19] "fastGHQuad" "fdaMixed" "forecast" + [22] "fugeR" "GeneticTools" "gMWT" + [25] "gof" "gRbase" "gRim" + [28] "growcurves" "GUTS" "jaatha" + [31] "KernSmoothIRT" "LaF" "marked" + [34] "maxent" "mets" "minqa" + [37] "mirt" "mRMRe" "multmod" + [40] "mvabund" "MVB" "NetworkAnalysis" + [43] "ngspatial" "oem" "openair" + [46] "orQA" "parser" "pbdBASE" + [49] "pbdDMAT" "phom" "phylobase" + [52] "planar" "PReMiuM" "psgp" + [55] "quadrupen" "Rchemcpp" "Rclusterpp" + [58] "RcppArmadillo" "RcppBDT" "rcppbugs" + [61] "RcppClassic" "RcppClassicExamples" "RcppCNPy" + [64] "RcppDE" "RcppEigen" "RcppExamples" + [67] "RcppGSL" "RcppOctave" "RcppRoll" + [70] "RcppSMC" "RcppXts" "rexpokit" + [73] "rforensicbatwing" "rgam" "RInside" + [76] "Rmalschains" "RMessenger" "Rmixmod" + [79] "robustgam" "robustHD" "rococo" + [82] "RProtoBuf" "RQuantLib" "RSNNS" + [85] "RSofia" "rugarch" "RVowpalWabbit" + [88] "SBSA" "sdcMicro" "sdcTable" + [91] "simFrame" "spacodiR" "sparseHessianFD" + [94] "sparseLTSEigen" "SpatialTools" "stochvol" + [97] "surveillance" "survSNP" "termstrc" +[100] "tmg" "transmission" "trustOptim" +[103] "unmarked" "VIM" "waffect" +[106] "WideLM" "wordcloud" "zic" +0 : acer_0.1.2.tar.gz +0 : ALKr_0.5.tar.gz +0 : Amelia_1.7.tar.gz +0 : apcluster_1.3.0.tar.gz +1 : auteur_0.12.1010.tar.gz +0 : bcp_3.0.1.tar.gz +0 : bfa_0.2.3.tar.gz +0 : bfp_0.0-25.tar.gz +0 : bifactorial_1.4.6.tar.gz +1 : blockcluster_1.01.tar.gz +0 : ccaPP_0.2.0.tar.gz +1 : cda_1.3.tar.gz +1 : classify_1.0.tar.gz +0 : clusteval_0.1.tar.gz +0 : ConConPiWiFun_0.3.tar.gz +0 : ecp_1.5.2.tar.gz +1 : EpiContactTrace_0.7.1.tar.gz +1 : ExactNumCI_1.0.0.tar.gz +0 : fastGHQuad_0.1-1.tar.gz +0 : fdaMixed_0.1.tar.gz +1 : forecast_4.01.tar.gz +1 : fugeR_0.1.2.tar.gz +1 : GeneticTools_0.1.tar.gz +1 : gMWT_0.2.tar.gz +0 : gof_0.8-2.tar.gz +1 : gRbase_1.6-7.tar.gz +1 : gRim_0.1-15.tar.gz +0 : growcurves_0.2.3.3.tar.gz +0 : GUTS_0.2.8.tar.gz +1 : jaatha_2.0.2.tar.gz +0 : KernSmoothIRT_3.0.tar.gz +0 : LaF_0.4.tar.gz +1 : marked_1.0.9.tar.gz +1 : maxent_1.3.2.tar.gz +1 : mets_0.1-13.tar.gz +0 : minqa_1.2.1.tar.gz +1 : mirt_0.5.0.tar.gz +1 : mRMRe_1.0.2.tar.gz +0 : multmod_0.9.tar.gz +0 : mvabund_3.6.11.tar.gz +0 : MVB_1.1.tar.gz +0 : NetworkAnalysis_0.3-1.tar.gz +1 : ngspatial_0.5-2.tar.gz +0 : oem_1.02.tar.gz +0 : openair_0.8-0.tar.gz +1 : orQA_0.2.1.tar.gz +0 : parser_0.1.tar.gz +1 : pbdBASE_0.1-1.tar.gz +1 : pbdDMAT_0.1-1.tar.gz +0 : phom_1.0.1.tar.gz +0 : phylobase_0.6.5.tar.gz +1 : planar_1.2.4.tar.gz +1 : PReMiuM_3.0.15.tar.gz +0 : psgp_0.3-1.tar.gz +0 : quadrupen_0.1-0.tar.gz +0 : Rchemcpp_1.0.6.tar.gz +0 : Rclusterpp_0.2.1.tar.gz +0 : RcppArmadillo_0.3.6.2.tar.gz +0 : RcppBDT_0.2.1.tar.gz +0 : rcppbugs_0.1.1.tar.gz +0 : RcppClassic_0.9.3.tar.gz +0 : RcppClassicExamples_0.1.1.tar.gz +0 : RcppCNPy_0.2.0.tar.gz +0 : RcppDE_0.1.1.tar.gz +0 : RcppEigen_0.3.1.2.1.tar.gz +0 : RcppExamples_0.1.6.tar.gz +0 : RcppGSL_0.2.0.tar.gz +0 : RcppOctave_0.8.12.tar.gz +0 : RcppRoll_0.1.0.tar.gz +0 : RcppSMC_0.1.1.tar.gz +0 : RcppXts_0.0.4.tar.gz +0 : rexpokit_0.24.tar.gz +0 : rforensicbatwing_1.1.tar.gz +0 : rgam_0.6.1.tar.gz +0 : RInside_0.2.10.tar.gz +0 : Rmalschains_0.1-2.tar.gz +0 : RMessenger_0.1.1.tar.gz +0 : Rmixmod_1.1.3.tar.gz +1 : robustgam_0.1.5.tar.gz +0 : robustHD_0.2.2.tar.gz +0 : rococo_1.1.0.tar.gz +0 : RProtoBuf_0.2.6.tar.gz +1 : RQuantLib_0.3.9.tar.gz +0 : RSNNS_0.4-3.tar.gz +0 : RSofia_1.1.tar.gz +0 : rugarch_1.0-16.tar.gz +0 : RVowpalWabbit_0.0.5.tar.gz +0 : SBSA_0.2.0.tar.gz +1 : sdcMicro_3.1.2.tar.gz +1 : sdcTable_0.10.2.tar.gz +0 : simFrame_0.5.0.tar.gz +1 : spacodiR_0.13.0115.tar.gz +0 : sparseHessianFD_0.1.0.tar.gz +1 : sparseLTSEigen_0.1.1.tar.gz +0 : SpatialTools_0.4.3.tar.gz +0 : stochvol_0.5-1.tar.gz +1 : surveillance_1.5-1.tar.gz +0 : survSNP_0.21-5.tar.gz +0 : termstrc_1.3.5.tar.gz +0 : tmg_0.1.tar.gz +0 : transmission_0.1.tar.gz +0 : transnet_0.1.tar.gz +0 : trustOptim_0.8.0.tar.gz +0 : unmarked_0.9-9.tar.gz +1 : VIM_3.0.3.tar.gz +0 : waffect_1.2.tar.gz +1 : WideLM_0.1-1.tar.gz +0 : wordcloud_2.2.tar.gz +0 : zic_0.7.5.tar.gz + pkg res +1 acer 0 +2 ALKr 0 +3 Amelia 0 +4 apcluster 0 +5 auteur 1 +6 bcp 0 +7 bfa 0 +8 bfp 0 +9 bifactorial 0 +10 blockcluster 1 +11 ccaPP 0 +12 cda 1 +13 classify 1 +14 clusteval 0 +15 ConConPiWiFun 0 +16 ecp 0 +17 EpiContactTrace 1 +18 ExactNumCI 1 +19 fastGHQuad 0 +20 fdaMixed 0 +21 forecast 1 +22 fugeR 1 +23 GeneticTools 1 +24 gMWT 1 +25 gof 0 +26 gRbase 1 +27 gRim 1 +28 growcurves 0 +29 GUTS 0 +30 jaatha 1 +31 KernSmoothIRT 0 +32 LaF 0 +33 marked 1 +34 maxent 1 +35 mets 1 +36 minqa 0 +37 mirt 1 +38 mRMRe 1 +39 multmod 0 +40 mvabund 0 +41 MVB 0 +42 NetworkAnalysis 0 +43 ngspatial 1 +44 oem 0 +45 openair 0 +46 orQA 1 +47 parser 0 +48 pbdBASE 1 +49 pbdDMAT 1 +50 phom 0 +51 phylobase 0 +52 planar 1 +53 PReMiuM 1 +54 psgp 0 +55 quadrupen 0 +56 Rchemcpp 0 +57 Rclusterpp 0 +58 RcppArmadillo 0 +59 RcppBDT 0 +60 rcppbugs 0 +61 RcppClassic 0 +62 RcppClassicExamples 0 +63 RcppCNPy 0 +64 RcppDE 0 +65 RcppEigen 0 +66 RcppExamples 0 +67 RcppGSL 0 +68 RcppOctave 0 +69 RcppRoll 0 +70 RcppSMC 0 +71 RcppXts 0 +72 rexpokit 0 +73 rforensicbatwing 0 +74 rgam 0 +75 RInside 0 +76 Rmalschains 0 +77 RMessenger 0 +78 Rmixmod 0 +79 robustgam 1 +80 robustHD 0 +81 rococo 0 +82 RProtoBuf 0 +83 RQuantLib 1 +84 RSNNS 0 +85 RSofia 0 +86 rugarch 0 +87 RVowpalWabbit 0 +88 SBSA 0 +89 sdcMicro 1 +90 sdcTable 1 +91 simFrame 0 +92 spacodiR 1 +93 sparseHessianFD 0 +94 sparseLTSEigen 1 +95 SpatialTools 0 +96 stochvol 0 +97 surveillance 1 +98 survSNP 0 +99 termstrc 0 +100 tmg 0 +101 transmission 0 +102 transnet 0 +103 trustOptim 0 +104 unmarked 0 +105 VIM 1 +106 waffect 0 +107 WideLM 1 +108 wordcloud 0 +109 zic 0 +Ended at 2013-02-17 09:24:31 From noreply at r-forge.r-project.org Mon Feb 18 08:55:24 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 18 Feb 2013 08:55:24 +0100 (CET) Subject: [Rcpp-commits] r4257 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/vector Message-ID: <20130218075524.445BC1833DC@r-forge.r-project.org> Author: romain Date: 2013-02-18 08:55:23 +0100 (Mon, 18 Feb 2013) New Revision: 4257 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/String.h pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h Log: make clang happy Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-17 21:13:32 UTC (rev 4256) +++ pkg/Rcpp/ChangeLog 2013-02-18 07:55:23 UTC (rev 4257) @@ -1,3 +1,9 @@ +2013-02-18 Romain Francois + + * include/Rcpp/vector/string_proxy.h : only declare operator+= + * include/Rcpp/String.h : define string_proxy::operator+=, now that + String is defined. + 2013-02-15 JJ Allaire * R/Attributes.R: Merge existing values of build related Modified: pkg/Rcpp/inst/include/Rcpp/String.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/String.h 2013-02-17 21:13:32 UTC (rev 4256) +++ pkg/Rcpp/inst/include/Rcpp/String.h 2013-02-18 07:55:23 UTC (rev 4257) @@ -390,8 +390,18 @@ return s.get_sexp() ; } + template + template + string_proxy& string_proxy::operator+=(const T& rhs) { + String tmp = get() ; + tmp += rhs ; + set( tmp ) ; + return *this ; + } + } + template <> inline SEXP wrap( const Rcpp::String& object) { RCPP_STRING_DEBUG( "wrap()" ) ; Modified: pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h 2013-02-17 21:13:32 UTC (rev 4256) +++ pkg/Rcpp/inst/include/Rcpp/vector/string_proxy.h 2013-02-18 07:55:23 UTC (rev 4257) @@ -101,12 +101,7 @@ * element this proxy refers to. */ template - string_proxy& operator+=(const T& rhs){ - String tmp = get() ; - tmp += rhs ; - set( tmp ) ; - return *this ; - } + string_proxy& operator+=(const T& rhs) ; /** * rhs use. Retrieves the current value of the From noreply at r-forge.r-project.org Mon Feb 18 17:23:16 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 18 Feb 2013 17:23:16 +0100 (CET) Subject: [Rcpp-commits] r4258 - pkg/RcppEigen/vignettes Message-ID: <20130218162316.D5E26183A40@r-forge.r-project.org> Author: edd Date: 2013-02-18 17:23:16 +0100 (Mon, 18 Feb 2013) New Revision: 4258 Added: pkg/RcppEigen/vignettes/jss.bst Removed: pkg/RcppEigen/vignettes/Rcpp.bib Modified: pkg/RcppEigen/vignettes/RcppEigen-Introduction.Rnw Log: Updated vignette to version in JSS, with proper short intro referencing paper and citation hint Removing Rcpp.bib as we now use an Sweave trick to use the Rcpp.bib which ships with Rcpp (and one currently needs the SVN version) Deleted: pkg/RcppEigen/vignettes/Rcpp.bib =================================================================== --- pkg/RcppEigen/vignettes/Rcpp.bib 2013-02-18 07:55:23 UTC (rev 4257) +++ pkg/RcppEigen/vignettes/Rcpp.bib 2013-02-18 16:23:16 UTC (rev 4258) @@ -1,492 +0,0 @@ - at String{CRAN = "http://CRAN.R-Project.org/" } - at String{manuals = CRAN # "doc/manuals/" } - at String{RCoreTeam = "{R Development Core Team}" } - at String{RFoundation = "R Foundation for Statistical Computing" } - at String{R-Forge = "http://R-Forge.R-Project.org/" } - - at Misc{cpp11, - author = "ISO/IEC", - organization = "{International Organization for Standardization}", - title = "\proglang{C++} 2011 Standard Document 14882:2011", - howpublished = {ISO/IEC Standard Group for Information Technology / Programming Languages / C++}, - year = 2011, - url = "http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372", - urlansi = "http://webstore.ansi.org/RecordDetail.aspx?sku=ISO/IEC%2014882:2011" -} - - at manual{Abrahams+Grosse-Kunstleve:2003:Boost.Python, - author = { David Abrahams and Ralf W. Grosse-Kunstleve }, - organization = "Boost Consulting", - title = "Building Hybrid Systems with Boost.Python", - year = 2003, - url = "http://www.boostpro.com/writing/bpl.pdf" -} - - at Book{Abrahams+Gurtovoy:2004:TemplateMetaprogramming, - author = {David Abrahams and Aleksey Gurtovoy}, - title = {\proglang{C++} {T}emplate {M}etaprogramming: Concepts, Tools - and Techniques from {B}oost and Beyond}, - publisher = {Addison-Wesley}, - year = 2004, - address = {Boston} -} - - at Manual{Armstrong:2009:RAbstraction, - title = {\pkg{RAbstraction}: \proglang{C++} abstraction for \proglang{R} objects}, - author = {Whit Armstrong}, - year = 2009, - note = {Code repository last updated 2009-07-22.}, - url = {http://github.com/armstrtw/rabstraction} -} - - at Manual{Armstrong:2009:RObjects, - title = {\pkg{RObjects}: \proglang{C++} wrapper for \proglang{R} objects (a better - implementation of {RAbstraction}}, - author = {Whit Armstrong}, - year = 2009, - note = {Code repository last updated 2009-11-28.}, - url = {http://github.com/armstrtw/RObjects} -} - - at InProceedings{Bates+DebRoy:2001:C++Classes, - author = {Douglas M. Bates and Saikat DebRoy}, - title = {\proglang{C++} Classes for \proglang{R} Objects}, - booktitle = {Proceedings of the 2nd International Workshop on Distributed - Statistical Computing, March 15--17, 2001, Technische - Universit\"at Wien, Vienna, Austria}, - editor = {Kurt Hornik and Friedrich Leisch}, - year = {2001}, - url = {http://www.ci.tuwien.ac.at/Conferences/DSC-2001/Proceedings/}, - note = {ISSN 1609-395X} -} - - - at Misc{Brokken:2011:Cpp, - author = {Frank B. Brokken}, - title = {\proglang{C++} Annotations}, - howpublished = {Electronic book, University of Groningen}, - year = 2012, - note = {version 9.4.0}, - url = {http://www.icce.rug.nl/documents/cplusplus/} -} - - at Book{Chambers:2008:SoDA, - author = {John M. Chambers}, - title = {Software for Data Analysis: Programming with \proglang{R}}, - publisher = {Springer-Verlag}, - year = 2008, - series = {Statistics and Computing}, - address = {Heidelberg}, - note = {{ISBN} 978-0-387-75935-7} -} - - at Manual{CRAN:RInside, - title = {\pkg{RInside}: \proglang{C++} classes to embed \proglang{R} in \proglang{C++} applications}, - author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2012, - note = {R package version 0.2.8}, - url = CRAN # "package=RInside" -} - - at Manual{CRAN:RProtoBuf, - title = {\pkg{RProtoBuf}: \proglang{R} Interface to the Protocol Buffers API}, - author = {Romain Fran\c{c}ois and Dirk Eddelbuettel}, - year = 2012, - note = {R package version 0.2.5}, - url = CRAN # "package=RProtoBuf" -} - - at Manual{CRAN:RQuantLib, - title = {\pkg{RQuantLib}: \proglang{R} interface to the {QuantLib} library}, - author = {Dirk Eddelbuettel and Khanh Nguyen}, - year = 2011, - note = {R package version 0.3.8}, - url = CRAN # "package=RQuantLib" -} - - at Article{JSS:Rcpp, - title = {\pkg{Rcpp}: Seamless \proglang{R} and \proglang{C++} Integration}, - author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - journal = {Journal of Statistical Software}, - year = 2011, - volume = 40, - number = 8, - pages = {1--18}, - url = {http://www.jstatsoft.org/v40/i08/}, -} - - at Manual{CRAN:Rcpp, - title = {\pkg{Rcpp}: Seamless \proglang{R} and \proglang{C++} Integration}, - author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2012, - note = {R package version 0.9.13}, - url = CRAN # "package=Rcpp" -} - - at Manual{CRAN:RcppArmadillo, - title = {\pkg{RcppArmadillo}: \pkg{Rcpp} integration for Armadillo - templated linear algebra library}, - author = {Romain Fran\c{c}ois and Dirk Eddelbuettel and - Douglas Bates}, - year = 2012, - note = {R package version 0.3.2.4}, - url = CRAN # "package=RcppArmadillo" -} - - at Manual{CRAN:RcppClassic, - title = {\pkg{RcppClassic}: Deprecated 'classic' \pkg{Rcpp} API}, - author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2012, - note = {R package version 0.9.2}, - url = CRAN # "package=RcppClassic" -} - - at Manual{CRAN:RcppDE, - title = {\pkg{RcppDE}: Global optimization by differential evolution in \proglang{C++}}, - author = {Dirk Eddelbuettel}, - year = 2012, - note = {R package version 0.1.1}, - url = CRAN # "package=RcppDE" -} - - at Manual{CRAN:RcppExamples, - title = {\pkg{RcppExamples}: Examples using \pkg{Rcpp} to interface \proglang{R} - and \proglang{C++}}, - author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2012, - note = {R package version 0.1.2}, - url = CRAN # "package=RcppExamples" -} - - at Manual{CRAN:RcppGSL, - title = {\pkg{RcppGSL}: \pkg{Rcpp} integration for GNU GSL vectors and matrices}, - author = {Romain Fran\c{c}ois and Dirk Eddelbuettel}, - year = 2012, - note = {R package version 0.2.0}, - url = CRAN # "package=RcppGSL" -} - - at Manual{CRAN:Rserve, - title = {\pkg{Rserve}: Binary R server}, - author = {Simon Urbanek}, - year = 2012, - note = {R package version 0.6-8}, - url = CRAN # "package=Rserve" -} - - at Manual{CRAN:cxxPack, - title = {\pkg{cxxpack}: \proglang{R}/\proglang{C++} Tools for Literate Statistical - Practice}, - author = {Dominick Samperi}, - year = 2010, - note = {R package version 7.0.6, now removed from the archive}, - url = CRAN # "package=cxxPack" -} - - at Manual{CRAN:highlight, - title = {\pkg{highlight}: Syntax highlighter}, - author = {Romain Fran\c{c}ois}, - year = 2012, - note = {R package version 0.3.2}, - url = CRAN # "package=highlight" -} - - at Manual{CRAN:inline, - title = {\pkg{inline}: Inline \proglang{C}, \proglang{C++}, - \proglang{Fortran} function calls from \proglang{R}}, - author = {Oleg Sklyar and Duncan Murdoch and Mike Smith and - Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2010, - note = {R package version 0.3.8}, - url = CRAN # "package=inline" -} - - at Manual{CRAN:Matrix, - title = {\pkg{Matrix}: Sparse and Dense Matrix Classes and Methods}, - author = {Douglas Bates and Martin Maechler}, - year = 2012, - note = {R package version 1.0-9}, - url = CRAN # "package=Matrix" -} - - at Manual{CRAN:minqa, - title = {\pkg{minqa}: Derivative-free optimization algorithms by - quadratic approximation}, - author = {Douglas Bates and Katharine M. Mullen and John - C. Nash and Ravi Varadhan}, - year = 2012, - note = {R package version 1.2.1}, - url = CRAN # "package=minqa" -} - - at Manual{CRAN:rbenchmark, - title = {\pkg{rbenchmark}: Benchmarking routine for \proglang{R}}, - author = {Wacek Kusnierczyk}, - year = 2012, - note = {R package version 1.0.0}, - url = CRAN # "package=rbenchmark" -} - -; see http://eigen.tuxfamily.org/index.php?title=BibTeX -; replaced 'howpublished' with 'url' and updated year to 2011, and again to 2012 - at MISC{Eigen:Web, - author = {Ga\"{e}l Guennebaud and Beno\^{i}t Jacob and others}, - title = {Eigen v3}, - year = 2012, - url = {http://eigen.tuxfamily.org}, -} - - at Article{Gropp+Lusk+Doss+Skjellum:1996:MPI, - author = {William Gropp and Ewing Lusk and Nathan Doss and Anthony Skjellum}, - title = {A high-performance, portable implementation of the {MPI} message passing interface standard}, - journal = {Parallel Computing}, - year = 1996, - url = {http://dx.doi.org/10.1016/0167-8191(96)00024-5}, - volume = 22, - number = 6, - pages = {789--828} -} - - at Book{Gropp+Lusk+Skjellum:1999:MPI, - author = {William Gropp and Ewing Lusk and Anthony Skjellum}, - title = {Using {MPI}: Portable Parallel Programming with the Message Passing Interface}, - publisher = {MIT Press}, - year = 1999, - series = {Scientific and Engineering Computation Series}, - edition = {2nd}, - month = {November}, - note = {{ISBN} 978-0-262-57132-6}} - - at Manual{GSL, - title = {{GNU} {S}cientific {L}ibrary {R}eference {M}anual}, - author = {Mark Galassi and Jim Davies and James Theiler and Brian Gough and Gerard Jungman and Patrick Alken and Michael Booth and Fabrice Rossi}, - year = {2010}, - edition = {3rd}, - note = {Version 1.14. {ISBN} 0954612078}, - url = {http://www.gnu.org/software/gsl} -} - - at Unpublished{Java+Gaile+Manly:2007:RCpp, - author = {James J. Java and Daniel P. Gaile and Kenneth - E. Manly}, - title = {{R/Cpp}: Interface Classes to Simplify Using \proglang{R} - Objects in \proglang{C++} Extensions}, - note = {Unpublished manuscript, University at Buffalo}, - url = - {http://sphhp.buffalo.edu/biostat/research/techreports/UB_Biostatistics_TR0702.pdf}, - month = {July}, - year = 2007 -} - - at InProceedings{Leisch:2008:Tutorial, - author = {Friedrich Leisch}, - title = {Tutorial on {C}reating \proglang{R} {P}ackages}, - booktitle = {COMPSTAT 2008 -- Proceedings in Computational - Statistics}, - year = 2008, - editor = {Paula Brito}, - address = {Heidelberg}, - publisher = {Physica Verlag}, - url = CRAN # "doc/contrib/Leisch-CreatingPackages.pdf" -} - - at Manual{Liang:2008:rcppbind, - title = {\pkg{rcppbind}: {A} template library for \proglang{R}/\proglang{C++} developers}, - author = {Gang Liang}, - year = 2008, - note = {R package version 1.0}, - url = R-Forge # "projects/rcppbind" -} - - at Book{Lippman+Lajoie+Moo:2005:Cpp_Primer, - author = {Stanley B. Lippman and Jos\'{e}e Lajoie and Barbara E. Moo}, - title = {The \proglang{C++} Primer}, - publisher = {Addison-Wesley}, - address = {Boston}, - year = 2005, - edition = {4th} -} - - at book{Meyers:1995:MoreEffectiveC++, - author = {Scott Meyers}, - title = {More Effective \proglang{C++}: 35 New Ways to Improve Your - Programs and Designs}, - year = 1995, - note = {{ISBN} 020163371X}, - publisher = {Addison-Wesley}, - address = {Boston} -} - - at book{Meyers:2001:EffectiveSTL, - author = {Scott Meyers}, - title = {Effective STL: 50 specific ways to improve your use - of the standard template library}, - year = 2001, - note = {{ISBN} 0-201-74962-9}, - publisher = {Addison-Wesley}, - address = {Essex} -} - - at book{Meyers:2005:EffectiveC++, - author = {Scott Meyers}, - title = {Effective \proglang{C++}: 55 Specific Ways to Improve Your - Programs and Designs}, - year = 2005, - note = {{ISBN} 978-0321334879}, - publisher = {Addison-Wesley}, - address = {Boston}, - edition = {3rd}, -} - - at Book{Plauger+Et+Al:2000:STL, - author = {P.J. Plauger and Alexander Stepanov and Meng Lee and - David R. Musser}, - title = {The \proglang{C++} Standard Template Library}, - publisher = {Prentice Hall PTR}, - year = 2000, - note = {{ISBN} 978-0134376332}, -} - - at manual{R:Administration, - author = RCoreTeam, - organization = RFoundation, - address = {Vienna, Austria}, - year = 2012, - title = "\proglang{R} Installation and Administration", - note = {{ISBN} 3-900051-09-7}, - url = manuals # "R-admin.html" -} - - at manual{R:Extensions, - author = RCoreTeam, - organization = RFoundation, - address = {Vienna, Austria}, - year = 2012, - title = "Writing \proglang{R} Extensions", - note = {{ISBN} 3-900051-11-9}, - url = manuals # "R-exts.html" -} - - at manual{R:Internals, - author = RCoreTeam, - organization = RFoundation, - address = {Vienna, Austria}, - year = 2012, - title = "\proglang{R} Internals", - note = {{ISBN} 3-900051-14-3}, - url = manuals # "R-ints.html" -} - - at manual{R:Main, - title = {\proglang{R}: A Language and Environment for Statistical - Computing}, - author = RCoreTeam, - organization = RFoundation, - address = {Vienna, Austria}, - year = 2012, - note = {{ISBN} 3-900051-07-0}, - url = {http://www.R-project.org/}, -} - - at manual{R:Language, - author = RCoreTeam, - organization = RFoundation, - address = {Vienna, Austria}, - year = 2012, - title = "\proglang{R} language", - note = {{ISBN} 3-900051-13-5}, - url = manuals # "R-lang.html" -} - - at InProceedings{Runnalls:2009:CXXR, - author = {Andrew Runnalls}, - title = {Aspects of {CXXR} internals}, - booktitle = {Directions in Statistical Computing}, - address = {University of Copenhagen, Denmark}, - year = 2009 -} - - at Manual{Samperi:2009:RcppTemplate, - title = {\pkg{RcppTemplate}: Rcpp \proglang{R}/\proglang{C++} Object Mapping Library - and Package Template}, - author = {Dominick Samperi}, - year = 2009, - note = {(Archived) R package version 6.1}, - url = CRAN # "/src/contrib/Archive/RcppTemplate" -} - - at TechReport{Sanderson:2010:Armadillo, - author = {Conrad Sanderson}, - title = {{Armadillo}: {An} open source \proglang{C++} Algebra Library - for Fast Prototyping and Computationally Intensive - Experiments }, - institution = {{NICTA}}, - year = 2010, - url = "http://arma.sf.net" -} - - at Book{Stroustrup:1997:Cpp, - author = {Bjarne Stroustrup}, - title = {The \proglang{C++} Programming Language}, - publisher = {Addison-Wesley}, - address = {Boston}, - year = 1997, - edition = {3rd} -} - - at Article{TempleLang:2009:ModestProposal, - author = {Duncan {Temple Lang}}, - title = {A modest proposal: an approach to making the - internal \proglang{R} system extensible}, - journal = {Computational Statistics}, - year = 2009, - volume = 24, - number = 2, - pages = {271-281}, - month = {May} -} - - at Article{TempleLang:2009:RGCCTranslationUnit, - author = {Duncan {Temple Lang}}, - title = {Working with meta-data from \proglang{C}/\proglang{C++} code in \proglang{R}: the - {RGCCTranslationUnit} package}, - journal = {Computational Statistics}, - year = 2009, - volume = 24, - number = 2, - pages = {283-293}, - month = {May} -} - - at InProceedings{Urbanek:2003:Rserve, - author = {Simon Urbanek}, - title = {\pkg{Rserve}: A Fast Way to Provide \proglang{R} Functionality to - Applications}, - booktitle = {Proceedings of the 3rd International Workshop on Distributed - Statistical Computing, Vienna, Austria}, - editor = {Kurt Hornik and Friedrich Leisch and Achim Zeileis}, - year = {2003}, - url = {http://www.ci.tuwien.ac.at/Conferences/DSC-2003/Proceedings/}, - note = {{ISSN 1609-395X}} -} - - at Book{Vandevoorde+Josuttis:2003:Templates, - author = {David Vandevoorde and Nicolai M. Josuttis}, - title = {\proglang{C++} {T}emplates: The Complete Guide}, - publisher = {Addison-Wesley}, - year = 2003, - address = {Boston} -} - - at inproceedings{Veldhuizen:1998:Blitz, - author = {Todd L. Veldhuizen}, - title = {Arrays in {Blitz++}}, - booktitle = {ISCOPE '98: Proceedings of the Second International - Symposium on Computing in Object-Oriented Parallel - Environments}, - note = {{ISBN} 3-540-65387-2}, - year = 1998, - pages = {223--230}, - publisher = {Springer-Verlag}, - address = {London}, -} Modified: pkg/RcppEigen/vignettes/RcppEigen-Introduction.Rnw =================================================================== --- pkg/RcppEigen/vignettes/RcppEigen-Introduction.Rnw 2013-02-18 07:55:23 UTC (rev 4257) +++ pkg/RcppEigen/vignettes/RcppEigen-Introduction.Rnw 2013-02-18 16:23:16 UTC (rev 4258) @@ -1,5 +1,5 @@ \documentclass[shortnames,article,nojss]{jss} -\usepackage{booktabs,bm,amsmath} +\usepackage{booktabs,bm,amsmath,thumbpdf} %\VignetteIndexEntry{RcppEigen-intro} %\VignetteKeywords{linear algebra, template programming, C++, R, Rcpp} %\VignettePackage{RcppEigen} @@ -13,21 +13,18 @@ #eigenVersion <- paste(unlist(.Call("eigen_version", FALSE)), collapse=".") @ -\author{Douglas Bates\\Univ.~of Wisconsin/Madison \And Dirk Eddelbuettel\\Debian Project} -\title{Fast and Elegant Numerical Linear Algebra\\ Using the \pkg{RcppEigen} Package} -\date{\pkg{RcppEigen} version 0.3.1 as of September 26, 2012} - +\author{Douglas Bates\\University of Wisconsin-Madison \And Dirk Eddelbuettel\\Debian Project} \Plainauthor{Douglas Bates, Dirk Eddelbuettel} + +\title{Fast and Elegant Numerical Linear Algebra Using the \pkg{RcppEigen} Package} \Plaintitle{Fast and Elegant Numerical Linear Algebra Using the RcppEigen Package} -\Shorttitle{Fast and Elegant Numerical Linear Algebra with RcppEigen} +\Shorttitle{Fast and Elegant Numerical Linear Algebra with \pkg{RcppEigen}} - \Abstract{ - \noindent The \pkg{RcppEigen} package provides access from \proglang{R} \citep{R:Main} to the \pkg{Eigen} \citep*{Eigen:Web} \proglang{C++} template library for numerical linear algebra. \pkg{Rcpp} - \citep{JSS:Rcpp,CRAN:Rcpp} classes and specializations of the + \citep{CRAN:Rcpp,Eddelbuettel:2013:Rcpp} classes and specializations of the \proglang{C++} templated functions \code{as} and \code{wrap} from \pkg{Rcpp} provide the ``glue'' for passing objects from \proglang{R} to \proglang{C++} and back. Several introductory @@ -37,26 +34,27 @@ comparison. Last but not least, sparse matrix methods are discussed. } -\Keywords{Linear algebra, template programming, \proglang{R}, \proglang{C++}, \pkg{Rcpp}} %% at least one keyword must be supplied -\Plainkeywords{Linear algebra, template programmig, R, C++, Rcpp} %% without formatting +\Keywords{linear algebra, template programming, \proglang{R}, \proglang{C++}, \pkg{Rcpp}} +\Plainkeywords{linear algebra, template programmig, R, C++, Rcpp} \Address{ Douglas Bates \\ Department of Statistics \\ - University of Wisconsin - Madison \\ - Madison, WI, USA \\ + University of Wisconsin-Madison \\ + Madison, WI, United States of America \\ E-mail: \email{bates at stat.wisc.edu} \\ URL: \url{http://www.stat.wisc.edu/~bates/}\\ Dirk Eddelbuettel \\ Debian Project \\ - River Forest, IL, USA\\ + River Forest, IL, United States of America\\ E-mail: \email{edd at debian.org}\\ URL: \url{http://dirk.eddelbuettel.com}\\ } %% need no \usepackage{Sweave.sty} +\newcommand{\argmin}{\operatorname{argmin}\displaylimits} \newcommand{\rank}{\operatorname{rank}} %% highlights macros @@ -66,9 +64,7 @@ \newcommand{\hlnum}[1]{\textcolor[rgb]{0,0,0}{#1}} \newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}} \newcommand{\hlesc}[1]{\textcolor[rgb]{0.74,0.55,0.55}{#1}} -%\newcommand{\hlstr}[1]{\textcolor[rgb]{0.74,0.55,0.55}{#1}} \newcommand{\hlstr}[1]{\textcolor[rgb]{0.90,0.15,0.15}{#1}} -%green: \newcommand{\hlstr}[1]{\textcolor[rgb]{0.13,0.67,0.13}{#1}} % 0.74 -> % 0.90; 0.55 -> 0.25 \newcommand{\hldstr}[1]{\textcolor[rgb]{0.74,0.55,0.55}{#1}} \newcommand{\hlslc}[1]{\textcolor[rgb]{0.67,0.13,0.13}{\it{#1}}} \newcommand{\hlcom}[1]{\textcolor[rgb]{0.67,0.13,0.13}{\it{#1}}} @@ -88,11 +84,11 @@ \SweaveOpts{engine=R,eps=FALSE} \begin{quote} \footnotesize - This vignette corresponds to a paper forthcoming %published - in the \textsl{Journal of Statistical Software}. % fill in vol,nb later - It is currently still identical to the published paper. Over time, this - vignette version may receive minor - updates. %For citations, please use the publication \citep{JSS:RcppEigen}. + This vignette corresponds to a + \href{http://www.jstatsoft.org/v52/i05/}{paper published} in the + \textsl{Journal of Statistical Software}. Currently still identical + to the paper, this vignette version may over time receive minor updates. + For citations, please use \citet{JSS:RcppEigen} as provided by \code{citation("RcppEigen")}. This version corresponds to \pkg{RcppEigen} version \Sexpr{pkgVersion} and was typeset on \Sexpr{prettyDate}. @@ -103,7 +99,7 @@ Linear algebra is an essential building block of statistical computing. Operations such as matrix decompositions, linear program -solvers, and eigenvalue / eigenvector computations are used in many +solvers, and eigenvalue/eigenvector computations are used in many estimation and analysis routines. As such, libraries supporting linear algebra have long been provided by statistical programmers for different programming languages and environments. Because it is @@ -112,10 +108,9 @@ representing matrices, vectors and decompositions, and numerous class libraries providing linear algebra routines have been written over the years. -% Could cite Eddelbuettel (1996) here, but a real survey would be better. As both the \proglang{C++} language and standards have evolved -\citep{Meyers:2005:EffectiveC++,Meyers:1995:MoreEffectiveC++,cpp11}, +\citep{Meyers:2005:EffectiveC++,Meyers:1995:MoreEffectiveC++,Cpp11}, so have the compilers implementing the language. Relatively modern language constructs such as template meta-programming are particularly useful because they provide overloading of operations (allowing @@ -135,28 +130,30 @@ KDE (a popular Linux desktop environment), initially focussing on fixed-size matrices to represent projections in a visualization application. \pkg{Eigen} grew from there and has over the course of about a decade produced three -major releases with ``Eigen3'' being the current major version. To +major releases with \pkg{Eigen}3 being the current major version. To check the minor and patch version numbers, load the \pkg{RcppEigen} package and call -\begin{verbatim} +\begin{CodeInput} R> .Call("eigen_version", FALSE) -major minor patch - 3 1 1 -\end{verbatim} - +\end{CodeInput} +\begin{CodeOutput} +major minor patch + 3 1 1 +\end{CodeOutput} \pkg{Eigen} is of interest as the \proglang{R} system for statistical computation and graphics \citep{R:Main} is itself easily extensible. This is particular true via the \proglang{C} language that most of \proglang{R}'s compiled core parts are written in, but also for the \proglang{C++} language which can interface with \proglang{C}-based systems rather easily. The manual -``Writing R Extensions'' \citep{R:Extensions} is the basic reference for +``Writing \proglang{R} Extensions'' \citep{R:Extensions} is the basic reference for extending \proglang{R} with either \proglang{C} or \proglang{C++}. The \pkg{Rcpp} package by \citet{JSS:Rcpp,CRAN:Rcpp} facilitates extending \proglang{R} with \proglang{C++} code by providing seamless object mapping between both languages. % -As stated in the \pkg{Rcpp} \citep{CRAN:Rcpp} vignette, ``Extending \pkg{Rcpp}'' +As stated in the \pkg{Rcpp} \citep{CRAN:Rcpp} vignette, ``Extending +\pkg{Rcpp}'' as well as in \citet{Eddelbuettel:2013:Rcpp} \begin{quote} \pkg{Rcpp} facilitates data interchange between \proglang{R} and \proglang{C++} through the templated functions \code{Rcpp::as} (for @@ -191,12 +188,13 @@ \code{typedef}s for common classes that correspond to \proglang{R} matrices and vectors, as shown in Table~\ref{tab:REigen}, and this paper will use these \code{typedef}s. -\begin{table}[tb] + +\begin{table}[t!] \centering \begin{tabular}{l l} - \toprule + \hline \multicolumn{1}{c}{\proglang{R} object type} & \multicolumn{1}{c}{\pkg{Eigen} class typedef}\\ - \midrule + \hline numeric matrix & \code{MatrixXd}\\ integer matrix & \code{MatrixXi}\\ complex matrix & \code{MatrixXcd}\\ @@ -204,10 +202,10 @@ integer vector & \code{VectorXi}\\ complex vector & \code{VectorXcd}\\ \code{Matrix::dgCMatrix} \phantom{XXX} & \code{SparseMatrix}\\ - \bottomrule + \hline \end{tabular} - \caption{Correspondence between \proglang{R} matrix and vector types and classes in the \pkg{Eigen} namespace.} - \label{tab:REigen} + \caption{Correspondence between \proglang{R} matrix and vector types and classes in the \pkg{Eigen} namespace. + \label{tab:REigen}} \end{table} Here, \code{Vector} and \code{Matrix} describe the dimension of the @@ -221,16 +219,6 @@ \pkg{Eigen} namespace, which means that they must be written as \code{Eigen::MatrixXd}. However, if one prefaces the use of these class names with a declaration like - -%% Alternatively, use 'highlight --enclose-pre --no-doc -O latex --syntax=C++' -%% as the command invoked from C-u M-| -%% For version 3.5 of highlight this should be -%% highlight --enclose-pre --no-doc --out-format=latex --syntax=C++ -%% -%% keep one copy to redo later -%% -%% using Eigen::MatrixXd; -%% \begin{quote} \noindent \ttfamily @@ -239,6 +227,9 @@ \normalfont \normalsize \end{quote} + +\vspace*{-0.4cm} + then one can use these names without the namespace qualifier. \subsection[Mapped matrices in Eigen]{Mapped matrices in \pkg{Eigen}} @@ -308,6 +299,9 @@ \mbox{} \normalfont \end{quote} + +\vspace*{-0.4cm} + where \code{AA} is the name of the \proglang{R} object (of type \code{SEXP} in \proglang{C} and \proglang{C++}) passed to the \proglang{C++} function. @@ -324,6 +318,8 @@ \normalsize \end{quote} +\vspace*{-0.4cm} + The \code{cxxfunction} function from the \pkg{inline} package \citep*{CRAN:inline} for \proglang{R} and its \pkg{RcppEigen} plugin provide a convenient method of developing and debugging the \proglang{C++} code. For actual production code @@ -348,24 +344,29 @@ \label{sec:transpose} The next \proglang{R} code snippet creates a simple matrix of integers -\begin{verbatim} -R> (A <- matrix(1:6, ncol=2)) +\begin{CodeInput} +R> (A <- matrix(1:6, ncol = 2)) +\end{CodeInput} +\begin{CodeOutput} [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 +\end{CodeOutput} +\begin{CodeInput} R> str(A) +\end{CodeInput} +\begin{CodeOutput} int [1:3, 1:2] 1 2 3 4 5 6 -\end{verbatim} +\end{CodeOutput} and, in Figure~\ref{trans}, the \code{transpose()} method for the \code{Eigen::MatrixXi} class is used to return the transpose of the supplied matrix. The \proglang{R} matrix in the \code{SEXP} \code{AA} is first mapped to an \code{Eigen::MatrixXi} object, and then the matrix \code{At} is constructed from its transpose and returned to \proglang{R}. -\begin{figure}[htb] +\begin{figure}[t!] \hrule \smallskip - %\begin{quote} \noindent \ttfamily \hlstd{}\hlkwa{using\ }\hlstd{Eigen}\hlsym{::}\hlstd{Map}\hlsym{;}\hspace*{\fill}\\ @@ -376,10 +377,9 @@ \hlstd{}\hlkwb{const\ }\hlstd{MatrixXi}\hlstd{\ \ \ \ \ \ }\hlstd{}\hlkwd{At}\hlstd{}\hlsym{(}\hlstd{A}\hlsym{.}\hlstd{}\hlkwd{transpose}\hlstd{}\hlsym{());}\hspace*{\fill}\\ \hlstd{}\hlkwa{return\ }\hlstd{}\hlkwd{wrap}\hlstd{}\hlsym{(}\hlstd{At}\hlsym{);}\hlstd{}\hspace*{\fill} \normalfont - %\end{quote} \hrule - \caption{\code{transCpp}: Transpose a matrix of integers.} - \label{trans} + \caption{\code{transCpp}: Transpose a matrix of integers. + \label{trans}} \end{figure} The \proglang{R} snippet below compiles and links the \proglang{C++} code @@ -392,15 +392,19 @@ an executable function which is assigned to \code{ftrans}. This new function is used on the matrix $\bm A$ shown above, and one can check that it works as intended by comparing the output to an explicit transpose of the matrix argument. -\begin{verbatim} -R> ftrans <- cxxfunction(signature(AA="matrix"), transCpp, plugin="RcppEigen") +\begin{CodeInput} +R> ftrans <- cxxfunction(signature(AA = "matrix"), transCpp, ++ plugin = "RcppEigen") R> (At <- ftrans(A)) +\end{CodeInput} +\begin{CodeOutput} [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 +\end{CodeOutput} +\begin{CodeInput} R> stopifnot(all.equal(At, t(A))) -\end{verbatim} - +\end{CodeInput} For numeric or integer matrices the \code{adjoint()} method is equivalent to the \code{transpose()} method. For complex matrices, the adjoint is the conjugate of the transpose. In keeping with the @@ -408,7 +412,6 @@ method is used in what follows to create the transpose of numeric or integer matrices. -\pagebreak % Achim may hate me \subsection{Products and cross-products} \label{sec:products} @@ -417,11 +420,10 @@ classes in \pkg{Eigen}. The \proglang{C++} code in Figure~\ref{prod} produces a list containing both the product and cross-product (in the sense of the \proglang{R} function call -\code{crossproduct(A, B)} evaluating $\bm A^\prime\bm B$) of its two arguments - -\begin{figure}[htb] +\code{crossproduct(A, B)} evaluating $\bm A^\top\bm B$) of its two arguments +% +\begin{figure}[t!] \hrule \smallskip - %\begin{quote} \noindent \ttfamily \hlstd{}\hlkwc{typedef\ }\hlstd{Eigen}\hlopt{::}\hlstd{Map}\hlopt{$<$}\hlstd{Eigen}\hlopt{::}\hlstd{MatrixXi}\hlopt{$>$}\hlstd{\ \ \ }\hlopt{}\hlstd{MapMati}\hlopt{;}\hspace*{\fill}\\ @@ -432,23 +434,27 @@ \mbox{} \normalfont \normalsize - %\end{quote} \hrule - \caption{\code{prodCpp}: Product and cross-product of two matrices.} - \label{prod} + \caption{\code{prodCpp}: Product and cross-product of two matrices. + \label{prod}} \end{figure} - -\begin{verbatim} +% +\begin{CodeInput} R> fprod <- cxxfunction(signature(BB = "matrix", CC = "matrix"), -+ prodCpp, "RcppEigen") -R> B <- matrix(1:4, ncol=2) -R> C <- matrix(6:1, nrow=2) ++ prodCpp, "RcppEigen") +R> B <- matrix(1:4, ncol = 2) +R> C <- matrix(6:1, nrow = 2) R> str(fp <- fprod(B, C)) +\end{CodeInput} +\begin{CodeOutput} List of 2 $ B %*% C : int [1:2, 1:3] 21 32 13 20 5 8 $ crossprod(B, C): int [1:2, 1:3] 16 38 10 24 4 10 +\end{CodeOutput} +\begin{CodeInput} R> stopifnot(all.equal(fp[[1]], B %*% C), all.equal(fp[[2]], crossprod(B, C))) -\end{verbatim} +\end{CodeInput} +% Note that the \code{create} class method for \code{Rcpp::List} implicitly applies \code{Rcpp::wrap} to its arguments. @@ -458,10 +464,10 @@ As shown in the last example, the \proglang{R} function \code{crossprod} calculates the product of the transpose of its first argument with its second argument. The single argument form, -\code{crossprod(X)}, evaluates $\bm X^\prime\bm X$. One could, of +\code{crossprod(X)}, evaluates $\bm X^\top\bm X$. One could, of course, calculate this product as \begin{verbatim} -t(X) %*% X + t(X) %*% X \end{verbatim} but \code{crossprod(X)} is roughly twice as fast because the result is known to be symmetric and only one triangle needs to be calculated. @@ -485,13 +491,12 @@ \code{UnitUpper} or \code{StrictlyUpper}. For self-adjoint views the \code{rankUpdate} method adds a scalar multiple -of $\bm A\bm A^\prime$ to the current symmetric matrix. The scalar +of $\bm A\bm A^\top$ to the current symmetric matrix. The scalar multiple defaults to 1. The code in Figure~\ref{crossprod} produces -both $\bm A^\prime\bm A$ and $\bm A\bm A^\prime$ from a matrix $\bm A$. +both $\bm A^\top\bm A$ and $\bm A\bm A^\top$ from a matrix $\bm A$. -\begin{figure}[htb] +\begin{figure}[t!] \hrule \smallskip - %\begin{quote} \noindent \ttfamily \hlstd{}\hlkwa{using\ }\hlstd{Eigen}\hlopt{::}\hlstd{Map}\hlopt{;}\hspace*{\fill}\\ @@ -509,30 +514,32 @@ \hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{Named}\hlopt{{(}}\hlstd{}\hlstr{"tcrossprod(A)"}\hlstd{}\hlopt{{)}\ =\ }\hlstd{AAt}\hlopt{);}\hlstd{}\hspace*{\fill} \normalfont \normalsize - %\end{quote} \hrule - \caption{\code{crossprodCpp}: Cross-product and transposed cross-product of a single matrix.} - \label{crossprod} + \caption{\code{crossprodCpp}: Cross-product and transposed cross-product of a single matrix. + \label{crossprod}} \end{figure} -\begin{verbatim} +\begin{CodeInput} R> fcprd <- cxxfunction(signature(AA = "matrix"), crossprodCpp, "RcppEigen") R> str(crp <- fcprd(A)) +\end{CodeInput} +\begin{CodeOutput} List of 2 $ crossprod(A) : int [1:2, 1:2] 14 32 32 77 $ tcrossprod(A): int [1:3, 1:3] 17 22 27 22 29 36 27 36 45 +\end{CodeOutput} +\begin{CodeInput} R> stopifnot(all.equal(crp[[1]], crossprod(A)), -+ all.equal(crp[[2]], tcrossprod(A))) -\end{verbatim} - ++ all.equal(crp[[2]], tcrossprod(A))) +\end{CodeInput} To some, the expressions in Figure~\ref{crossprod} to construct \code{AtA} and \code{AAt} are compact and elegant. To others they are hopelessly confusing. If you find yourself in the latter group, you just need to read the expression left to right. So, for example, we [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/rcpp -r 4258 From noreply at r-forge.r-project.org Mon Feb 18 17:25:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 18 Feb 2013 17:25:25 +0100 (CET) Subject: [Rcpp-commits] r4259 - pkg/Rcpp/inst/doc Message-ID: <20130218162525.13B67183A40@r-forge.r-project.org> Author: edd Date: 2013-02-18 17:25:24 +0100 (Mon, 18 Feb 2013) New Revision: 4259 Modified: pkg/Rcpp/inst/doc/Rcpp.bib Log: some additions needed by RcppEigen vignette which now uses it Modified: pkg/Rcpp/inst/doc/Rcpp.bib =================================================================== --- pkg/Rcpp/inst/doc/Rcpp.bib 2013-02-18 16:23:16 UTC (rev 4258) +++ pkg/Rcpp/inst/doc/Rcpp.bib 2013-02-18 16:25:24 UTC (rev 4259) @@ -4,6 +4,16 @@ @String{RFoundation = "R Foundation for Statistical Computing" } @String{R-Forge = "http://R-Forge.R-Project.org/" } + at Misc{Cpp11, + author = "ISO/IEC", + organization = "{International Organization for Standardization}", + title = "\proglang{C++} 2011 Standard Document 14882:2011", + howpublished = {ISO/IEC Standard Group for Information Technology / Programming Languages / C++}, + year = 2011, + url = "http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372", + urlansi = "http://webstore.ansi.org/RecordDetail.aspx?sku=ISO/IEC%2014882:2011" +} + @manual{Abrahams+Grosse-Kunstleve:2003:Boost.Python, author = { David Abrahams and Ralf W. Grosse-Kunstleve }, organization = "Boost Consulting", @@ -102,6 +112,14 @@ url = CRAN # "package=RQuantLib" } + at Manual{CRAN:rbenchmark, + title = {\pkg{rbenchmark}: Benchmarking routine for \proglang{R}}, + author = {Wacek Kusnierczyk}, + year = 2012, + note = {R package version 1.0.0}, + url = CRAN # "package=rbenchmark" +} + @Article{JSS:Rcpp, title = {{Rcpp}: Seamless {R} and {C++} Integration}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, @@ -147,6 +165,27 @@ url = CRAN # "package=RcppDE" } + at Manual{CRAN:RcppEigen, + title = {RcppEigen: Rcpp integration for the Eigen templated linear + algebra library}, + author = {Douglas Bates and Romain Fran\c{c}ois and Dirk Eddelbuettel}, + year = 2012, + note = {{R} package version 0.3.1.2}, + url = CRAN # "package=RcppEigen" +} + + at Article{JSS:RcppEigen, + title = {Fast and Elegant Numerical Linear Algebra Using the + {RcppEigen} Package}, + author = {Douglas Bates and Dirk Eddelbuettel}, + journal = {Journal of Statistical Software}, + year = {2013}, + volume = {52}, + number = {5}, + pages = {1--24}, + url = {http://www.jstatsoft.org/v52/i05/}, +} + @Manual{CRAN:RcppExamples, title = {RcppExamples: Examples using {Rcpp} to interface {R} and {C++}}, @@ -199,6 +238,14 @@ url = CRAN # "package=inline" } + at Manual{CRAN:Matrix, + title = {\pkg{Matrix}: Sparse and Dense Matrix Classes and Methods}, + author = {Douglas Bates and Martin Maechler}, + year = 2012, + note = {R package version 1.0-9}, + url = CRAN # "package=Matrix" +} + @Manual{CRAN:minqa, title = {minqa: Derivative-free optimization algorithms by quadratic approximation}, @@ -217,6 +264,24 @@ url = CRAN # "package=roxygen2" } + at Book{Eddelbuettel:2013:Rcpp, + author = {Dirk Eddelbuettel}, + title = {Seamless R and C++ Integration with Rcpp}, + publisher = {Springer}, + year = 2013, + address = {New York}, + isbn = {978-1-4614-6867-7} +} + +; see http://eigen.tuxfamily.org/index.php?title=BibTeX +; replaced 'howpublished' with 'url' and updated year to 2011, and again to 2012 + at MISC{Eigen:Web, + author = {Ga\"{e}l Guennebaud and Beno\^{i}t Jacob and others}, + title = {Eigen v3}, + year = 2012, + url = {http://eigen.tuxfamily.org}, +} + @Book{Gentleman:2009:RProgramming, author = {Robert Gentleman}, title = {R Programming for Bioinformatics}, From noreply at r-forge.r-project.org Mon Feb 18 17:59:17 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 18 Feb 2013 17:59:17 +0100 (CET) Subject: [Rcpp-commits] r4260 - pkg/Rcpp/inst/doc Message-ID: <20130218165917.C38E1184BCD@r-forge.r-project.org> Author: edd Date: 2013-02-18 17:59:17 +0100 (Mon, 18 Feb 2013) New Revision: 4260 Modified: pkg/Rcpp/inst/doc/Rcpp.bib Log: updated version Modified: pkg/Rcpp/inst/doc/Rcpp.bib =================================================================== --- pkg/Rcpp/inst/doc/Rcpp.bib 2013-02-18 16:25:24 UTC (rev 4259) +++ pkg/Rcpp/inst/doc/Rcpp.bib 2013-02-18 16:59:17 UTC (rev 4260) @@ -135,7 +135,7 @@ title = {{Rcpp}: Seamless {R} and {C++} Integration}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, year = 2012, - note = {R package version 0.9.13}, + note = {R package version 0.10.2}, url = CRAN # "package=Rcpp" } From noreply at r-forge.r-project.org Mon Feb 18 17:59:49 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 18 Feb 2013 17:59:49 +0100 (CET) Subject: [Rcpp-commits] r4261 - pkg/Rcpp Message-ID: <20130218165949.16314184BCD@r-forge.r-project.org> Author: edd Date: 2013-02-18 17:59:48 +0100 (Mon, 18 Feb 2013) New Revision: 4261 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/DESCRIPTION Log: minor version 0.10.2.4 some whitespace cleanup from Emacs Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-18 16:59:17 UTC (rev 4260) +++ pkg/Rcpp/ChangeLog 2013-02-18 16:59:48 UTC (rev 4261) @@ -1,8 +1,8 @@ 2013-02-18 Romain Francois - * include/Rcpp/vector/string_proxy.h : only declare operator+= - * include/Rcpp/String.h : define string_proxy::operator+=, now that - String is defined. + * include/Rcpp/vector/string_proxy.h : only declare operator+= + * include/Rcpp/String.h : define string_proxy::operator+=, now that + String is defined. 2013-02-15 JJ Allaire @@ -15,18 +15,17 @@ 2013-02-08 Romain Francois - * include/Rcpp/as.h: re-enable as( CharacterVector[int] ) - + * include/Rcpp/as.h: re-enable as(CharacterVector[int]) 2013-02-07 Dirk Eddelbuettel * inst/THANKS: Adding Ben North for the help / bug report on iterators 2013-02-05 Romain Francois - * include/Rcpp/vector/string_proxy.h : more wstring support - * include/Rcpp/XPtr.h : more debugging. removed delete_finalizer which is - no longer used - + * include/Rcpp/vector/string_proxy.h : more wstring support + * include/Rcpp/XPtr.h : more debugging. removed delete_finalizer + which is no longer used + 2013-02-05 JJ Allaire * src/attributes.cpp : ensure that line comments invalidate block @@ -34,37 +33,42 @@ 2013-02-04 Romain Francois - * include/Rcpp/traits/r_type_traits.h : make the r_type_pairstring_string_tag tag - more general, handling wstring as well as string - * include/Rcpp/internal/wrap.h : using make_charsexp, a more generic version - of charsexp_from_wstring. + * include/Rcpp/traits/r_type_traits.h : make the + r_type_pairstring_string_tag tag more general, handling wstring as + well as string + * include/Rcpp/internal/wrap.h : using make_charsexp, a more generic + version of charsexp_from_wstring. * include/Rcpp/as.h : more support fot wstring * include/Rcpp/internal/wrap.h : rework the support of wstring - * include/Rcpp/internal/export.h : added as_string_elt to rework the support - of wstring - * include/Rcpp/traits/char_type.h : new trait to help the wstring support - * include/Rcpp/String.h : added some support for wstring - * include/Rcpp/vector/string_proxy.h : adapt to add wstring support + * include/Rcpp/internal/export.h : added as_string_elt to rework the + support of wstring + * include/Rcpp/traits/char_type.h : new trait to help the wstring + support + * include/Rcpp/String.h : added some support for wstring + * include/Rcpp/vector/string_proxy.h : adapt to add wstring support * unitTests/runit.wstring.R : unit tests for wstring support * unitTests/cpp/wstring.cpp : unit tests for wstring support - + 2013-02-03 Romain Francois * include/Rcpp/traits/wrap_type_traits.h : support for wrap( wstring ) - * include/Rcpp/internal/export.h : exporting wstring and containers of wstring - * include/Rcpp/internal/wrap.h : support for wrap( wstring ) and containers of wstring + * include/Rcpp/internal/export.h : exporting wstring and containers + of wstring + * include/Rcpp/internal/wrap.h : support for wrap( wstring ) and + containers of wstring * include/RcppCommon.h : definition of charsexp_from_wstring * src/api.cpp: implementation of charsexp_from_wstring 2013-02-02 Romain Francois - * include/Rcpp/vector/MatrixRow.h: correct operator++(int) and operator--(int) + * include/Rcpp/vector/MatrixRow.h: correct operator++(int) and + operator--(int) * include/Rcpp/internal/Proxy_Iterator.h: correct operators ++ and -- * include/Rcpp/sugar/Range.h: correct operators ++ and -- * include/Rcpp/sugar/tools/iterator.h: correct operators ++ and -- * include/Rcpp/vector/MatrixBase.h : correct operators ++ and -- * include/Rcpp/vector/VectorBase.h : correct operators ++ and -- - * unitTests/cpp/Vector.cpp: new unit tests + * unitTests/cpp/Vector.cpp: new unit tests * unitTests/runit.Vector.R: new unit tests * src/api.cpp: comment dropTrailing0 which is not used anymore * include/Rcpp/as.h: support for as @@ -74,7 +78,7 @@ * src/api.cpp (Rcpp): Commented-out coerce_to_string() for real and complex arguments as R-devel (as of today) dislikes use of non-API - functions Rf_EncodeComplex?, ?Rf_EncodeReal?, ?Rf_formatComplex? + functions Rf_EncodeComplex?, ?Rf_EncodeReal?, ?Rf_formatComplex? * .Rbuildignore: Added inst/include/Rcpp/preprocessor and sugar/functions/impl which are currently empty directories @@ -95,16 +99,16 @@ * R/tools.R: handle build paths with spaces on windows * src/Timer.cpp: fix OSX build (remove __MACH__ define check) * R/: set svn eol-style native for source files - * src/: set svn eol-style native for source files - * inst/include/: set svn eol-style native for source files + * src/: set svn eol-style native for source files + * inst/include/: set svn eol-style native for source files 2014-01-13 JJ Allaire - * R/Attributes.R: use plugin includes in cppFunction; stop with - explicit error on Windows then the Rcpl libPath or sourceCpp - target file contains spaces in it's path; add source file directory - as an include path for sourceCpp; special handling for sourceCpp - include paths on windows + * R/Attributes.R: use plugin includes in cppFunction; stop with + explicit error on Windows then the Rcpl libPath or sourceCpp target + file contains spaces in it's path; add source file directory as an + include path for sourceCpp; special handling for sourceCpp include + paths on windows * man/pluginsAttribute.Rd: clarify which fields of plugin are used by sourceCpp Modified: pkg/Rcpp/DESCRIPTION =================================================================== --- pkg/Rcpp/DESCRIPTION 2013-02-18 16:59:17 UTC (rev 4260) +++ pkg/Rcpp/DESCRIPTION 2013-02-18 16:59:48 UTC (rev 4261) @@ -1,6 +1,6 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.10.2.3 +Version: 0.10.2.4 Date: $Date$ Author: Dirk Eddelbuettel and Romain Francois, with contributions by Douglas Bates, John Chambers and JJ Allaire From noreply at r-forge.r-project.org Tue Feb 19 16:36:59 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 19 Feb 2013 16:36:59 +0100 (CET) Subject: [Rcpp-commits] r4262 - in pkg/Rcpp: . inst/include inst/include/Rcpp/api/meat inst/include/Rcpp/internal inst/include/Rcpp/vector src Message-ID: <20130219153659.921B8184DB0@r-forge.r-project.org> Author: romain Date: 2013-02-19 16:36:57 +0100 (Tue, 19 Feb 2013) New Revision: 4262 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h pkg/Rcpp/inst/include/Rcpp/internal/wrap.h pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h pkg/Rcpp/inst/include/Rcpp/vector/Vector.h pkg/Rcpp/inst/include/Rcpp/vector/traits.h pkg/Rcpp/inst/include/RcppCommon.h pkg/Rcpp/src/api.cpp Log: correct wrap( MatrixRow) Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-18 16:59:48 UTC (rev 4261) +++ pkg/Rcpp/ChangeLog 2013-02-19 15:36:57 UTC (rev 4262) @@ -1,3 +1,11 @@ +2013-02-19 Romain Francois + + * src/api.cpp : more debugging + * include/RcppCommon.h : move sexp_to_name here. Used in some debugging + * include/Rcpp/vector/MatrixRow.h : fix const version of operator[] + * include/Rcpp/vector/Vector.h : more debugging + * include/Rcpp/internal/wrap.h : more debugging. more dispatch. + 2013-02-18 Romain Francois * include/Rcpp/vector/string_proxy.h : only declare operator+= Modified: pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h 2013-02-18 16:59:48 UTC (rev 4261) +++ pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h 2013-02-19 15:36:57 UTC (rev 4262) @@ -2,7 +2,7 @@ // // Vector.h: Rcpp R/C++ interface class library -- Vector meat // -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -57,12 +57,12 @@ template Vector::Vector( const Dimension& dims ) : RObject( Rf_allocVector( RTYPE, dims.prod() ) ){ - RCPP_DEBUG_3( "Vector<%d>( const Dimension& (%d) ) m_sexp = <%p>", RTYPE, dims.size(), m_sexp ) + RCPP_DEBUG_3( "Vector<%s>( const Dimension& (%d) ) m_sexp = <%p>", sexp_to_name(RTYPE), dims.size(), m_sexp ) update_vector(); init() ; if( dims.size() > 1 ){ RObject::attr( "dim" ) = dims; - } + } } template @@ -720,7 +720,16 @@ return false ; } + namespace internal { + template + inline SEXP wrap_range_sugar_expression( const T& object, Rcpp::traits::true_type) { + RCPP_DEBUG_1( "wrap_range_sugar_expression<%s>(., true )", DEMANGLE(T) ) + const int RTYPE = T::r_type::value ; + return Rcpp::Vector(object) ; + } + + } } // namespace Rcpp Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-18 16:59:48 UTC (rev 4261) +++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-02-19 15:36:57 UTC (rev 4262) @@ -435,6 +435,7 @@ */ template inline SEXP wrap_dispatch_unknown( const T& object, ::Rcpp::traits::true_type ){ + RCPP_DEBUG_1( "wrap_dispatch_unknown<%s>(., false )", DEMANGLE(T) ) // here we know (or assume) that T is convertible to SEXP SEXP x = object ; return x ; @@ -453,7 +454,8 @@ */ template inline SEXP wrap_dispatch_unknown_iterable(const T& object, ::Rcpp::traits::false_type){ - // here we know that T is not convertible to SEXP +RCPP_DEBUG_1( "wrap_dispatch_unknown_iterable<%s>(., false )", DEMANGLE(T) ) + // here we know that T is not convertible to SEXP #ifdef HAS_STATIC_ASSERT static_assert( !sizeof(T), "cannot convert type to SEXP" ) ; #else @@ -466,6 +468,7 @@ template inline SEXP wrap_dispatch_unknown_iterable__logical( const T& object, ::Rcpp::traits::true_type){ + RCPP_DEBUG_1( "wrap_dispatch_unknown_iterable__logical<%s>(., true )", DEMANGLE(T) ) size_t size = object.size() ; SEXP x = PROTECT( Rf_allocVector( LGLSXP, size ) ); std::copy( object.begin(), object.end(), LOGICAL(x) ) ; @@ -474,13 +477,23 @@ } template -inline SEXP wrap_dispatch_unknown_iterable__logical( const T& object, ::Rcpp::traits::false_type){ +inline SEXP wrap_range_sugar_expression( const T& object, Rcpp::traits::false_type){ + RCPP_DEBUG_1( "wrap_range_sugar_expression<%s>(., false )", DEMANGLE(T) ) return range_wrap( object.begin(), object.end() ) ; } +template +inline SEXP wrap_range_sugar_expression( const T& object, Rcpp::traits::true_type) ; +template +inline SEXP wrap_dispatch_unknown_iterable__logical( const T& object, ::Rcpp::traits::false_type){ + RCPP_DEBUG_1( "wrap_dispatch_unknown_iterable__logical<%s>(., false )", DEMANGLE(T) ) + return wrap_range_sugar_expression( object, typename Rcpp::traits::is_sugar_expression::type() ) ; +} + template inline SEXP wrap_dispatch_unknown_iterable__matrix_interface( const T& object, ::Rcpp::traits::false_type ){ + RCPP_DEBUG_1( "wrap_dispatch_unknown_iterable__matrix_interface<%s>(., false )", DEMANGLE(T) ) return wrap_dispatch_unknown_iterable__logical( object, typename ::Rcpp::traits::expands_to_logical::type() ); } @@ -567,6 +580,7 @@ template inline SEXP wrap_dispatch_unknown_iterable__matrix_interface( const T& object, ::Rcpp::traits::true_type ){ + RCPP_DEBUG_1( "wrap_dispatch_unknown_iterable__matrix_interface<%s>(., true )", DEMANGLE(T) ) return wrap_dispatch_matrix_logical( object, typename ::Rcpp::traits::expands_to_logical::type() ) ; } @@ -585,6 +599,7 @@ */ template inline SEXP wrap_dispatch_unknown_iterable(const T& object, ::Rcpp::traits::true_type){ + RCPP_DEBUG_1( "wrap_dispatch_unknown_iterable<%s>(., true )", DEMANGLE(T) ) return wrap_dispatch_unknown_iterable__matrix_interface( object, typename ::Rcpp::traits::matrix_interface::type() ) ; } @@ -661,6 +676,7 @@ */ template inline SEXP wrap_dispatch_unknown( const T& object, ::Rcpp::traits::false_type){ + RCPP_DEBUG_1( "wrap_dispatch_unknown<%s>(., false )", DEMANGLE(T) ) return wrap_dispatch_unknown_iterable( object, typename ::Rcpp::traits::has_iterator::type() ) ; } // }}} @@ -692,11 +708,13 @@ template inline SEXP wrap_dispatch_eigen( const T& object, ::Rcpp::traits::false_type){ + RCPP_DEBUG_1( "wrap_dispatch_eigen<%s>(., false )", DEMANGLE(T) ) return wrap_dispatch_unknown( object, typename ::Rcpp::traits::is_convertible::type() ) ; } template inline SEXP wrap_dispatch_eigen( const T& object, ::Rcpp::traits::true_type){ + RCPP_DEBUG_1( "wrap_dispatch_eigen<%s>(., true )", DEMANGLE(T) ) return ::Rcpp::RcppEigen::eigen_wrap( object ) ; } @@ -707,6 +725,7 @@ */ template inline SEXP wrap_dispatch_unknown_importable( const T& object, ::Rcpp::traits::false_type){ + RCPP_DEBUG_1( "wrap_dispatch_unknown_importable<%s>(., false )", DEMANGLE(T) ) return wrap_dispatch_eigen( object, typename traits::is_eigen_base::type() ) ; } @@ -715,6 +734,7 @@ */ template inline SEXP wrap_dispatch_unknown_importable( const T& object, ::Rcpp::traits::true_type){ + RCPP_DEBUG_1( "wrap_dispatch_unknown_importable<%s>(., true )", DEMANGLE(T) ) return wrap_dispatch_importer( object ) ; } @@ -725,6 +745,7 @@ */ template inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_unknown_tag ){ + RCPP_DEBUG_1( "wrap_dispatch<%s>(., wrap_type_unknown_tag )", DEMANGLE(T) ) return wrap_dispatch_unknown_importable( object, typename ::Rcpp::traits::is_importer::type() ) ; } // }}} Modified: pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h 2013-02-18 16:59:48 UTC (rev 4261) +++ pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h 2013-02-19 15:36:57 UTC (rev 4262) @@ -28,6 +28,7 @@ typedef Matrix MATRIX ; typedef typename MATRIX::Proxy Proxy ; typedef typename MATRIX::Proxy reference ; + typedef typename MATRIX::const_Proxy const_reference ; typedef typename MATRIX::value_type value_type ; class iterator { @@ -101,7 +102,8 @@ MatrixRow( MATRIX& object, int i ) : parent(object), start(parent.begin() + i), - parent_nrow(parent.nrow()) + parent_nrow(parent.nrow()), + row(i) { if( i < 0 || i >= parent.nrow() ) throw index_out_of_bounds() ; } @@ -109,7 +111,8 @@ MatrixRow( const MatrixRow& other ) : parent(other.parent), start(other.start), - parent_nrow(other.parent_nrow) + parent_nrow(other.parent_nrow), + row(other.row) {} ; template @@ -131,7 +134,7 @@ } inline reference operator[]( int i ) const { - return start[ get_parent_index(i) ] ; + return parent[ row + i * parent_nrow ] ; } inline iterator begin(){ @@ -158,9 +161,11 @@ MATRIX& parent; typename MATRIX::iterator start ; int parent_nrow ; + int row ; inline int get_parent_index(int i) const { RCPP_DEBUG_4( "MatrixRow<%d>[%p]::get_parent_index(%d) = %d", RTYPE, this, i, i*parent_nrow) + Rprintf( "MatrixRow::get_parent_index(int = %d), parent_nrow = %d >> %d\n", i, parent_nrow, i*parent_nrow ) ; return i * parent_nrow ; } } ; Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h 2013-02-18 16:59:48 UTC (rev 4261) +++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h 2013-02-19 15:36:57 UTC (rev 4262) @@ -439,6 +439,7 @@ return INTEGER( ::Rf_getAttrib( RObject::m_sexp, R_DimSymbol ) ) ; } void init(){ + RCPP_DEBUG_2( "VECTOR<%d>::init( SEXP = <%p> )", RTYPE, RObject::m_sexp ) internal::r_init_vector(RObject::m_sexp) ; } Modified: pkg/Rcpp/inst/include/Rcpp/vector/traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/traits.h 2013-02-18 16:59:48 UTC (rev 4261) +++ pkg/Rcpp/inst/include/Rcpp/vector/traits.h 2013-02-19 15:36:57 UTC (rev 4262) @@ -36,7 +36,7 @@ r_vector_cache() : start(0){} ; inline void update( const VECTOR& v ) { - start = ::Rcpp::internal::r_vector_start(v.asSexp()) ; + start = ::Rcpp::internal::r_vector_start(v.asSexp()) ; RCPP_DEBUG_3( " cache<%d>::update( <%p> ), start = <%p>", RTYPE, reinterpret_cast(v.asSexp()), reinterpret_cast(start) ) } inline iterator get() const { return start; } Modified: pkg/Rcpp/inst/include/RcppCommon.h =================================================================== --- pkg/Rcpp/inst/include/RcppCommon.h 2013-02-18 16:59:48 UTC (rev 4261) +++ pkg/Rcpp/inst/include/RcppCommon.h 2013-02-19 15:36:57 UTC (rev 4262) @@ -23,7 +23,7 @@ #ifndef RcppCommon_h #define RcppCommon_h -// #define RCPP_DEBUG_LEVEL 0 +// #define RCPP_DEBUG_LEVEL 1 #include #include @@ -39,6 +39,11 @@ #include #include +#ifdef __cplusplus +extern "C" +#endif +const char * sexp_to_name(int sexp_type); + /** * \brief Rcpp API */ Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-02-18 16:59:48 UTC (rev 4261) +++ pkg/Rcpp/src/api.cpp 2013-02-19 15:36:57 UTC (rev 4262) @@ -1355,11 +1355,26 @@ namespace Rcpp{ namespace internal{ - template<> int* r_vector_start(SEXP x){ return INTEGER(x) ; } - template<> int* r_vector_start(SEXP x){ return LOGICAL(x) ; } - template<> double* r_vector_start(SEXP x){ return REAL(x) ; } - template<> Rbyte* r_vector_start(SEXP x){ return RAW(x) ; } - template<> Rcomplex* r_vector_start(SEXP x){ return COMPLEX(x) ; } + template<> int* r_vector_start(SEXP x){ + RCPP_DEBUG_1( "r_vector_start( SEXP = %p )", x ) + return INTEGER(x) ; + } + template<> int* r_vector_start(SEXP x){ + RCPP_DEBUG_1( "r_vector_start( SEXP = %p )", x ) + return LOGICAL(x) ; + } + template<> double* r_vector_start(SEXP x){ + RCPP_DEBUG_1( "r_vector_start( SEXP = %p )", x ) + return REAL(x) ; + } + template<> Rbyte* r_vector_start(SEXP x){ + RCPP_DEBUG_1( "r_vector_start( SEXP = %p )", x ) + return RAW(x) ; + } + template<> Rcomplex* r_vector_start(SEXP x){ + RCPP_DEBUG_1( "r_vector_start( SEXP = %p )", x ) + return COMPLEX(x) ; + } template<> void r_init_vector(SEXP x){} template<> void r_init_vector(SEXP x){} From noreply at r-forge.r-project.org Wed Feb 20 03:12:15 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Feb 2013 03:12:15 +0100 (CET) Subject: [Rcpp-commits] r4263 - in pkg/RcppCNPy: . inst src Message-ID: <20130220021215.EB2911842E0@r-forge.r-project.org> Author: edd Date: 2013-02-20 03:12:14 +0100 (Wed, 20 Feb 2013) New Revision: 4263 Modified: pkg/RcppCNPy/ChangeLog pkg/RcppCNPy/DESCRIPTION pkg/RcppCNPy/inst/NEWS.Rd pkg/RcppCNPy/src/cnpy.cpp pkg/RcppCNPy/src/cnpy.h Log: add R_NO_REMAP to avoid clashes when length() etc are redefined suppress one noisy message from g++ in pedantic mode Modified: pkg/RcppCNPy/ChangeLog =================================================================== --- pkg/RcppCNPy/ChangeLog 2013-02-19 15:36:57 UTC (rev 4262) +++ pkg/RcppCNPy/ChangeLog 2013-02-20 02:12:14 UTC (rev 4263) @@ -1,3 +1,11 @@ +2013-02-19 Dirk Eddelbuettel + + * src/cnpy.h: Define R_NO_REMAP before including Rinternals to not + define length(), error(), ... but rather Rf_length(), Rf_error() + + * src/cnpy.cpp: Add a bogus unused variable at the never-reached end + of code (after an error exit) to silence the pedantic mode of g++ + 2012-07-30 Dirk Eddelbuettel * DESCRIPTION: Version 0.2.0 Modified: pkg/RcppCNPy/DESCRIPTION =================================================================== --- pkg/RcppCNPy/DESCRIPTION 2013-02-19 15:36:57 UTC (rev 4262) +++ pkg/RcppCNPy/DESCRIPTION 2013-02-20 02:12:14 UTC (rev 4263) @@ -1,7 +1,7 @@ Package: RcppCNPy Type: Package Title: Rcpp bindings for NumPy files -Version: 0.2.0 +Version: 0.2.0.1 Date: $Date$ Author: Dirk Eddelbuettel Maintainer: Dirk Eddelbuettel Modified: pkg/RcppCNPy/inst/NEWS.Rd =================================================================== --- pkg/RcppCNPy/inst/NEWS.Rd 2013-02-19 15:36:57 UTC (rev 4262) +++ pkg/RcppCNPy/inst/NEWS.Rd 2013-02-20 02:12:14 UTC (rev 4263) @@ -2,6 +2,13 @@ \title{News for Package \pkg{RcppCNPy}} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{Changes in version 0.2.1 (2013-02-19)}{ + \itemize{ + \item Ensure that inclusion of \code{Rinternal.h} does not affect + other headers by adding RF_NO_REMAP + } +} + \section{Changes in version 0.2.0 (2012-07-30)}{ \itemize{ \item Support for writing of \code{gzip}-ed \code{npy} files has Modified: pkg/RcppCNPy/src/cnpy.cpp =================================================================== --- pkg/RcppCNPy/src/cnpy.cpp 2013-02-19 15:36:57 UTC (rev 4262) +++ pkg/RcppCNPy/src/cnpy.cpp 2013-02-20 02:12:14 UTC (rev 4263) @@ -231,6 +231,8 @@ fclose(fp); Rf_error("npz_load: Error! Variable name %s not found in %s!\n",varname.c_str(),fname.c_str()); // never reached -- not satisfying -Wall -pedantic + NpyArray unused; + return unused; } cnpy::NpyArray cnpy::npy_load(std::string fname) { Modified: pkg/RcppCNPy/src/cnpy.h =================================================================== --- pkg/RcppCNPy/src/cnpy.h 2013-02-19 15:36:57 UTC (rev 4262) +++ pkg/RcppCNPy/src/cnpy.h 2013-02-20 02:12:14 UTC (rev 4263) @@ -22,6 +22,8 @@ #ifdef RCPP_HAS_LONG_LONG_TYPES #include // for std::int64_t, needs c++11 switch #endif + +#define R_NO_REMAP #include // for Rf_error namespace cnpy { From noreply at r-forge.r-project.org Wed Feb 20 12:53:00 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Feb 2013 12:53:00 +0100 (CET) Subject: [Rcpp-commits] r4264 - pkg/Rcpp Message-ID: <20130220115300.DD0DF181059@r-forge.r-project.org> Author: jjallaire Date: 2013-02-20 12:53:00 +0100 (Wed, 20 Feb 2013) New Revision: 4264 Modified: pkg/Rcpp/TODO Log: todo on exposing modules from sourceCpp Modified: pkg/Rcpp/TODO =================================================================== --- pkg/Rcpp/TODO 2013-02-20 02:12:14 UTC (rev 4263) +++ pkg/Rcpp/TODO 2013-02-20 11:53:00 UTC (rev 4264) @@ -123,6 +123,8 @@ o Additional high-level mechanism for specifying additional build configuration (perhaps cxxflags and libs attributes) + o Allow definition of Rcpp modules within sourceCpp code + Testing o all r* functions : rnorm, etc ... From noreply at r-forge.r-project.org Wed Feb 20 13:17:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Feb 2013 13:17:58 +0100 (CET) Subject: [Rcpp-commits] r4265 - in pkg/RcppArmadillo: . inst inst/include/armadillo_bits Message-ID: <20130220121758.256A6183B91@r-forge.r-project.org> Author: edd Date: 2013-02-20 13:17:57 +0100 (Wed, 20 Feb 2013) New Revision: 4265 Modified: pkg/RcppArmadillo/ChangeLog pkg/RcppArmadillo/DESCRIPTION pkg/RcppArmadillo/inst/NEWS.Rd pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_iterators_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eGlueCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eGlue_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eOpCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_conv_to.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_eps.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_mean.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_misc.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_norm.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_rank.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_reshape.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_svd.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_times_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cx_scalar_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_find_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_inv_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_mean_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_var_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_var_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_elem1_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_elem2_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/unwrap.hpp Log: Release 0.3.6.3 containing Armadillo 0.3.6.3 Modified: pkg/RcppArmadillo/ChangeLog =================================================================== --- pkg/RcppArmadillo/ChangeLog 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/ChangeLog 2013-02-20 12:17:57 UTC (rev 4265) @@ -1,3 +1,9 @@ +2013-02-20 Dirk Eddelbuettel + + * DESCRIPTION: Release 0.3.6.3 + + * inst/include/*: Upgraded to new release 3.6.3 of Armadillo + 2013-01-29 Dirk Eddelbuettel * DESCRIPTION: Release 0.3.6.2 Modified: pkg/RcppArmadillo/DESCRIPTION =================================================================== --- pkg/RcppArmadillo/DESCRIPTION 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/DESCRIPTION 2013-02-20 12:17:57 UTC (rev 4265) @@ -1,7 +1,7 @@ Package: RcppArmadillo Type: Package Title: Rcpp integration for Armadillo templated linear algebra library -Version: 0.3.6.2 +Version: 0.3.6.3 Date: $Date$ Author: Romain Francois, Dirk Eddelbuettel and Doug Bates Maintainer: Dirk Eddelbuettel @@ -21,7 +21,7 @@ (due to speed and/or integration capabilities), rather than another language. . The RcppArmadillo package includes the header files from the templated - Armadillo library (currently version 3.6.1). Thus users do not need to + Armadillo library (currently version 3.6.3). Thus users do not need to install Armadillo itself in order to use RcppArmadillo. . This Armadillo integration provides a nice illustration of the Modified: pkg/RcppArmadillo/inst/NEWS.Rd =================================================================== --- pkg/RcppArmadillo/inst/NEWS.Rd 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/inst/NEWS.Rd 2013-02-20 12:17:57 UTC (rev 4265) @@ -2,6 +2,17 @@ \title{News for Package 'RcppArmadillo'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{Changes in RcppArmadillo version 0.3.6.3 (2013-02-20)}{ + \itemize{ + \item Upgraded to Armadillo release Version 3.6.3 + \itemize{ + \item faster \code{find()} + \item minor fix for non-contiguous submatrix views to handle empty vectors of indices + \item reduction of pedantic compiler warnings + } + } +} + \section{Changes in RcppArmadillo version 0.3.6.2 (2013-01-29)}{ \itemize{ \item Upgraded to Armadillo release Version 3.6.2 Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp 2013-02-20 12:17:57 UTC (rev 4265) @@ -1,5 +1,5 @@ -// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) -// Copyright (C) 2008-2012 Conrad Sanderson +// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) +// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2012 Ryan Curtin // // This file is part of the Armadillo C++ library. @@ -480,6 +480,8 @@ inline bool empty() const; inline uword size() const; + inline void swap(Mat& B); + inline void steal_mem(Mat& X); //!< don't use this unless you're writing code internal to Armadillo template class fixed; Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2013-02-20 12:17:57 UTC (rev 4265) @@ -1,5 +1,5 @@ -// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) -// Copyright (C) 2008-2012 Conrad Sanderson +// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) +// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2012 Ryan Curtin // // This file is part of the Armadillo C++ library. @@ -716,6 +716,90 @@ +//! EXPERIMENTAL: swap the contents of this matrix, denoted as matrix A, with given matrix B +template +inline +void +Mat::swap(Mat& B) + { + Mat& A = (*this); + + arma_extra_debug_sigprint(arma_boost::format("A = %x B = %x") % &A % &B); + + arma_debug_check( (A.vec_state != B.vec_state), "Mat::swap(): incompatible object types" ); + + const uhword A_mem_state = A.mem_state; + const uhword B_mem_state = B.mem_state; + + if( (A_mem_state == 0) && (B_mem_state == 0) ) + { + const uword A_n_elem = A.n_elem; + const uword B_n_elem = B.n_elem; + + const bool A_use_local_mem = (A_n_elem <= arma_config::mat_prealloc); + const bool B_use_local_mem = (B_n_elem <= arma_config::mat_prealloc); + + if( (A_use_local_mem == false) && (B_use_local_mem == false) ) + { + std::swap( access::rw(A.mem), access::rw(B.mem) ); + } + else + if( (A_use_local_mem == true) && (B_use_local_mem == true) ) + { + const uword N = (std::max)(A_n_elem, B_n_elem); + + eT* A_mem = A.memptr(); + eT* B_mem = B.memptr(); + + for(uword ii=0; ii < N; ++ii) { std::swap( A_mem[ii], B_mem[ii] ); } + } + else + if( (A_use_local_mem == true) && (B_use_local_mem == false) ) + { + eT* A_mem_local = &(A.mem_local[0]); + eT* B_mem_local = &(B.mem_local[0]); + + arrayops::copy(B_mem_local, A_mem_local, A_n_elem); + + access::rw(A.mem) = B.mem; + access::rw(B.mem) = B_mem_local; + } + else + if( (A_use_local_mem == false) && (B_use_local_mem == true) ) + { + eT* A_mem_local = &(A.mem_local[0]); + eT* B_mem_local = &(B.mem_local[0]); + + arrayops::copy(A_mem_local, B_mem_local, B_n_elem); + + access::rw(B.mem) = A.mem; + access::rw(A.mem) = A_mem_local; + } + + std::swap( access::rw(A.n_rows), access::rw(B.n_rows) ); + std::swap( access::rw(A.n_cols), access::rw(B.n_cols) ); + std::swap( access::rw(A.n_elem), access::rw(B.n_elem) ); + } + else + if( (A_mem_state == 3) && (B_mem_state == 3) ) + { + arma_debug_check( ((A.n_rows != B.n_rows) || (A.n_cols != B.n_cols)), "Mat::swap(): incompatible object types" ); + + const uword N = A.n_elem; + + eT* A_mem = A.memptr(); + eT* B_mem = B.memptr(); + + for(uword ii=0; ii < N; ++ii) { std::swap(A_mem[ii], B_mem[ii]); } + } + else + { + arma_bad("Mat::swap(): incompatible object types"); + } + } + + + //! try to steal the memory from a given matrix; //! if memory can't be stolen, copy the given matrix template Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_iterators_meat.hpp 2013-02-20 12:17:57 UTC (rev 4265) @@ -32,10 +32,10 @@ template inline -SpMat::iterator_base::iterator_base(const SpMat& in_M, const uword col, const uword pos) +SpMat::iterator_base::iterator_base(const SpMat& in_M, const uword in_col, const uword in_pos) : M(in_M) - , internal_col(col) - , internal_pos(pos) + , internal_col(in_col) + , internal_pos(in_pos) { // Nothing to do. } Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp 2013-02-20 12:17:57 UTC (rev 4265) @@ -616,7 +616,7 @@ podarray partial_sums(n_rows); partial_sums.zeros(); - for(uword col = 0; col < n_cols; ++col) + for(uword lcol = 0; lcol < n_cols; ++lcol) { const_iterator it = begin(); @@ -624,7 +624,7 @@ { const eT value = (*it); - partial_sums[it.row()] += (value * p.at(it.col(), col)); + partial_sums[it.row()] += (value * p.at(it.col(), lcol)); ++it; } @@ -636,8 +636,8 @@ { access::rw(z.values[cur_pos]) = partial_sums[i]; access::rw(z.row_indices[cur_pos]) = i; - ++access::rw(z.col_ptrs[col + 1]); - //printf("colptr %d now %d\n", col + 1, z.col_ptrs[col + 1]); + ++access::rw(z.col_ptrs[lcol + 1]); + //printf("colptr %d now %d\n", lcol + 1, z.col_ptrs[lcol + 1]); ++cur_pos; partial_sums[i] = 0; // Would it be faster to do this in batch later? } @@ -1028,12 +1028,10 @@ // efficient way, by calculating the number of nonzero elements the output // matrix will have, allocating the memory correctly, and then filling the // matrix correctly. However... for now, this works okay. - for(uword col = 0; col < n_cols; ++col) + for(uword lcol = 0; lcol < n_cols; ++lcol) + for(uword lrow = 0; lrow < n_rows; ++lrow) { - for(uword row = 0; row < n_rows; ++row) - { - at(row, col) += x.at(row, col); - } + at(lrow, lcol) += x.at(lrow, lcol); } return *this; @@ -1051,12 +1049,10 @@ arma_debug_assert_same_size(n_rows, n_cols, x.n_rows, x.n_cols, "subtraction"); // Loop over every element. - for(uword col = 0; col < n_cols; ++col) + for(uword lcol = 0; lcol < n_cols; ++lcol) + for(uword lrow = 0; lrow < n_rows; ++lrow) { - for(uword row = 0; row < n_rows; ++row) - { - at(row, col) -= x.at(row, col); - } + at(lrow, lcol) -= x.at(lrow, lcol); } return *this; @@ -1078,12 +1074,12 @@ // Performed in the same fashion as operator*=(SpMat). for (const_row_iterator x_row_it = begin_row(); x_row_it.pos() < n_nonzero; ++x_row_it) { - for (uword col = 0; col < y.n_cols; ++col) + for (uword lcol = 0; lcol < y.n_cols; ++lcol) { // At this moment in the loop, we are calculating anything that is contributed to by *x_row_it and *y_col_it. // Given that our position is x_ab and y_bc, there will only be a contribution if x.col == y.row, and that // contribution will be in location z_ac. - z.at(x_row_it.row, col) += (*x_row_it) * y.at(x_row_it.col, col); + z.at(x_row_it.row, lcol) += (*x_row_it) * y.at(x_row_it.col, lcol); } } @@ -1104,12 +1100,10 @@ arma_debug_assert_same_size(n_rows, n_cols, x.n_rows, x.n_cols, "element-wise multiplication"); // Loop over every element. - for(uword col = 0; col < n_cols; ++col) + for(uword lcol = 0; lcol < n_cols; ++lcol) + for(uword lrow = 0; lrow < n_rows; ++lrow) { - for(uword row = 0; row < n_rows; ++row) - { - at(row, col) *= x.at(row, col); - } + at(lrow, lcol) *= x.at(lrow, lcol); } return *this; @@ -1127,12 +1121,10 @@ arma_debug_assert_same_size(n_rows, n_cols, x.n_rows, x.n_cols, "element-wise division"); // Loop over every element. - for(uword col = 0; col < n_cols; ++col) + for(uword lcol = 0; lcol < n_cols; ++lcol) + for(uword lrow = 0; lrow < n_rows; ++lrow) { - for(uword row = 0; row < n_rows; ++row) - { - at(row, col) /= x.at(row, col); - } + at(lrow, lcol) /= x.at(lrow, lcol); } return *this; @@ -1698,10 +1690,10 @@ uword col1 = (in_row1 < in_row2) ? in_row1 : in_row2; uword col2 = (in_row1 < in_row2) ? in_row2 : in_row1; - for (uword col = 0; col < n_cols; col++) + for (uword lcol = 0; lcol < n_cols; lcol++) { // If there is nothing in this column we can ignore it. - if (col_ptrs[col] == col_ptrs[col + 1]) + if (col_ptrs[lcol] == col_ptrs[lcol + 1]) { continue; } @@ -1710,7 +1702,7 @@ uword loc1 = n_nonzero + 1; uword loc2 = n_nonzero + 1; - for (uword search_pos = col_ptrs[col]; search_pos < col_ptrs[col + 1]; search_pos++) + for (uword search_pos = col_ptrs[lcol]; search_pos < col_ptrs[lcol + 1]; search_pos++) { if (row_indices[search_pos] == col1) { @@ -1737,7 +1729,7 @@ { // We need to find the correct place to move our value to. It will be forward (not backwards) because in_row2 > in_row1. // Each iteration of the loop swaps the current value (loc1) with (loc1 + 1); in this manner we move our value down to where it should be. - while (((loc1 + 1) < col_ptrs[col + 1]) && (row_indices[loc1 + 1] < in_row2)) + while (((loc1 + 1) < col_ptrs[lcol + 1]) && (row_indices[loc1 + 1] < in_row2)) { // Swap both the values and the indices. The column should not change. eT tmp = values[loc1]; @@ -1759,7 +1751,7 @@ { // We need to find the correct place to move our value to. It will be backwards (not forwards) because in_row1 < in_row2. // Each iteration of the loop swaps the current value (loc2) with (loc2 - 1); in this manner we move our value up to where it should be. - while (((loc2 - 1) >= col_ptrs[col]) && (row_indices[loc2 - 1] > in_row1)) + while (((loc2 - 1) >= col_ptrs[lcol]) && (row_indices[loc2 - 1] > in_row1)) { // Swap both the values and the indices. The column should not change. eT tmp = values[loc2]; @@ -1792,11 +1784,11 @@ arma_extra_debug_sigprint(); // slow but works - for(uword row = 0; row < n_rows; ++row) + for(uword lrow = 0; lrow < n_rows; ++lrow) { - eT tmp = at(row, in_col1); - at(row, in_col1) = at(row, in_col2); - at(row, in_col2) = tmp; + eT tmp = at(lrow, in_col1); + at(lrow, in_col1) = at(lrow, in_col2); + at(lrow, in_col2) = tmp; } } @@ -1854,9 +1846,9 @@ for (i = 0, j = 0; i < vlength; ++i) { // Store the row of the ith element. - const uword row = row_indices[i]; + const uword lrow = row_indices[i]; // Is the ith element in the range of rows we want to remove? - if (row >= in_row1 && row <= in_row2) + if (lrow >= in_row1 && lrow <= in_row2) { // Increment our "removed elements" counter. ++j; @@ -1880,7 +1872,7 @@ // j = 0 until we remove the first element. if (j != 0) { - access::rw(row_indices[i - j]) = (row > in_row2) ? (row - (in_row2 - in_row1 + 1)) : row; + access::rw(row_indices[i - j]) = (lrow > in_row2) ? (lrow - (in_row2 - in_row1 + 1)) : lrow; access::rw(values[i - j]) = values[i]; } } @@ -2990,13 +2982,13 @@ uword cur_index = 0; uword count = 0; - for(uword col = 0; col < in_cols; ++col) - for(uword row = 0; row < in_rows; ++row) + for(uword lcol = 0; lcol < in_cols; ++lcol) + for(uword lrow = 0; lrow < in_rows; ++lrow) { if(count == indices[cur_index]) { - access::rw(row_indices[cur_index]) = row; - access::rw(col_ptrs[col + 1])++; + access::rw(row_indices[cur_index]) = lrow; + access::rw(col_ptrs[lcol + 1])++; ++cur_index; } @@ -3010,9 +3002,9 @@ } // Sum column pointers. - for(uword col = 1; col <= in_cols; ++col) + for(uword lcol = 1; lcol <= in_cols; ++lcol) { - access::rw(col_ptrs[col]) += col_ptrs[col - 1]; + access::rw(col_ptrs[lcol]) += col_ptrs[lcol - 1]; } return *this; @@ -3067,13 +3059,13 @@ uword cur_index = 0; uword count = 0; - for(uword col = 0; col < in_cols; ++col) - for(uword row = 0; row < in_rows; ++row) + for(uword lcol = 0; lcol < in_cols; ++lcol) + for(uword lrow = 0; lrow < in_rows; ++lrow) { if(count == indices[cur_index]) { - access::rw(row_indices[cur_index]) = row; - access::rw(col_ptrs[col + 1])++; + access::rw(row_indices[cur_index]) = lrow; + access::rw(col_ptrs[lcol + 1])++; ++cur_index; } @@ -3087,9 +3079,9 @@ } // Sum column pointers. - for(uword col = 1; col <= in_cols; ++col) + for(uword lcol = 1; lcol <= in_cols; ++lcol) { - access::rw(col_ptrs[col]) += col_ptrs[col - 1]; + access::rw(col_ptrs[lcol]) += col_ptrs[lcol - 1]; } return *this; @@ -3743,7 +3735,7 @@ line_start = 0; line_end = 0; - uword row = 0; + uword lrow = 0; while (line_start < text.length()) { @@ -3756,7 +3748,7 @@ std::string::size_type line_len = line_end - line_start + 1; std::stringstream line_stream(text.substr(line_start, line_len)); - uword col = 0; + uword lcol = 0; eT val; while (line_stream >> val) @@ -3764,13 +3756,13 @@ // Only add nonzero elements. if (val != eT(0)) { - get_value(row, col) = val; + get_value(lrow, lcol) = val; } - ++col; + ++lcol; } - ++row; + ++lrow; line_start = line_end + 1; } @@ -3847,12 +3839,12 @@ if(n_nonzero > 0) { // Copy old elements. - uword copy_size = std::min(n_nonzero, new_n_nonzero); + uword copy_len = std::min(n_nonzero, new_n_nonzero); - arrayops::copy(new_values, values, copy_size); - arrayops::copy(new_row_indices, row_indices, copy_size); + arrayops::copy(new_values, values, copy_len); + arrayops::copy(new_row_indices, row_indices, copy_len); } - + memory::release(values); memory::release(row_indices); @@ -4222,10 +4214,10 @@ SpMat::get_value(const uword i) { // First convert to the actual location. - uword col = i / n_rows; // Integer division. - uword row = i % n_rows; + uword lcol = i / n_rows; // Integer division. + uword lrow = i % n_rows; - return get_value(row, col); + return get_value(lrow, lcol); } @@ -4238,10 +4230,10 @@ SpMat::get_value(const uword i) const { // First convert to the actual location. - uword col = i / n_rows; // Integer division. - uword row = i % n_rows; + uword lcol = i / n_rows; // Integer division. + uword lrow = i % n_rows; - return get_value(row, col); + return get_value(lrow, lcol); } @@ -4326,12 +4318,12 @@ uword SpMat::get_position(const uword i) const { - uword row, col; + uword lrow, lcol; - get_position(i, row, col); + get_position(i, lrow, lcol); // Assemble the row/col into the element's location in the matrix. - return (row + n_rows * col); + return (lrow + n_rows * lcol); } Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_bones.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_bones.hpp 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_bones.hpp 2013-02-20 12:17:57 UTC (rev 4265) @@ -234,7 +234,7 @@ inline iterator(SpSubview& in_M, const uword initial_pos = 0) : const_iterator(in_M, initial_pos) { } inline iterator(SpSubview& in_M, const uword in_row, const uword in_col) : const_iterator(in_M, in_row, in_col) { } - inline iterator(SpSubview& in_M, const uword in_row, const uword in_col, const uword in_pos, const uword skip_pos) : const_iterator(in_M, in_row, in_col, in_pos, skip_pos) { } + inline iterator(SpSubview& in_M, const uword in_row, const uword in_col, const uword in_pos, const uword in_skip_pos) : const_iterator(in_M, in_row, in_col, in_pos, in_skip_pos) { } inline iterator(const iterator& other) : const_iterator(other) { } inline SpValProxy > operator*(); Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_iterators_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_iterators_meat.hpp 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_iterators_meat.hpp 2013-02-20 12:17:57 UTC (rev 4265) @@ -32,11 +32,11 @@ template inline -SpSubview::iterator_base::iterator_base(const SpSubview& in_M, const uword col, const uword pos, const uword skip_pos) +SpSubview::iterator_base::iterator_base(const SpSubview& in_M, const uword in_col, const uword in_pos, const uword in_skip_pos) : M(in_M) - , internal_col(col) - , internal_pos(pos) - , skip_pos(skip_pos) + , internal_col(in_col) + , internal_pos(in_pos) + , skip_pos (in_skip_pos) { // Nothing to do. } @@ -66,36 +66,36 @@ if(in_M.n_nonzero == 0) { iterator_base::internal_col = in_M.n_cols; - iterator_base::skip_pos = in_M.m.n_nonzero; + iterator_base::skip_pos = in_M.m.n_nonzero; return; } // Figure out the row and column of the position. - // skip_pos holds the number of values which aren't part of this subview. + // lskip_pos holds the number of values which aren't part of this subview. const uword aux_col = iterator_base::M.aux_col1; const uword aux_row = iterator_base::M.aux_row1; - const uword n_rows = iterator_base::M.n_rows; - const uword n_cols = iterator_base::M.n_cols; + const uword ln_rows = iterator_base::M.n_rows; + const uword ln_cols = iterator_base::M.n_cols; - uword cur_pos = 0; // off by one because we might be searching for pos 0 - uword skip_pos = iterator_base::M.m.col_ptrs[aux_col]; - uword cur_col = 0; + uword cur_pos = 0; // off by one because we might be searching for pos 0 + uword lskip_pos = iterator_base::M.m.col_ptrs[aux_col]; + uword cur_col = 0; while(cur_pos < (iterator_base::internal_pos + 1)) { // Have we stepped forward a column (or multiple columns)? - while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < n_cols)) + while(((lskip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < ln_cols)) { ++cur_col; } // See if the current position is in the subview. - const uword row_index = iterator_base::M.m.row_indices[cur_pos + skip_pos]; + const uword row_index = iterator_base::M.m.row_indices[cur_pos + lskip_pos]; if(row_index < aux_row) { - ++skip_pos; // not valid + ++lskip_pos; // not valid } - else if(row_index < (aux_row + n_rows)) + else if(row_index < (aux_row + ln_rows)) { ++cur_pos; // valid, in the subview } @@ -103,12 +103,12 @@ { // skip to end of column const uword next_colptr = iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]; - skip_pos += (next_colptr - (cur_pos + skip_pos)); + lskip_pos += (next_colptr - (cur_pos + lskip_pos)); } } iterator_base::internal_col = cur_col; - iterator_base::skip_pos = skip_pos; + iterator_base::skip_pos = lskip_pos; } @@ -131,8 +131,8 @@ // Because we have to count the points in this subview and not in this subview, this becomes a little difficult and slow. const uword aux_col = iterator_base::M.aux_col1; const uword aux_row = iterator_base::M.aux_row1; - const uword n_rows = iterator_base::M.n_rows; - const uword n_cols = iterator_base::M.n_cols; + const uword ln_rows = iterator_base::M.n_rows; + const uword ln_cols = iterator_base::M.n_cols; uword cur_pos = 0; uword skip_pos = iterator_base::M.m.col_ptrs[aux_col]; @@ -146,7 +146,7 @@ { ++skip_pos; } - else if(row_index < (aux_row + n_rows)) + else if(row_index < (aux_row + ln_rows)) { ++cur_pos; } @@ -158,7 +158,7 @@ } // Have we stepped forward a column (or multiple columns)? - while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < n_cols)) + while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < ln_cols)) { ++cur_col; } @@ -181,7 +181,7 @@ } // Ensure we didn't step forward a column; if we did, we need to stop. - while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < n_cols)) + while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < ln_cols)) { ++cur_col; } @@ -203,9 +203,9 @@ row_index = iterator_base::M.m.row_indices[cur_pos + skip_pos]; // Are we at the last position? - if(cur_col >= n_cols) + if(cur_col >= ln_cols) { - cur_col = n_cols; + cur_col = ln_cols; // Make sure we will be pointing at the last element in the parent matrix. skip_pos = iterator_base::M.m.n_nonzero - iterator_base::M.n_nonzero; break; @@ -215,7 +215,7 @@ { ++skip_pos; } - else if(row_index < (aux_row + n_rows)) + else if(row_index < (aux_row + ln_rows)) { break; // found } @@ -225,20 +225,20 @@ } // Did we move any columns? - while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < n_cols)) + while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < ln_cols)) { ++cur_col; } } // It is possible we have moved another column. - while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < n_cols)) + while(((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]) && (cur_col < ln_cols)) { ++cur_col; } iterator_base::internal_pos = cur_pos; - iterator_base::skip_pos = skip_pos; + iterator_base::skip_pos = skip_pos; iterator_base::internal_col = cur_col; } @@ -246,8 +246,8 @@ template inline -SpSubview::const_iterator::const_iterator(const SpSubview& in_M, uword in_row, uword in_col, uword in_pos, uword skip_pos) - : iterator_base(in_M, in_col, in_pos, skip_pos) +SpSubview::const_iterator::const_iterator(const SpSubview& in_M, uword in_row, uword in_col, uword in_pos, uword in_skip_pos) + : iterator_base(in_M, in_col, in_pos, in_skip_pos) { // Nothing to do. } @@ -271,51 +271,51 @@ { const uword aux_col = iterator_base::M.aux_col1; const uword aux_row = iterator_base::M.aux_row1; - const uword n_rows = iterator_base::M.n_rows; - const uword n_cols = iterator_base::M.n_cols; + const uword ln_rows = iterator_base::M.n_rows; + const uword ln_cols = iterator_base::M.n_cols; - uword cur_col = iterator_base::internal_col; - uword cur_pos = iterator_base::internal_pos + 1; - uword skip_pos = iterator_base::skip_pos; + uword cur_col = iterator_base::internal_col; + uword cur_pos = iterator_base::internal_pos + 1; + uword lskip_pos = iterator_base::skip_pos; uword row_index; while(true) { const uword next_colptr = iterator_base::M.m.col_ptrs[cur_col + aux_col + 1]; - row_index = iterator_base::M.m.row_indices[cur_pos + skip_pos]; + row_index = iterator_base::M.m.row_indices[cur_pos + lskip_pos]; // Did we move any columns? - while((cur_col < n_cols) && ((skip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1])) + while((cur_col < ln_cols) && ((lskip_pos + cur_pos) >= iterator_base::M.m.col_ptrs[cur_col + aux_col + 1])) { ++cur_col; } // Are we at the last position? - if(cur_col >= n_cols) + if(cur_col >= ln_cols) { - cur_col = n_cols; + cur_col = ln_cols; // Make sure we will be pointing at the last element in the parent matrix. - skip_pos = iterator_base::M.m.n_nonzero - iterator_base::M.n_nonzero; + lskip_pos = iterator_base::M.m.n_nonzero - iterator_base::M.n_nonzero; break; } if(row_index < aux_row) { - ++skip_pos; + ++lskip_pos; } - else if(row_index < (aux_row + n_rows)) + else if(row_index < (aux_row + ln_rows)) { break; // found } else { - skip_pos += (next_colptr - (cur_pos + skip_pos)); + lskip_pos += (next_colptr - (cur_pos + lskip_pos)); } } iterator_base::internal_pos = cur_pos; iterator_base::internal_col = cur_col; - iterator_base::skip_pos = skip_pos; + iterator_base::skip_pos = lskip_pos; return *this; } @@ -343,10 +343,10 @@ { const uword aux_col = iterator_base::M.aux_col1; const uword aux_row = iterator_base::M.aux_row1; - const uword n_rows = iterator_base::M.n_rows; + const uword ln_rows = iterator_base::M.n_rows; - uword cur_col = iterator_base::internal_col; - uword cur_pos = iterator_base::internal_pos - 1; + uword cur_col = iterator_base::internal_col; + uword cur_pos = iterator_base::internal_pos - 1; uword skip_pos = iterator_base::skip_pos; // Special condition for end of iterator. @@ -374,7 +374,7 @@ { skip_pos -= (colptr - (cur_pos + skip_pos) + 1); } - else if(row_index < (aux_row + n_rows)) + else if(row_index < (aux_row + ln_rows)) { break; // found } @@ -385,7 +385,7 @@ } iterator_base::internal_pos = cur_pos; - iterator_base::skip_pos = skip_pos; + iterator_base::skip_pos = skip_pos; iterator_base::internal_col = cur_col; return *this; @@ -577,7 +577,7 @@ const uword aux_col = iterator_base::M.aux_col1; const uword aux_row = iterator_base::M.aux_row1; - const uword n_cols = iterator_base::M.n_cols; + const uword ln_cols = iterator_base::M.n_cols; // We don't know where the elements are in each row. What we will do is // loop across all valid columns looking for elements in row 0 (and add to @@ -619,7 +619,7 @@ } cur_col++; // Done with the column. Move on. - if(cur_col == n_cols) + if(cur_col == ln_cols) { // Out of columns. Loop back to the beginning and look on the next row. cur_col = 0; @@ -692,12 +692,12 @@ const uword aux_col = iterator_base::M.aux_col1; const uword aux_row = iterator_base::M.aux_row1; - const uword n_cols = iterator_base::M.n_cols; + const uword ln_cols = iterator_base::M.n_cols; while(true) { // Increment the current column and see if we are on a new row. - if(++cur_col == n_cols) + if(++cur_col == ln_cols) { cur_col = 0; ++cur_row; @@ -771,14 +771,14 @@ const uword aux_col = iterator_base::M.aux_col1; const uword aux_row = iterator_base::M.aux_row1; - const uword n_cols = iterator_base::M.n_cols; + const uword ln_cols = iterator_base::M.n_cols; while(true) { // Decrement the current column and see if we are on a new row. - if(--cur_col > n_cols) + if(--cur_col > ln_cols) { - cur_col = n_cols - 1; + cur_col = ln_cols - 1; cur_row--; } Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_meat.hpp 2013-02-20 11:53:00 UTC (rev 4264) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpSubview_meat.hpp 2013-02-20 12:17:57 UTC (rev 4265) @@ -29,13 +29,13 @@ arma_extra_debug_sigprint(); // There must be a O(1) way to do this - uword end = m.col_ptrs[in_col1 + in_n_cols]; - uword end_row = in_row1 + in_n_rows; + uword lend = m.col_ptrs[in_col1 + in_n_cols]; + uword lend_row = in_row1 + in_n_rows; uword count = 0; - for(uword i = m.col_ptrs[in_col1]; i < end; ++i) + for(uword i = m.col_ptrs[in_col1]; i < lend; ++i) { - if(m.row_indices[i] >= in_row1 && m.row_indices[i] < end_row) + if(m.row_indices[i] >= in_row1 && m.row_indices[i] < lend_row) { ++count; } @@ -60,13 +60,13 @@ arma_extra_debug_sigprint(); // There must be a O(1) way to do this - uword end = m.col_ptrs[in_col1 + in_n_cols]; - uword end_row = in_row1 + in_n_rows; - uword count = 0; + uword lend = m.col_ptrs[in_col1 + in_n_cols]; + uword lend_row = in_row1 + in_n_rows; + uword count = 0; - for(uword i = m.col_ptrs[in_col1]; i < end; ++i) + for(uword i = m.col_ptrs[in_col1]; i < lend; ++i) { - if(m.row_indices[i] >= in_row1 && m.row_indices[i] < end_row) + if(m.row_indices[i] >= in_row1 && m.row_indices[i] < lend_row) { ++count; } @@ -98,20 +98,19 @@ return *this; } - const uword start_row = aux_row1; - const uword end_row = aux_row1 + n_rows; - const uword start_col = aux_col1; - const uword end_col = aux_col1 + n_cols; + const uword lstart_row = aux_row1; + const uword lend_row = aux_row1 + n_rows; + + const uword lstart_col = aux_col1; + const uword lend_col = aux_col1 + n_cols; const uword old_n_nonzero = m.n_nonzero; // iterate over our part of the sparse matrix - for(uword col = start_col; col < end_col; ++col) + for(uword lcol = lstart_col; lcol < lend_col; ++lcol) + for(uword lrow = lstart_row; lrow < lend_row; ++lrow) { - for(uword row = start_row; row < end_row; ++row) - { - access::rw(m).at(row, col) += val; - } + access::rw(m).at(lrow, lcol) += val; } const uword new_n_nonzero = m.n_nonzero; @@ -135,19 +134,18 @@ return *this; } - const uword start_row = aux_row1; - const uword end_row = aux_row1 + n_rows; - const uword start_col = aux_col1; - const uword end_col = aux_col1 + n_cols; + const uword lstart_row = aux_row1; + const uword lend_row = aux_row1 + n_rows; + + const uword lstart_col = aux_col1; + const uword lend_col = aux_col1 + n_cols; const uword old_n_nonzero = m.n_nonzero; - for(uword col = start_col; col < end_col; ++col) + for(uword lcol = lstart_col; lcol < lend_col; ++lcol) [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/rcpp -r 4265 From noreply at r-forge.r-project.org Thu Feb 21 03:08:03 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Feb 2013 03:08:03 +0100 (CET) Subject: [Rcpp-commits] r4266 - in pkg/RcppCNPy: . src Message-ID: <20130221020803.74344184C3F@r-forge.r-project.org> Author: edd Date: 2013-02-21 03:08:02 +0100 (Thu, 21 Feb 2013) New Revision: 4266 Modified: pkg/RcppCNPy/ChangeLog pkg/RcppCNPy/src/cnpy.cpp pkg/RcppCNPy/src/cnpyMod.cpp Log: New function npyHasIntegerSupport to test if integer support was compiled in Minor tweak on unused var to suppress warning Modified: pkg/RcppCNPy/ChangeLog =================================================================== --- pkg/RcppCNPy/ChangeLog 2013-02-20 12:17:57 UTC (rev 4265) +++ pkg/RcppCNPy/ChangeLog 2013-02-21 02:08:02 UTC (rev 4266) @@ -1,3 +1,8 @@ +2013-02-20 Dirk Eddelbuettel + + * src/cnpyMod.cpp (npyHasIntegerSupport): New function to test if + integer support was compiled in, also exported via Rcpp Modules to R + 2013-02-19 Dirk Eddelbuettel * src/cnpy.h: Define R_NO_REMAP before including Rinternals to not @@ -4,7 +9,7 @@ define length(), error(), ... but rather Rf_length(), Rf_error() * src/cnpy.cpp: Add a bogus unused variable at the never-reached end - of code (after an error exit) to silence the pedantic mode of g++ + of code (after an error exit) to silence the pedantic mode of g++ 2012-07-30 Dirk Eddelbuettel Modified: pkg/RcppCNPy/src/cnpy.cpp =================================================================== --- pkg/RcppCNPy/src/cnpy.cpp 2013-02-20 12:17:57 UTC (rev 4265) +++ pkg/RcppCNPy/src/cnpy.cpp 2013-02-21 02:08:02 UTC (rev 4266) @@ -231,7 +231,9 @@ fclose(fp); Rf_error("npz_load: Error! Variable name %s not found in %s!\n",varname.c_str(),fname.c_str()); // never reached -- not satisfying -Wall -pedantic - NpyArray unused; + cnpy::NpyArray unused; + unused.word_size = 0; + unused.data = NULL; return unused; } Modified: pkg/RcppCNPy/src/cnpyMod.cpp =================================================================== --- pkg/RcppCNPy/src/cnpyMod.cpp 2013-02-20 12:17:57 UTC (rev 4265) +++ pkg/RcppCNPy/src/cnpyMod.cpp 2013-02-21 02:08:02 UTC (rev 4266) @@ -154,6 +154,14 @@ } } +bool npyHasIntegerSupport() { +#ifdef RCPP_HAS_LONG_LONG_TYPES + return true; +#else + return false; +#endif +} + RCPP_MODULE(cnpy){ using namespace Rcpp; @@ -172,4 +180,6 @@ Named("mode") = "w"), "save an R object (vector or matrix of type integer or numeric) to an npy file"); + function("npyHasIntegerSupport", &npyHasIntegerSupport, + "return logical value indicating whether package has integer support (which need C++11)"); } From noreply at r-forge.r-project.org Thu Feb 21 03:20:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Feb 2013 03:20:07 +0100 (CET) Subject: [Rcpp-commits] r4267 - in pkg/RcppCNPy: . man tests Message-ID: <20130221022007.CE74C184E2D@r-forge.r-project.org> Author: edd Date: 2013-02-21 03:20:05 +0100 (Thu, 21 Feb 2013) New Revision: 4267 Modified: pkg/RcppCNPy/ChangeLog pkg/RcppCNPy/DESCRIPTION pkg/RcppCNPy/man/RcppCNPy-package.Rd pkg/RcppCNPy/tests/loadFiles.R Log: more integer support Modified: pkg/RcppCNPy/ChangeLog =================================================================== --- pkg/RcppCNPy/ChangeLog 2013-02-21 02:08:02 UTC (rev 4266) +++ pkg/RcppCNPy/ChangeLog 2013-02-21 02:20:05 UTC (rev 4267) @@ -2,7 +2,11 @@ * src/cnpyMod.cpp (npyHasIntegerSupport): New function to test if integer support was compiled in, also exported via Rcpp Modules to R + * man/RcppCNPy-package.Rd: Added documentation entry + * tests/loadFiles.R: Updated regression test to use run-time integer + support check, and test integer support if available + 2013-02-19 Dirk Eddelbuettel * src/cnpy.h: Define R_NO_REMAP before including Rinternals to not Modified: pkg/RcppCNPy/DESCRIPTION =================================================================== --- pkg/RcppCNPy/DESCRIPTION 2013-02-21 02:08:02 UTC (rev 4266) +++ pkg/RcppCNPy/DESCRIPTION 2013-02-21 02:20:05 UTC (rev 4267) @@ -1,7 +1,7 @@ Package: RcppCNPy Type: Package Title: Rcpp bindings for NumPy files -Version: 0.2.0.1 +Version: 0.2.0.2 Date: $Date$ Author: Dirk Eddelbuettel Maintainer: Dirk Eddelbuettel Modified: pkg/RcppCNPy/man/RcppCNPy-package.Rd =================================================================== --- pkg/RcppCNPy/man/RcppCNPy-package.Rd 2013-02-21 02:08:02 UTC (rev 4266) +++ pkg/RcppCNPy/man/RcppCNPy-package.Rd 2013-02-21 02:20:05 UTC (rev 4267) @@ -3,6 +3,7 @@ \alias{RcppCNPy} \alias{npyLoad} \alias{npySave} +\alias{npyHasIntegerSupport} \docType{package} \title{ File access to data files written by (or for) NumPy (Numeric Python) modules @@ -23,6 +24,7 @@ \usage{ npyLoad(filename, type="numeric", dotranspose=TRUE) npySave(filename, object, mode="w") + npyHasIntegerSupport() } \arguments{ \item{filename}{string with (path and) filename for a \code{npy} @@ -43,14 +45,6 @@ } } \details{ - \tabular{ll}{ - Package: \tab RcppCNPy\cr - Type: \tab Package\cr - Version: \tab 0.1.0\cr - Date: \tab 2012-07-07\cr - License: \tab GPL (>= 2)\cr - } - The package uses Rcpp modules to provide R bindings \code{npyLoad()} and \code{npySave()} which wrap the \code{npy_load()} and \code{npy_save()} functions. Currently, only one- and two-dimensional Modified: pkg/RcppCNPy/tests/loadFiles.R =================================================================== --- pkg/RcppCNPy/tests/loadFiles.R 2013-02-21 02:08:02 UTC (rev 4266) +++ pkg/RcppCNPy/tests/loadFiles.R 2013-02-21 02:20:05 UTC (rev 4267) @@ -10,15 +10,19 @@ fmat stopifnot(all.equal(fmat, t(matrix(seq(0,11) * 1.1, 4, 3)))) -#imat <- npyLoad("imat.npy", "integer") -#imat -#stopifnot(all.equal(imat, t(matrix(seq(0,11), 4, 3)))) +if (npyHasIntegerSupport()) { + imat <- npyLoad("imat.npy", "integer") + imat + stopifnot(all.equal(imat, t(matrix(seq(0,11), 4, 3)))) +} fvec <- npyLoad("fvec.npy") fvec stopifnot(all.equal(fvec, seq(0,4) * 1.1)) -#ivec <- npyLoad("ivec.npy", "integer") -#ivec -#stopifnot(all.equal(ivec, seq(0,4))) +if (npyHasIntegerSupport()) { + ivec <- npyLoad("ivec.npy", "integer") + ivec + stopifnot(all.equal(ivec, seq(0,4))) +} From noreply at r-forge.r-project.org Thu Feb 21 03:23:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Feb 2013 03:23:53 +0100 (CET) Subject: [Rcpp-commits] r4268 - pkg/RcppCNPy Message-ID: <20130221022353.A59AF184E2D@r-forge.r-project.org> Author: edd Date: 2013-02-21 03:23:53 +0100 (Thu, 21 Feb 2013) New Revision: 4268 Modified: pkg/RcppCNPy/ Log: more svn ignore Property changes on: pkg/RcppCNPy ___________________________________________________________________ Modified: svn:ignore - .Rproj.user .Rhistory .RData + .Rproj.user .Rhistory .RData .Rbuildignore RcppCNPy.Rproj From noreply at r-forge.r-project.org Thu Feb 21 03:47:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Feb 2013 03:47:19 +0100 (CET) Subject: [Rcpp-commits] r4269 - in pkg/RcppCNPy: . tests vignettes Message-ID: <20130221024719.D422F184B6E@r-forge.r-project.org> Author: edd Date: 2013-02-21 03:47:18 +0100 (Thu, 21 Feb 2013) New Revision: 4269 Modified: pkg/RcppCNPy/DESCRIPTION pkg/RcppCNPy/tests/loadFiles.Rout.save pkg/RcppCNPy/vignettes/RcppCNPy-intro.Rnw pkg/RcppCNPy/vignettes/RcppCNPy-intro.pdf Log: updated Description: and vignette regarding the need for -std=c++11 compilation of RcppCNPy (but not Rcpp) updated test output Modified: pkg/RcppCNPy/DESCRIPTION =================================================================== --- pkg/RcppCNPy/DESCRIPTION 2013-02-21 02:23:53 UTC (rev 4268) +++ pkg/RcppCNPy/DESCRIPTION 2013-02-21 02:47:18 UTC (rev 4269) @@ -9,8 +9,8 @@ by Carl Rogers which provides read and write facilities for files created with (or for) the NumPy extension for Python. Vectors and matrices of numeric types can be read or written to and from files as well as compressed - files. Support for integer files is available if the package (and Rcpp) have - been compiled with -std=c++0x. + files. Support for integer files is available if the package has been built + with -std=c++0x or -std=c++11 which is needed for long long int support. License: GPL (>= 2) LazyLoad: yes Depends: methods, Rcpp (>= 0.9.13) Modified: pkg/RcppCNPy/tests/loadFiles.Rout.save =================================================================== --- pkg/RcppCNPy/tests/loadFiles.Rout.save 2013-02-21 02:23:53 UTC (rev 4268) +++ pkg/RcppCNPy/tests/loadFiles.Rout.save 2013-02-21 02:47:18 UTC (rev 4269) @@ -1,5 +1,5 @@ -R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows" +R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit) @@ -37,20 +37,24 @@ [3,] 8.8 9.9 11.0 12.1 > stopifnot(all.equal(fmat, t(matrix(seq(0,11) * 1.1, 4, 3)))) > -> #imat <- npyLoad("imat.npy", "integer") -> #imat -> #stopifnot(all.equal(imat, t(matrix(seq(0,11), 4, 3)))) +> if (npyHasIntegerSupport()) { ++ imat <- npyLoad("imat.npy", "integer") ++ imat ++ stopifnot(all.equal(imat, t(matrix(seq(0,11), 4, 3)))) ++ } > > fvec <- npyLoad("fvec.npy") > fvec [1] 0.0 1.1 2.2 3.3 4.4 > stopifnot(all.equal(fvec, seq(0,4) * 1.1)) > -> #ivec <- npyLoad("ivec.npy", "integer") -> #ivec -> #stopifnot(all.equal(ivec, seq(0,4))) +> if (npyHasIntegerSupport()) { ++ ivec <- npyLoad("ivec.npy", "integer") ++ ivec ++ stopifnot(all.equal(ivec, seq(0,4))) ++ } > > > proc.time() user system elapsed - 0.596 0.024 0.460 + 0.588 0.024 0.456 Modified: pkg/RcppCNPy/vignettes/RcppCNPy-intro.Rnw =================================================================== --- pkg/RcppCNPy/vignettes/RcppCNPy-intro.Rnw 2013-02-21 02:23:53 UTC (rev 4268) +++ pkg/RcppCNPy/vignettes/RcppCNPy-intro.Rnw 2013-02-21 02:47:18 UTC (rev 4269) @@ -5,11 +5,14 @@ \usepackage[bf,sf,compact,small]{titlesec} -\usepackage[margin=0.85in,paper=letterpaper]{geometry} +\usepackage[margin=0.95in,paper=letterpaper]{geometry} \usepackage[T1]{fontenc} -\usepackage{pslatex} % just like RJournal -\usepackage{palatino,mathpazo} +%\usepackage{pslatex} % just like RJournal +%\usepackage{palatino,mathpazo} +%% Cf http://www.khirevich.com/latex/font/ +\usepackage[T1]{fontenc} +\usepackage[bitstream-charter]{mathdesign} \usepackage{color,url,booktabs} @@ -369,12 +372,13 @@ \subsection{Integer support} -Support for integer data types is conditional on use of the \code{-std=c++0x} -compiler extension. Only the newer standard supports the \code{long long int} -type needed to represent \code{int64} data on a 32-bit OS. So until \R -switches to allowing \code{-std=c++0x} on CRAN packages, users will need to -rebuild both \pkg{Rcpp} and \pkg{RcppCNPy} with the switch enabled. As shown -in the previous examples, integers also transparently convert to float types. +Support for integer data types is conditional on use of either the +\code{-std=c++0x} or the newer \code{-std=c++11} compiler extension +switches. Only the newer standard supports the \code{long long int} type +needed to represent \code{int64} data on a 32-bit OS. So until \R allows +\code{-std=c++0x} on CRAN packages, users will need to rebuild \pkg{RcppCNPy} +with the switch enabled. As shown in the previous examples, integers also +transparently convert to float types. \subsection{Higher-dimensional arrays} Modified: pkg/RcppCNPy/vignettes/RcppCNPy-intro.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Thu Feb 21 03:53:56 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Feb 2013 03:53:56 +0100 (CET) Subject: [Rcpp-commits] r4270 - in pkg/RcppCNPy: . inst Message-ID: <20130221025356.AED8F18444C@r-forge.r-project.org> Author: edd Date: 2013-02-21 03:53:55 +0100 (Thu, 21 Feb 2013) New Revision: 4270 Added: pkg/RcppCNPy/inst/THANKS Modified: pkg/RcppCNPy/ChangeLog Log: added THANKS to show thanks to Carl and Gong updated ChangeLog Modified: pkg/RcppCNPy/ChangeLog =================================================================== --- pkg/RcppCNPy/ChangeLog 2013-02-21 02:47:18 UTC (rev 4269) +++ pkg/RcppCNPy/ChangeLog 2013-02-21 02:53:55 UTC (rev 4270) @@ -6,7 +6,14 @@ * tests/loadFiles.R: Updated regression test to use run-time integer support check, and test integer support if available + * tests/loadFiles.Rout.save: Updated accordingly + * RcppCNPy-intro.Rnw: Updated the discussion of integer support and + clarified that only RcppCNPy needs to be rebuilt with -std=c++11 + * DESCRIPTION: Idem + + * inst/THANKS: Added to show thanks to Carl and Gong + 2013-02-19 Dirk Eddelbuettel * src/cnpy.h: Define R_NO_REMAP before including Rinternals to not Added: pkg/RcppCNPy/inst/THANKS =================================================================== --- pkg/RcppCNPy/inst/THANKS (rev 0) +++ pkg/RcppCNPy/inst/THANKS 2013-02-21 02:53:55 UTC (rev 4270) @@ -0,0 +1,2 @@ +Carl Rogers for writing the terrific cnpy library +Gong-Yi Liao for most useful help with integer support From noreply at r-forge.r-project.org Sun Feb 24 11:10:45 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Feb 2013 11:10:45 +0100 (CET) Subject: [Rcpp-commits] r4271 - in pkg/Rcpp: . R inst Message-ID: <20130224101045.8C5ED184E58@r-forge.r-project.org> Author: jjallaire Date: 2013-02-24 11:10:45 +0100 (Sun, 24 Feb 2013) New Revision: 4271 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/R/Attributes.R pkg/Rcpp/inst/NEWS.Rd Log: Add global package include file to RcppExports.cpp if it exists Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-21 02:53:55 UTC (rev 4270) +++ pkg/Rcpp/ChangeLog 2013-02-24 10:10:45 UTC (rev 4271) @@ -1,3 +1,8 @@ +2013-02-24 JJ Allaire + + * R/Attributes.R: add global package include file to RcppExports.cpp + if it exists + 2013-02-19 Romain Francois * src/api.cpp : more debugging Modified: pkg/Rcpp/R/Attributes.R =================================================================== --- pkg/Rcpp/R/Attributes.R 2013-02-21 02:53:55 UTC (rev 4270) +++ pkg/Rcpp/R/Attributes.R 2013-02-24 10:10:45 UTC (rev 4271) @@ -332,6 +332,15 @@ linkingTo <- as.character(pkgInfo$DESCRIPTION["LinkingTo"]) includes <- .linkingToIncludes(linkingTo, TRUE) + # if a master include file is defined for the package then include it + pkgHeader <- paste(pkgname, ".h", sep="") + pkgHeaderPath <- file.path(pkgdir, "inst", "include", pkgHeader) + if (file.exists(pkgHeaderPath)) { + pkgInclude <- paste("#include \"../inst/include/", + pkgHeader, "\"", sep="") + includes <- c(includes, pkgInclude) + } + # generate exports invisible(.Call("compileAttributes", PACKAGE="Rcpp", pkgdir, pkgname, depends, cppFiles, cppFileBasenames, Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-02-21 02:53:55 UTC (rev 4270) +++ pkg/Rcpp/inst/NEWS.Rd 2013-02-24 10:10:45 UTC (rev 4271) @@ -19,6 +19,8 @@ the use of C++11 in a translation unit \item Merge existing values of build related environment variables for sourceCpp + \item Add global package include file to RcppExports.cpp + if it exists \item Stop with an error if the file name passed to \code{sourceCpp} has spaces in it \item Return invisibly from void functions From noreply at r-forge.r-project.org Sun Feb 24 13:09:03 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Feb 2013 13:09:03 +0100 (CET) Subject: [Rcpp-commits] r4272 - in pkg/Rcpp: . R inst man src Message-ID: <20130224120903.3A898183912@r-forge.r-project.org> Author: jjallaire Date: 2013-02-24 13:09:02 +0100 (Sun, 24 Feb 2013) New Revision: 4272 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/R/Attributes.R pkg/Rcpp/inst/NEWS.Rd pkg/Rcpp/man/sourceCpp.Rd pkg/Rcpp/src/attributes.cpp Log: support for Rcpp modules in sourceCpp Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-24 10:10:45 UTC (rev 4271) +++ pkg/Rcpp/ChangeLog 2013-02-24 12:09:02 UTC (rev 4272) @@ -1,7 +1,9 @@ 2013-02-24 JJ Allaire * R/Attributes.R: add global package include file to RcppExports.cpp - if it exists + if it exists; handle Rcpp module definitions in sourceCpp + * src/attributes.cpp: handle Rcpp module definitions in sourceCpp + * man/sourceCpp.Rd: documentation updates 2013-02-19 Romain Francois Modified: pkg/Rcpp/R/Attributes.R =================================================================== --- pkg/Rcpp/R/Attributes.R 2013-02-24 10:10:45 UTC (rev 4271) +++ pkg/Rcpp/R/Attributes.R 2013-02-24 12:09:02 UTC (rev 4272) @@ -141,19 +141,21 @@ "force a rebuild)\n\n", sep="") } - # load the module if we have exported functions (else there is no module) - if (length(context$exportedFunctions) > 0) { + # load the module if we have exported symbols + if (length(context$exportedFunctions) > 0 || length(context$modules) > 0) { # remove existing objects of the same name from the environment - exports <- context$exportedFunctions + exports <- c(context$exportedFunctions, context$modules) removeObjs <- exports[exports %in% ls(envir = env, all.names = T)] remove(list = removeObjs, envir = env) # source the R script scriptPath <- file.path(context$buildDirectory, context$rSourceFilename) source(scriptPath, local = env) + } else if (getOption("rcpp.warnNoExports", default=TRUE)) { - warning("No Rcpp::export attributes found in source") + warning("No Rcpp::export attributes or RCPP_MODULE declarations ", + "found in source") } # source the embeddedR @@ -162,8 +164,9 @@ source(file=srcConn, echo=TRUE) } - # return (invisibly) a list of exported functions - invisible(context$exportedFunctions) + # return (invisibly) a list containing exported functions and modules + invisible(list(functions = context$exportedFunctions, + modules = context$modules)) } # Define a single C++ function @@ -233,12 +236,12 @@ verbose = verbose) # verify that a single function was exported and return it - if (length(exported) == 0) + if (length(exported$functions) == 0) stop("No function definition found") - else if (length(exported) > 1) + else if (length(exported$functions) > 1) stop("More than one function definition") else { - functionName <- exported[[1]] + functionName <- exported$functions[[1]] invisible(get(functionName, env)) } } Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-02-24 10:10:45 UTC (rev 4271) +++ pkg/Rcpp/inst/NEWS.Rd 2013-02-24 12:09:02 UTC (rev 4272) @@ -12,6 +12,7 @@ } \item Changes in Rcpp attributes: \itemize{ + \item Rcpp modules can now be used with \code{sourceCpp} \item Added \code{Rcpp::plugins} attribute for binding directly to inline plugins. Plugins can be registered using the new \code{registerPlugin} function. Modified: pkg/Rcpp/man/sourceCpp.Rd =================================================================== --- pkg/Rcpp/man/sourceCpp.Rd 2013-02-24 10:10:45 UTC (rev 4271) +++ pkg/Rcpp/man/sourceCpp.Rd 2013-02-24 12:09:02 UTC (rev 4272) @@ -4,7 +4,8 @@ Source C++ Code from a File or String } \description{ -\code{sourceCpp} parses the specified C++ file or source code and looks for functions marked with the \code{\link[=exportAttribute]{Rcpp::export}} attribute. A shared library is then built and its exported functions are made available as R functions in the specified environment. +\code{sourceCpp} parses the specified C++ file or source code and looks for functions marked with the \code{\link[=exportAttribute]{Rcpp::export}} attribute +and RCPP_MODULE declarations. A shared library is then built and its exported functions and Rcpp modules are made available in the specified environment. } \usage{ sourceCpp(file = "", code = NULL, env = globalenv(), @@ -20,7 +21,7 @@ A character string with source code. If supplied, the code is taken from this string instead of a file. } \item{env}{ - Environment where the R functions should be made available. + Environment where the R functions and modules should be made available. } \item{rebuild}{ Force a rebuild of the shared library. @@ -37,6 +38,8 @@ Functions exported using \code{sourceCpp} must meet several conditions, including being defined in the global namespace and having return types that are compatible with \code{Rcpp::wrap} and parameter types that are compatible with \code{Rcpp::as}. See the \code{\link[=exportAttribute]{Rcpp::export}} documentation for more details. + Rcpp Modules will be automatically loaded into the specified environment using the \code{\link[=Module]{Module}} function. the name of the loaded module object will be the same as the name specified in the \code{RCPP_MODULE} declaration. + If the source file has compilation dependencies on other packages (e.g. \pkg{Matrix}, \pkg{RcppArmadillo}) then an \code{\link[=dependsAttribute]{Rcpp::depends}} attribute should be provided naming these dependencies. It's possible to embed chunks of R code within a C++ source file by including the R code within a block comment with the prefix of \code{/*** R}. For example: @@ -50,11 +53,15 @@ */ } - Multiple R code chunks can be included in a C++ file. All R code is sourced after the C++ functions within the file have been defined. + Multiple R code chunks can be included in a C++ file. R code is sourced after the C++ compliation is completed so all functions and modules will be available to the R code. } \value{ - Returns (invisibly) a character vector with the names of the R functions that were sourced into the specified environment. + Returns (invisibly) a list with two elements: + \tabular{ll}{ + \code{functions} \tab Names of exported functions\cr + \code{modules} \tab Names of Rcpp modules\cr + } } \note{ @@ -64,7 +71,7 @@ If you are sourcing a C++ file from within the \code{src} directory of a package then the package's \code{LinkingTo} dependencies, \code{inst/include}, and \code{src} directories are automatically included in the compilation. - If no \code{Rcpp::export} attributes are found within the source file then a warning is printed to the console. You can disable this warning by setting the \code{rcpp.warnNoExports} option to \code{FALSE}. + If no \code{Rcpp::export} attributes or \code{RCPP_MODULE} declarations are found within the source file then a warning is printed to the console. You can disable this warning by setting the \code{rcpp.warnNoExports} option to \code{FALSE}. } Modified: pkg/Rcpp/src/attributes.cpp =================================================================== --- pkg/Rcpp/src/attributes.cpp 2013-02-24 10:10:45 UTC (rev 4271) +++ pkg/Rcpp/src/attributes.cpp 2013-02-24 12:09:02 UTC (rev 4272) @@ -258,10 +258,14 @@ virtual ~SourceFileAttributes() {}; virtual const std::string& sourceFile() const = 0; virtual bool hasInterface(const std::string& name) const = 0; + typedef std::vector::const_iterator const_iterator; virtual const_iterator begin() const = 0; virtual const_iterator end() const = 0; - virtual bool empty() const = 0; + + virtual const std::vector& modules() const = 0; + + virtual bool hasAttributesOrModules() const = 0; }; @@ -288,6 +292,7 @@ public: bool inComment() const { return inComment_; } void submitLine(const std::string& line); + void reset() { inComment_ = false; } private: bool inComment_; }; @@ -309,7 +314,17 @@ } virtual const_iterator begin() const { return attributes_.begin(); } virtual const_iterator end() const { return attributes_.end(); } - virtual bool empty() const { return attributes_.empty(); } + + virtual const std::vector& modules() const + { + return modules_; + } + + virtual bool hasAttributesOrModules() const + { + return !attributes_.empty() || !modules_.empty(); + } + virtual bool hasInterface(const std::string& name) const { for (const_iterator it=begin(); it != end(); ++it) { @@ -358,6 +373,7 @@ std::string sourceFile_; CharacterVector lines_; std::vector attributes_; + std::vector modules_; std::vector embeddedR_; std::vector roxygenBuffer_; }; @@ -795,7 +811,8 @@ std::string contents = buffer.str(); // Check for attribute signature - if (contents.find("[[Rcpp::") != std::string::npos) { + if (contents.find("[[Rcpp::") != std::string::npos || + contents.find("RCPP_MODULE") != std::string::npos) { // Now read into a list of strings (which we can pass to regexec) // First read into a std::deque (which will handle lots of append @@ -850,6 +867,26 @@ } } + // Scan for Rcpp modules + commentState.reset(); + Rcpp::List modMatches = regexMatches(lines_, + "^\\s*RCPP_MODULE\\s*\\(\\s*(\\w+)\\s*\\).*$"); + for (int i = 0; i 0) { + const char * name = match[1]; + modules_.push_back(name); + } + } + // Parse embedded R embeddedR_ = parseEmbeddedR(lines_, lines); } @@ -2331,7 +2368,7 @@ rOfs.close(); - // discover exported functions, and dependencies + // discover exported functions and dependencies exportedFunctions_.clear(); depends_.clear(); plugins_.clear(); @@ -2352,6 +2389,9 @@ } } + // capture modules + modules_ = sourceAttributes.modules(); + // capture embededded R embeddedR_ = sourceAttributes.embeddedR(); } @@ -2399,6 +2439,10 @@ return exportedFunctions_; } + const std::vector& modules() const { + return modules_; + } + const std::vector& depends() const { return depends_; }; const std::vector& plugins() const { return plugins_; }; @@ -2437,7 +2481,23 @@ << dllInfo << ", " << "'" << contextId_ + "_" + function.name() << "')" << std::endl; - } + } + + // modules + std::vector modules = attributes.modules(); + if (modules.size() > 0) + { + // modules require definition of C++Object to be loaded + ostr << "library(Rcpp)" << std::endl; + + // load each module + for (std::vector::const_iterator + it = modules.begin(); it != modules.end(); ++it) + { + ostr << *it << " <- Rcpp::Module(\"" << *it << "\"," + << dllInfo << ")" << std::endl; + } + } } @@ -2459,6 +2519,7 @@ std::string previousDynlibFilename_; std::string dynlibExt_; std::vector exportedFunctions_; + std::vector modules_; std::vector depends_; std::vector plugins_; std::vector embeddedR_; @@ -2576,6 +2637,7 @@ _["buildDirectory"] = pDynlib->buildDirectory(), _["generatedCpp"] = pDynlib->generatedCpp(), _["exportedFunctions"] = pDynlib->exportedFunctions(), + _["modules"] = pDynlib->modules(), _["cppSourceFilename"] = pDynlib->cppSourceFilename(), _["rSourceFilename"] = pDynlib->rSourceFilename(), _["dynlibFilename"] = pDynlib->dynlibFilename(), @@ -2658,7 +2720,7 @@ // parse attributes (continue if there are none) std::string cppFile = cppFiles[i]; SourceFileAttributesParser attributes(cppFile); - if (attributes.empty()) + if (!attributes.hasAttributesOrModules()) continue; // confirm we have attributes From noreply at r-forge.r-project.org Wed Feb 27 20:57:55 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 27 Feb 2013 20:57:55 +0100 (CET) Subject: [Rcpp-commits] r4273 - in pkg/Rcpp: . R inst Message-ID: <20130227195755.4CE8B183AD8@r-forge.r-project.org> Author: jjallaire Date: 2013-02-27 20:57:54 +0100 (Wed, 27 Feb 2013) New Revision: 4273 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/R/Rcpp.package.skeleton.R pkg/Rcpp/inst/NEWS.Rd Log: eliminated spurious empty hello world function definition in Rcpp.package.skeleton Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-24 12:09:02 UTC (rev 4272) +++ pkg/Rcpp/ChangeLog 2013-02-27 19:57:54 UTC (rev 4273) @@ -1,3 +1,8 @@ +2013-02-27 JJ Allaire + + * R/Rcpp.package.skeleton.R: eliminated spurious empty hello world + function definition in Rcpp.package.skeleton + 2013-02-24 JJ Allaire * R/Attributes.R: add global package include file to RcppExports.cpp Modified: pkg/Rcpp/R/Rcpp.package.skeleton.R =================================================================== --- pkg/Rcpp/R/Rcpp.package.skeleton.R 2013-02-24 12:09:02 UTC (rev 4272) +++ pkg/Rcpp/R/Rcpp.package.skeleton.R 2013-02-27 19:57:54 UTC (rev 4273) @@ -38,7 +38,7 @@ if( !length(list) ){ fake <- TRUE assign( "Rcpp.fake.fun", function(){}, envir = env ) - if( example_code ){ + if( example_code && !isTRUE(attributes)){ assign( "rcpp_hello_world", function(){}, envir = env ) remove_hello_world <- TRUE } else { @@ -63,7 +63,7 @@ call <- call[ c( 1L, which( names(call) %in% names(formals(package.skeleton)))) ] if( fake ){ - call[["list"]] <- c( if( isTRUE(example_code)) "rcpp_hello_world" , "Rcpp.fake.fun" ) + call[["list"]] <- c( if( isTRUE(example_code) && !isTRUE(attributes)) "rcpp_hello_world" , "Rcpp.fake.fun" ) } tryCatch( eval( call, envir = env ), error = function(e){ Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-02-24 12:09:02 UTC (rev 4272) +++ pkg/Rcpp/inst/NEWS.Rd 2013-02-27 19:57:54 UTC (rev 4273) @@ -27,6 +27,8 @@ \item Return invisibly from void functions \item Ensure that line comments invalidate block comments when parsing for attributes + \item Eliminated spurious empty hello world function definition + in Rcpp.package.skeleton } \item Changes in Rcpp API: \itemize{ From noreply at r-forge.r-project.org Thu Feb 28 21:14:48 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 28 Feb 2013 21:14:48 +0100 (CET) Subject: [Rcpp-commits] r4274 - in pkg/Rcpp: . inst src Message-ID: <20130228201448.7CBDF1842D8@r-forge.r-project.org> Author: jjallaire Date: 2013-02-28 21:14:48 +0100 (Thu, 28 Feb 2013) New Revision: 4274 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/NEWS.Rd pkg/Rcpp/src/attributes.cpp Log: standalone roxygen chunks (e.g. to document a class) are now transposed into RcppExports.R Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-02-27 19:57:54 UTC (rev 4273) +++ pkg/Rcpp/ChangeLog 2013-02-28 20:14:48 UTC (rev 4274) @@ -1,3 +1,8 @@ +2013-02-28 JJ Allaire + + * src/attributes.cpp: standalone roxygen chunks (e.g. to document + a class) are now transposed into RcppExports.R + 2013-02-27 JJ Allaire * R/Rcpp.package.skeleton.R: eliminated spurious empty hello world Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-02-27 19:57:54 UTC (rev 4273) +++ pkg/Rcpp/inst/NEWS.Rd 2013-02-28 20:14:48 UTC (rev 4274) @@ -13,6 +13,8 @@ \item Changes in Rcpp attributes: \itemize{ \item Rcpp modules can now be used with \code{sourceCpp} + \item Standalone roxygen chunks (e.g. to document a class) are now + transposed into RcppExports.R \item Added \code{Rcpp::plugins} attribute for binding directly to inline plugins. Plugins can be registered using the new \code{registerPlugin} function. Modified: pkg/Rcpp/src/attributes.cpp =================================================================== --- pkg/Rcpp/src/attributes.cpp 2013-02-27 19:57:54 UTC (rev 4273) +++ pkg/Rcpp/src/attributes.cpp 2013-02-28 20:14:48 UTC (rev 4274) @@ -264,8 +264,10 @@ virtual const_iterator end() const = 0; virtual const std::vector& modules() const = 0; - - virtual bool hasAttributesOrModules() const = 0; + + virtual const std::vector >& roxygenChunks() const = 0; + + virtual bool hasGeneratorOutput() const = 0; }; @@ -320,9 +322,15 @@ return modules_; } - virtual bool hasAttributesOrModules() const + virtual const std::vector >& roxygenChunks() const { + return roxygenChunks_; + } + + virtual bool hasGeneratorOutput() const { - return !attributes_.empty() || !modules_.empty(); + return !attributes_.empty() || + !modules_.empty() || + !roxygenChunks_.empty(); } virtual bool hasInterface(const std::string& name) const { @@ -375,6 +383,7 @@ std::vector attributes_; std::vector modules_; std::vector embeddedR_; + std::vector > roxygenChunks_; std::vector roxygenBuffer_; }; @@ -864,6 +873,12 @@ std::string roxLine = "#" + line.substr(2); roxygenBuffer_.push_back(roxLine); } + + // a non-roxygen line causes us to clear the roxygen buffer + else if (!roxygenBuffer_.empty()) { + roxygenChunks_.push_back(roxygenBuffer_); + roxygenBuffer_.clear(); + } } } @@ -1779,6 +1794,17 @@ const SourceFileAttributes& attributes, bool verbose) { + // write standalone roxygen chunks + const std::vector >& roxygenChunks = + attributes.roxygenChunks(); + for (std::size_t i = 0; i& chunk = roxygenChunks[i]; + for (std::size_t l = 0; l < chunk.size(); l++) + ostr() << chunk[l] << std::endl; + ostr() << "NULL" << std::endl << std::endl; + } + + // write exported functions if (attributes.hasInterface(kInterfaceR)) { // process each attribute for(std::vector::const_iterator @@ -2717,10 +2743,10 @@ std::set dependsAttribs; for (std::size_t i=0; i