From noreply at r-forge.r-project.org Mon May 13 16:52:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 13 May 2013 16:52:58 +0200 (CEST) Subject: [Rcpp-commits] r4315 - in pkg/RcppArmadillo: . debian inst inst/include/armadillo_bits Message-ID: <20130513145258.F1940185173@r-forge.r-project.org> Author: edd Date: 2013-05-13 16:52:58 +0200 (Mon, 13 May 2013) New Revision: 4315 Modified: pkg/RcppArmadillo/ChangeLog pkg/RcppArmadillo/DESCRIPTION pkg/RcppArmadillo/cleanup pkg/RcppArmadillo/debian/changelog pkg/RcppArmadillo/inst/NEWS.Rd pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/compiler_setup.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/config.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/debug.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eGlueCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eglue_core_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eop_core_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/field_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/field_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_as_scalar.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trace.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/gemm.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/gemv.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_mixed_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_times_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_times_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_dot_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_strans_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_strans_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_sum_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_times.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/traits.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/unwrap.hpp Log: Release 0.3.820 using Armadillo 3.820 Modified: pkg/RcppArmadillo/ChangeLog =================================================================== --- pkg/RcppArmadillo/ChangeLog 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/ChangeLog 2013-05-13 14:52:58 UTC (rev 4315) @@ -1,3 +1,10 @@ +2013-05-13 Dirk Eddelbuettel + + * DESCRIPTION: Release 0.3.820 + * inst/NEWS: Release 0.3.820 + * inst/include/*: Upgraded to new release 3.820 of Armadillo + * debian/*: Similarly updated for new release to Debian + 2013-04-30 Dirk Eddelbuettel * DESCRIPTION: Release 0.3.810.2 Modified: pkg/RcppArmadillo/DESCRIPTION =================================================================== --- pkg/RcppArmadillo/DESCRIPTION 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/DESCRIPTION 2013-05-13 14:52:58 UTC (rev 4315) @@ -1,7 +1,7 @@ Package: RcppArmadillo Type: Package Title: Rcpp integration for Armadillo templated linear algebra library -Version: 0.3.810.2 +Version: 0.3.820 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.810.2). Thus users do not need to + Armadillo library (currently version 3.820). 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/cleanup =================================================================== --- pkg/RcppArmadillo/cleanup 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/cleanup 2013-05-13 14:52:58 UTC (rev 4315) @@ -5,5 +5,6 @@ inst/doc/RcppArmadillo-unitTests.out \ inst/doc/RcppArmadillo-unitTests.aux \ inst/doc/RcppArmadillo-unitTests.log \ + inst/doc/RcppArmadillo-intro.out \ */*~ *~ rm -rf autom4te.cache Modified: pkg/RcppArmadillo/debian/changelog =================================================================== --- pkg/RcppArmadillo/debian/changelog 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/debian/changelog 2013-05-13 14:52:58 UTC (rev 4315) @@ -1,3 +1,9 @@ +r-cran-rcpparmadillo (0.3.820-1) unstable; urgency=low + + * New upstream release + + -- Dirk Eddelbuettel Mon, 13 May 2013 09:20:13 -0500 + r-cran-rcpparmadillo (0.3.810.2-1) unstable; urgency=low * New upstream release Modified: pkg/RcppArmadillo/inst/NEWS.Rd =================================================================== --- pkg/RcppArmadillo/inst/NEWS.Rd 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/NEWS.Rd 2013-05-13 14:52:58 UTC (rev 4315) @@ -2,6 +2,18 @@ \title{News for Package 'RcppArmadillo'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{Changes in RcppArmadillo version 0.3.820 (2013-05-12)}{ + \itemize{ + \item Upgraded to Armadillo release Version 3.820 (Mt Cootha) + \itemize{ + \item faster \code{as_scalar()} for compound expressions + \item faster transpose of small vectors + \item faster matrix-vector product for small vectors + \item faster multiplication of small fixed size matrices + } + } +} + \section{Changes in RcppArmadillo version 0.3.810.2 (2013-04-30)}{ \itemize{ \item Upgraded to Armadillo release Version 3.810.2 Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_bones.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -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 // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -171,17 +171,16 @@ inline const Col& operator=(const std::string& text); inline const Col& operator=(const subview_cube& X); + using Col::operator(); - #if !defined(ARMA_GCC47_BUG) - using Col::operator(); - #endif - - #if defined(ARMA_USE_CXX11) inline fixed(const std::initializer_list& list); inline const Col& operator=(const std::initializer_list& list); #endif + arma_inline const Op< Col_fixed_type, op_htrans > t() const; + arma_inline const Op< Col_fixed_type, op_htrans > ht() const; + arma_inline const Op< Col_fixed_type, op_strans > st() const; arma_inline arma_warn_unused eT& operator[] (const uword i); arma_inline arma_warn_unused eT operator[] (const uword i) const; Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Col_meat.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -1026,6 +1026,39 @@ template template arma_inline +const Op< typename Col::template fixed::Col_fixed_type, op_htrans > +Col::fixed::t() const + { + return Op< typename Col::template fixed::Col_fixed_type, op_htrans >(*this); + } + + + +template +template +arma_inline +const Op< typename Col::template fixed::Col_fixed_type, op_htrans > +Col::fixed::ht() const + { + return Op< typename Col::template fixed::Col_fixed_type, op_htrans >(*this); + } + + + +template +template +arma_inline +const Op< typename Col::template fixed::Col_fixed_type, op_strans > +Col::fixed::st() const + { + return Op< typename Col::template fixed::Col_fixed_type, op_strans >(*this); + } + + + +template +template +arma_inline arma_warn_unused eT& Col::fixed::operator[] (const uword ii) Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_bones.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_bones.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_bones.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -270,11 +270,13 @@ typedef eT* slice_iterator; typedef const eT* const_slice_iterator; - inline iterator begin(); - inline const_iterator begin() const; + inline iterator begin(); + inline const_iterator begin() const; + inline const_iterator cbegin() const; - inline iterator end(); - inline const_iterator end() const; + inline iterator end(); + inline const_iterator end() const; + inline const_iterator cend() const; inline slice_iterator begin_slice(const uword slice_num); inline const_slice_iterator begin_slice(const uword slice_num) const; @@ -324,10 +326,13 @@ { private: - static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols * fixed_n_slices; + static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols * fixed_n_slices; + static const uword fixed_n_elem_slice = fixed_n_rows * fixed_n_cols; + static const bool use_extra = (fixed_n_elem > Cube_prealloc::mem_n_elem); + arma_aligned Mat* mat_ptrs_local_extra[ (fixed_n_slices > Cube_prealloc::mat_ptrs_size) ? fixed_n_slices : 1 ]; - arma_aligned eT mem_local_extra [ (fixed_n_elem > Cube_prealloc::mem_n_elem) ? fixed_n_elem : 1 ]; + arma_aligned eT mem_local_extra [ use_extra ? fixed_n_elem : 1 ]; arma_inline void mem_setup(); @@ -348,8 +353,23 @@ inline explicit fixed(const BaseCube& A, const BaseCube& B) { mem_setup(); Cube::init(A,B); } - // using Cube::operator(); - // TODO: overload operator(), operator[] and .at() to allow faster element access + using Cube::operator(); + + + arma_inline arma_warn_unused eT& operator[] (const uword i); + arma_inline arma_warn_unused eT operator[] (const uword i) const; + + arma_inline arma_warn_unused eT& at (const uword i); + arma_inline arma_warn_unused eT at (const uword i) const; + + arma_inline arma_warn_unused eT& operator() (const uword i); + arma_inline arma_warn_unused eT operator() (const uword i) const; + + arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col, const uword in_slice); + arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col, const uword in_slice) const; + + arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col, const uword in_slice); + arma_inline arma_warn_unused eT operator() (const uword in_row, const uword in_col, const uword in_slice) const; }; Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Cube_meat.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -248,7 +248,7 @@ { arma_extra_debug_sigprint(); - typedef typename T1::elem_type T; + typedef typename T1::elem_type T; arma_type_check(( is_complex::value == false )); //!< compile-time abort if eT isn't std::complex arma_type_check(( is_complex< T>::value == true )); //!< compile-time abort if T is std::complex @@ -258,7 +258,7 @@ const ProxyCube PX(X.get_ref()); const ProxyCube PY(Y.get_ref()); - arma_assert_same_size(PX, PY, "Cube()"); + arma_debug_assert_same_size(PX, PY, "Cube()"); const uword local_n_rows = PX.get_n_rows(); const uword local_n_cols = PX.get_n_cols(); @@ -535,7 +535,7 @@ { arma_extra_debug_sigprint(); - arma_debug_assert_same_size(*this, m, "cube addition"); + arma_debug_assert_same_size(*this, m, "addition"); arrayops::inplace_plus( memptr(), m.memptr(), n_elem ); @@ -552,7 +552,7 @@ { arma_extra_debug_sigprint(); - arma_debug_assert_same_size(*this, m, "cube subtraction"); + arma_debug_assert_same_size(*this, m, "subtraction"); arrayops::inplace_minus( memptr(), m.memptr(), n_elem ); @@ -569,7 +569,7 @@ { arma_extra_debug_sigprint(); - arma_debug_assert_same_size(*this, m, "element-wise cube multiplication"); + arma_debug_assert_same_size(*this, m, "element-wise multiplication"); arrayops::inplace_mul( memptr(), m.memptr(), n_elem ); @@ -586,7 +586,7 @@ { arma_extra_debug_sigprint(); - arma_debug_assert_same_size(*this, m, "element-wise cube division"); + arma_debug_assert_same_size(*this, m, "element-wise division"); arrayops::inplace_div( memptr(), m.memptr(), n_elem ); @@ -3038,6 +3038,18 @@ template inline +typename Cube::const_iterator +Cube::cbegin() const + { + arma_extra_debug_sigprint(); + + return memptr(); + } + + + +template +inline typename Cube::iterator Cube::end() { @@ -3057,9 +3069,21 @@ return memptr() + n_elem; } + + + +template +inline +typename Cube::const_iterator +Cube::cend() const + { + arma_extra_debug_sigprint(); + return memptr() + n_elem; + } + template inline typename Cube::slice_iterator @@ -3116,43 +3140,6 @@ -template -template -arma_inline -void -Cube::fixed::mem_setup() - { - arma_extra_debug_sigprint_this(this); - - if(fixed_n_elem > 0) - { - access::rw(Cube::n_rows) = fixed_n_rows; - access::rw(Cube::n_cols) = fixed_n_cols; - access::rw(Cube::n_elem_slice) = fixed_n_rows * fixed_n_cols; - access::rw(Cube::n_slices) = fixed_n_slices; - access::rw(Cube::n_elem) = fixed_n_elem; - access::rw(Cube::mem_state) = 3; - access::rw(Cube::mat_ptrs) = const_cast< const Mat** >( \ - (fixed_n_slices > Cube_prealloc::mat_ptrs_size) ? mat_ptrs_local_extra : mat_ptrs_local ); - access::rw(Cube::mem) = (fixed_n_elem > Cube_prealloc::mem_n_elem) ? mem_local_extra : mem_local; - - create_mat(); - } - else - { - access::rw(Cube::n_rows) = 0; - access::rw(Cube::n_cols) = 0; - access::rw(Cube::n_elem_slice) = 0; - access::rw(Cube::n_slices) = 0; - access::rw(Cube::n_elem) = 0; - access::rw(Cube::mem_state) = 3; - access::rw(Cube::mat_ptrs) = 0; - access::rw(Cube::mem) = 0; - } - } - - - //! resets this cube to an empty matrix template inline @@ -3252,6 +3239,193 @@ +template +template +arma_inline +void +Cube::fixed::mem_setup() + { + arma_extra_debug_sigprint_this(this); + + if(fixed_n_elem > 0) + { + access::rw(Cube::n_rows) = fixed_n_rows; + access::rw(Cube::n_cols) = fixed_n_cols; + access::rw(Cube::n_elem_slice) = fixed_n_rows * fixed_n_cols; + access::rw(Cube::n_slices) = fixed_n_slices; + access::rw(Cube::n_elem) = fixed_n_elem; + access::rw(Cube::mem_state) = 3; + access::rw(Cube::mat_ptrs) = const_cast< const Mat** >( \ + (fixed_n_slices > Cube_prealloc::mat_ptrs_size) ? mat_ptrs_local_extra : mat_ptrs_local ); + access::rw(Cube::mem) = (fixed_n_elem > Cube_prealloc::mem_n_elem) ? mem_local_extra : mem_local; + + create_mat(); + } + else + { + access::rw(Cube::n_rows) = 0; + access::rw(Cube::n_cols) = 0; + access::rw(Cube::n_elem_slice) = 0; + access::rw(Cube::n_slices) = 0; + access::rw(Cube::n_elem) = 0; + access::rw(Cube::mem_state) = 3; + access::rw(Cube::mat_ptrs) = 0; + access::rw(Cube::mem) = 0; + } + } + + + +template +template +arma_inline +arma_warn_unused +eT& +Cube::fixed::operator[] (const uword i) + { + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT +Cube::fixed::operator[] (const uword i) const + { + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT& +Cube::fixed::at(const uword i) + { + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT +Cube::fixed::at(const uword i) const + { + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT& +Cube::fixed::operator() (const uword i) + { + arma_debug_check( (i >= fixed_n_elem), "Cube::operator(): out of bounds"); + + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT +Cube::fixed::operator() (const uword i) const + { + arma_debug_check( (i >= fixed_n_elem), "Cube::operator(): out of bounds"); + + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT& +Cube::fixed::at(const uword in_row, const uword in_col, const uword in_slice) + { + const uword i = in_slice*fixed_n_elem_slice + in_col*fixed_n_rows + in_row; + + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT +Cube::fixed::at(const uword in_row, const uword in_col, const uword in_slice) const + { + const uword i = in_slice*fixed_n_elem_slice + in_col*fixed_n_rows + in_row; + + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT& +Cube::fixed::operator() (const uword in_row, const uword in_col, const uword in_slice) + { + arma_debug_check + ( + (in_row >= fixed_n_rows ) || + (in_col >= fixed_n_cols ) || + (in_slice >= fixed_n_slices) + , + "Cube::operator(): index out of bounds" + ); + + const uword i = in_slice*fixed_n_elem_slice + in_col*fixed_n_rows + in_row; + + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + +template +template +arma_inline +arma_warn_unused +eT +Cube::fixed::operator() (const uword in_row, const uword in_col, const uword in_slice) const + { + arma_debug_check + ( + (in_row >= fixed_n_rows ) || + (in_col >= fixed_n_cols ) || + (in_slice >= fixed_n_slices) + , + "Cube::operator(): index out of bounds" + ); + + const uword i = in_slice*fixed_n_elem_slice + in_col*fixed_n_rows + in_row; + + return (use_extra) ? mem_local_extra[i] : mem_local[i]; + } + + + //! prefix ++ template arma_inline Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_bones.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -464,11 +464,13 @@ arma_aligned uword col; }; - inline iterator begin(); - inline const_iterator begin() const; + inline iterator begin(); + inline const_iterator begin() const; + inline const_iterator cbegin() const; - inline iterator end(); - inline const_iterator end() const; + inline iterator end(); + inline const_iterator end() const; + inline const_iterator cend() const; inline col_iterator begin_col(const uword col_num); inline const_col_iterator begin_col(const uword col_num) const; @@ -567,25 +569,17 @@ inline fixed(const char* text); inline fixed(const std::string& text); + using Mat::operator=; + using Mat::operator(); - #if !defined(ARMA_GCC47_BUG) - using Mat::operator=; - using Mat::operator(); - #else - template inline const Mat& operator=(const Base& A); - - inline const Mat& operator=(const eT val); - - inline const Mat& operator=(const char* text); - inline const Mat& operator=(const std::string& text); - #endif - - #if defined(ARMA_USE_CXX11) inline fixed(const std::initializer_list& list); inline const Mat& operator=(const std::initializer_list& list); #endif + arma_inline const Op< Mat_fixed_type, op_htrans > t() const; + arma_inline const Op< Mat_fixed_type, op_htrans > ht() const; + arma_inline const Op< Mat_fixed_type, op_strans > st() const; arma_inline arma_warn_unused eT& operator[] (const uword i); arma_inline arma_warn_unused eT operator[] (const uword i) const; @@ -599,9 +593,14 @@ arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col); arma_inline arma_warn_unused eT operator() (const uword in_row, const uword in_col) const; + arma_inline arma_warn_unused eT* colptr(const uword in_col); + arma_inline arma_warn_unused const eT* colptr(const uword in_col) const; + arma_inline arma_warn_unused eT* memptr(); arma_inline arma_warn_unused const eT* memptr() const; + arma_inline arma_warn_unused bool is_vec() const; + arma_hot inline const Mat& fill(const eT val); arma_hot inline const Mat& zeros(); arma_hot inline const Mat& ones(); Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Mat_meat.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -672,7 +672,7 @@ const Proxy PX(X.get_ref()); const Proxy PY(Y.get_ref()); - arma_assert_same_size(PX, PY, "Mat()"); + arma_debug_assert_same_size(PX, PY, "Mat()"); const uword local_n_rows = PX.get_n_rows(); const uword local_n_cols = PX.get_n_cols(); @@ -5922,6 +5922,18 @@ template inline +typename Mat::const_iterator +Mat::cbegin() const + { + arma_extra_debug_sigprint(); + + return memptr(); + } + + + +template +inline typename Mat::iterator Mat::end() { @@ -5941,9 +5953,21 @@ return memptr() + n_elem; } + + + +template +inline +typename Mat::const_iterator +Mat::cend() const + { + arma_extra_debug_sigprint(); + return memptr() + n_elem; + } + template inline typename Mat::col_iterator @@ -6184,69 +6208,6 @@ -#if defined(ARMA_GCC47_BUG) - - template - template - template - inline - const Mat& - Mat::fixed::operator=(const Base& A) - { - Mat::operator=(A.get_ref()); - - return *this; - } - - - - template - template - inline - const Mat& - Mat::fixed::operator=(const eT val) - { - arma_extra_debug_sigprint(); - - Mat::operator=(val); - - return *this; - } - - - - template - template - inline - const Mat& - Mat::fixed::operator=(const char* text) - { - arma_extra_debug_sigprint(); - - Mat::operator=(text); - - return *this; - } - - - - template - template - inline - const Mat& - Mat::fixed::operator=(const std::string& text) - { - arma_extra_debug_sigprint(); - - Mat::operator=(text); - - return *this; - } - -#endif - - - #if defined(ARMA_USE_CXX11) template @@ -6284,12 +6245,45 @@ } #endif - + template template arma_inline +const Op< typename Mat::template fixed::Mat_fixed_type, op_htrans > +Mat::fixed::t() const + { + return Op< typename Mat::template fixed::Mat_fixed_type, op_htrans >(*this); + } + + + +template +template +arma_inline +const Op< typename Mat::template fixed::Mat_fixed_type, op_htrans > +Mat::fixed::ht() const + { + return Op< typename Mat::template fixed::Mat_fixed_type, op_htrans >(*this); + } + + + +template +template +arma_inline +const Op< typename Mat::template fixed::Mat_fixed_type, op_strans > +Mat::fixed::st() const + { + return Op< typename Mat::template fixed::Mat_fixed_type, op_strans >(*this); + } + + + +template +template +arma_inline arma_warn_unused eT& Mat::fixed::operator[] (const uword ii) @@ -6428,6 +6422,34 @@ arma_inline arma_warn_unused eT* +Mat::fixed::colptr(const uword in_col) + { + eT* mem_actual = (use_extra) ? mem_local_extra : mem_local; + + return & access::rw(mem_actual[in_col*fixed_n_rows]); + } + + + +template +template +arma_inline +arma_warn_unused +const eT* +Mat::fixed::colptr(const uword in_col) const + { + const eT* mem_actual = (use_extra) ? mem_local_extra : mem_local; + + return & mem_actual[in_col*fixed_n_rows]; + } + + + +template +template +arma_inline +arma_warn_unused +eT* Mat::fixed::memptr() { return (use_extra) ? mem_local_extra : mem_local; @@ -6449,6 +6471,18 @@ template template +arma_inline +arma_warn_unused +bool +Mat::fixed::is_vec() const + { + return ( (fixed_n_rows == 1) || (fixed_n_cols == 1) ); + } + + + +template +template arma_hot inline const Mat& Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_bones.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -169,17 +169,16 @@ inline const Row& operator=(const std::string& text); inline const Row& operator=(const subview_cube& X); + using Row::operator(); - #if !defined(ARMA_GCC47_BUG) - using Row::operator(); - #endif - - #if defined(ARMA_USE_CXX11) inline fixed(const std::initializer_list& list); inline const Row& operator=(const std::initializer_list& list); #endif + arma_inline const Op< Row_fixed_type, op_htrans > t() const; + arma_inline const Op< Row_fixed_type, op_htrans > ht() const; + arma_inline const Op< Row_fixed_type, op_strans > st() const; arma_inline arma_warn_unused eT& operator[] (const uword i); arma_inline arma_warn_unused eT operator[] (const uword i) const; Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/Row_meat.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -964,6 +964,39 @@ template template arma_inline +const Op< typename Row::template fixed::Row_fixed_type, op_htrans > +Row::fixed::t() const + { + return Op< typename Row::template fixed::Row_fixed_type, op_htrans >(*this); + } + + + +template +template +arma_inline +const Op< typename Row::template fixed::Row_fixed_type, op_htrans > +Row::fixed::ht() const + { + return Op< typename Row::template fixed::Row_fixed_type, op_htrans >(*this); + } + + + +template +template +arma_inline +const Op< typename Row::template fixed::Row_fixed_type, op_strans > +Row::fixed::st() const + { + return Op< typename Row::template fixed::Row_fixed_type, op_strans >(*this); + } + + + +template +template +arma_inline arma_warn_unused eT& Row::fixed::operator[] (const uword ii) Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_meat.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -626,43 +626,48 @@ , col_ptrs(NULL) { arma_extra_debug_sigprint(); - + typedef typename T1::elem_type T; - + // Make sure eT is complex and T is not (compile-time check). arma_type_check(( is_complex::value == false )); arma_type_check(( is_complex< T>::value == true )); - + // Compile-time abort if types are not compatible. arma_type_check(( is_same_type< std::complex, eT >::value == false )); - - // Hack until Proxy supports sparse matrices: assume get_ref() is SpMat<> (at - // the moment it must be). - const SpMat& X = A.get_ref(); - const SpMat& Y = B.get_ref(); - - arma_assert_same_size(X.n_rows, X.n_cols, Y.n_rows, Y.n_cols, "SpMat()"); - + + const unwrap_spmat tmp1(A.get_ref()); + const unwrap_spmat tmp2(B.get_ref()); + + const SpMat& X = tmp1.M; + const SpMat& Y = tmp2.M; + + arma_debug_assert_same_size(X.n_rows, X.n_cols, Y.n_rows, Y.n_cols, "SpMat()"); + const uword l_n_rows = X.n_rows; const uword l_n_cols = X.n_cols; - + // Set size of matrix correctly. init(l_n_rows, l_n_cols); mem_resize(n_unique(X, Y, op_n_unique_count())); - + // Now on a second iteration, fill it. - typename SpMat::const_iterator x_it = X.begin(); - typename SpMat::const_iterator y_it = Y.begin(); + typename SpMat::const_iterator x_it = X.begin(); + typename SpMat::const_iterator x_end = X.end(); + + typename SpMat::const_iterator y_it = Y.begin(); + typename SpMat::const_iterator y_end = Y.end(); + uword cur_pos = 0; - - while ((x_it != X.end()) || (y_it != Y.end())) + + while ((x_it != x_end) || (y_it != y_end)) { if(x_it == y_it) // if we are at the same place { access::rw(values[cur_pos]) = std::complex((T) *x_it, (T) *y_it); access::rw(row_indices[cur_pos]) = x_it.row(); ++access::rw(col_ptrs[x_it.col() + 1]); - + ++x_it; ++y_it; } @@ -673,7 +678,7 @@ access::rw(values[cur_pos]) = std::complex((T) *x_it, T(0)); access::rw(row_indices[cur_pos]) = x_it.row(); ++access::rw(col_ptrs[x_it.col() + 1]); - + ++x_it; } else // x is closer to the end @@ -681,20 +686,20 @@ access::rw(values[cur_pos]) = std::complex(T(0), (T) *y_it); access::rw(row_indices[cur_pos]) = y_it.row(); ++access::rw(col_ptrs[y_it.col() + 1]); - + ++y_it; } } - + ++cur_pos; } - + // Now fix the column pointers; they are supposed to be a sum. for (uword c = 1; c <= n_cols; ++c) { access::rw(col_ptrs[c]) += col_ptrs[c - 1]; } - + } Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -12,9 +12,9 @@ #define ARMA_VERSION_MAJOR 3 -#define ARMA_VERSION_MINOR 810 -#define ARMA_VERSION_PATCH 2 -#define ARMA_VERSION_NAME "Newell Highway" +#define ARMA_VERSION_MINOR 820 +#define ARMA_VERSION_PATCH 0 +#define ARMA_VERSION_NAME "Mt Cootha" Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/compiler_setup.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/compiler_setup.hpp 2013-04-30 12:11:22 UTC (rev 4314) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/compiler_setup.hpp 2013-05-13 14:52:58 UTC (rev 4315) @@ -134,12 +134,8 @@ #endif #if ( (ARMA_GCC_VERSION >= 40700) && (ARMA_GCC_VERSION <= 40701) ) - #define ARMA_GCC47_BUG - - #warning "*** Detected GCC 4.7.0 / 4.7.1, which has a regression (bug)" - #warning "*** See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53549 " - #warning "*** A partial workaround for the bug has been activated, " - #warning "*** which reduces some functionality in fixed-size matrices " + #error "gcc versions 4.7.0 and 4.7.1 are unsupported; use 4.7.2 or later" + // due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53549 #endif #undef ARMA_GCC_VERSION [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/rcpp -r 4315 From noreply at r-forge.r-project.org Tue May 14 20:59:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 14 May 2013 20:59:07 +0200 (CEST) Subject: [Rcpp-commits] r4316 - pkg/Rcpp Message-ID: <20130514185907.6FD561855A3@r-forge.r-project.org> Author: edd Date: 2013-05-14 20:59:07 +0200 (Tue, 14 May 2013) New Revision: 4316 Modified: pkg/Rcpp/TODO Log: add buglet regarding 'char' reported as SO post Modified: pkg/Rcpp/TODO =================================================================== --- pkg/Rcpp/TODO 2013-05-13 14:52:58 UTC (rev 4315) +++ pkg/Rcpp/TODO 2013-05-14 18:59:07 UTC (rev 4316) @@ -10,6 +10,9 @@ o DataFrame::create(Named("a")=b, Named("b")=b) fails with NumericVectors + o Single char variables do not seem to covered correctly by as<>() + and wrap() (cf http://stackoverflow.com/questions/16535899/) + Documentation o Finish the quickref vignette From noreply at r-forge.r-project.org Thu May 16 23:27:20 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 16 May 2013 23:27:20 +0200 (CEST) Subject: [Rcpp-commits] r4317 - in pkg/RcppArmadillo: . inst/examples/kalman Message-ID: <20130516212721.00904185668@r-forge.r-project.org> Author: edd Date: 2013-05-16 23:27:20 +0200 (Thu, 16 May 2013) New Revision: 4317 Removed: pkg/RcppArmadillo/inst/examples/kalman/KalmanCpp.R Modified: pkg/RcppArmadillo/ChangeLog pkg/RcppArmadillo/inst/examples/kalman/Kalman.cpp pkg/RcppArmadillo/inst/examples/kalman/benchmark.R Log: switch Kalman example from cxxfunction to sourceCpp Modified: pkg/RcppArmadillo/ChangeLog =================================================================== --- pkg/RcppArmadillo/ChangeLog 2013-05-14 18:59:07 UTC (rev 4316) +++ pkg/RcppArmadillo/ChangeLog 2013-05-16 21:27:20 UTC (rev 4317) @@ -1,3 +1,9 @@ +2013-05-16 Dirk Eddelbuettel + + * inst/examples/kalman/benchmark.R: Switch from inline to sourceCpp + * inst/examples/kalman/Kalman.cpp: Added Rcpp attributes function + * inst/examples/kalman/KalmanCpp.R: Retired, no longer used + 2013-05-13 Dirk Eddelbuettel * DESCRIPTION: Release 0.3.820 Modified: pkg/RcppArmadillo/inst/examples/kalman/Kalman.cpp =================================================================== --- pkg/RcppArmadillo/inst/examples/kalman/Kalman.cpp 2013-05-14 18:59:07 UTC (rev 4316) +++ pkg/RcppArmadillo/inst/examples/kalman/Kalman.cpp 2013-05-16 21:27:20 UTC (rev 4317) @@ -1,3 +1,8 @@ + +// [[Rcpp::depends(RcppArmadillo)]] + +#include + using namespace arma; class Kalman { @@ -44,3 +49,11 @@ return Y; } }; + + +// [[Rcpp::export]] +mat KalmanCpp(mat Z) { + Kalman K; + mat Y = K.estimate(Z); + return Y; +} Deleted: pkg/RcppArmadillo/inst/examples/kalman/KalmanCpp.R =================================================================== --- pkg/RcppArmadillo/inst/examples/kalman/KalmanCpp.R 2013-05-14 18:59:07 UTC (rev 4316) +++ pkg/RcppArmadillo/inst/examples/kalman/KalmanCpp.R 2013-05-16 21:27:20 UTC (rev 4317) @@ -1,59 +0,0 @@ -kalmanClass <- ' -using namespace arma; - -class Kalman { -private: - mat A, H, Q, R, xest, pest; - double dt; - -public: - // constructor, sets up data structures - Kalman() : dt(1.0) { - A.eye(6,6); - A(0,2) = A(1,3) = A(2,4) = A(3,5) = dt; - H.zeros(2,6); - H(0,0) = H(1,1) = 1.0; - Q.eye(6,6); - R = 1000 * eye(2,2); - xest.zeros(6,1); - pest.zeros(6,6); - } - - // sole member function: estimate model - mat estimate(const mat & Z) { - unsigned int n = Z.n_rows, k = Z.n_cols; - mat Y = zeros(n, k); - mat xprd, pprd, S, B, kalmangain; - colvec z, y; - - for (unsigned int i = 0; i(ZS); // passed from R - Kalman K; - mat Y = K.estimate(Z); - return wrap(Y);' - -KalmanCpp <- cxxfunction(signature(ZS="numeric"), - body=kalmanSrc, include=kalmanClass, - plugin="RcppArmadillo") Modified: pkg/RcppArmadillo/inst/examples/kalman/benchmark.R =================================================================== --- pkg/RcppArmadillo/inst/examples/kalman/benchmark.R 2013-05-14 18:59:07 UTC (rev 4316) +++ pkg/RcppArmadillo/inst/examples/kalman/benchmark.R 2013-05-16 21:27:20 UTC (rev 4317) @@ -1,13 +1,12 @@ suppressMessages(library(Rcpp)) -suppressMessages(library(inline)) suppressMessages(library(rbenchmark)) suppressMessages(library(compiler)) source("FirstKalmanR.R") source("KalmanR.R") source("KalmanRimp.R") -source("KalmanCpp.R") +sourceCpp("Kalman.cpp") FirstKalmanRC <- cmpfun(FirstKalmanR) KalmanRC <- cmpfun(KalmanR) From noreply at r-forge.r-project.org Sat May 18 03:32:10 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 18 May 2013 03:32:10 +0200 (CEST) Subject: [Rcpp-commits] r4318 - pkg/Rcpp/src Message-ID: <20130518013210.DF323185072@r-forge.r-project.org> Author: jjallaire Date: 2013-05-18 03:32:08 +0200 (Sat, 18 May 2013) New Revision: 4318 Modified: pkg/Rcpp/src/api.cpp Log: use unsigned long for RNG scope counter Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-05-16 21:27:20 UTC (rev 4317) +++ pkg/Rcpp/src/api.cpp 2013-05-18 01:32:08 UTC (rev 4318) @@ -1942,7 +1942,7 @@ namespace Rcpp{ namespace internal{ namespace { - int RNGScopeCounter = 0; + unsigned long RNGScopeCounter = 0; } void enterRNGScope() { From noreply at r-forge.r-project.org Sat May 18 03:39:14 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 18 May 2013 03:39:14 +0200 (CEST) Subject: [Rcpp-commits] r4319 - pkg/Rcpp/src Message-ID: <20130518013914.207071855DB@r-forge.r-project.org> Author: jjallaire Date: 2013-05-18 03:39:13 +0200 (Sat, 18 May 2013) New Revision: 4319 Modified: pkg/Rcpp/src/attributes.cpp Log: prevent gc problems with RNGScope destructor in attributes generated functions; don't include package header file in generated cpp exports file Modified: pkg/Rcpp/src/attributes.cpp =================================================================== --- pkg/Rcpp/src/attributes.cpp 2013-05-18 01:32:08 UTC (rev 4318) +++ pkg/Rcpp/src/attributes.cpp 2013-05-18 01:39:13 UTC (rev 4319) @@ -1657,8 +1657,10 @@ << getCCallable(package() + "_" + function.name()) << ";" << std::endl; ostr() << " }" << std::endl; - ostr() << " RNGScope __rngScope;" << std::endl; - ostr() << " RObject __result = " << ptrName << "("; + ostr() << " RObject __result;" << std::endl; + ostr() << " {" << std::endl; + ostr() << " RNGScope __rngScope;" << std::endl; + ostr() << " __result = " << ptrName << "("; const std::vector& args = function.arguments(); for (std::size_t i = 0; i(" << argument.name() << "SEXP);" << std::endl; } - ostr << " "; + ostr << " "; if (!function.type().isVoid()) ostr << function.type() << " __result = "; ostr << function.name() << "("; @@ -2145,10 +2158,22 @@ ostr << ", "; } ostr << ");" << std::endl; - - std::string res = function.type().isVoid() ? "R_NilValue" : - "Rcpp::wrap(__result)"; - ostr << " return " << res << ";" << std::endl; + + if (!function.type().isVoid()) + { + ostr << " PROTECT(__sexp_result = Rcpp::wrap(__result));" + << std::endl; + } + ostr << " }" << std::endl; + if (!function.type().isVoid()) + { + ostr << " UNPROTECT(1);" << std::endl; + ostr << " return __sexp_result;" << std::endl; + } + else + { + ostr << " return R_NilValue;" << std::endl; + } ostr << (cppInterface ? "END_RCPP_RETURN_ERROR" : "END_RCPP") << std::endl; ostr << "}" << std::endl; @@ -2157,8 +2182,10 @@ if (cppInterface) { ostr << "RcppExport SEXP " << funcName << "(" << args << ") {" << std::endl; - ostr << " Rcpp::RNGScope __rngScope;" << std::endl; - ostr << " SEXP __result = PROTECT(" << funcName + ostr << " SEXP __result;" << std::endl; + ostr << " {" << std::endl; + ostr << " Rcpp::RNGScope __rngScope;" << std::endl; + ostr << " __result = PROTECT(" << funcName << kTrySuffix << "("; for (size_t i = 0; i Author: jjallaire Date: 2013-05-18 03:48:15 +0200 (Sat, 18 May 2013) New Revision: 4320 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/DESCRIPTION pkg/Rcpp/inst/NEWS.Rd Log: update ChangeLog and NEWS; bump version to 0.10.3.3 Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-05-18 01:39:13 UTC (rev 4319) +++ pkg/Rcpp/ChangeLog 2013-05-18 01:48:15 UTC (rev 4320) @@ -1,3 +1,10 @@ +2013-05-17 J.J. Allaire + + * src/attributes.cpp: prevent gc problems with RNGScope destructor + in attributes generated functions; don't include package header file + in generated cpp exports file + * src/api.cpp: use unsigned long for RNG scope counter + 2013-04-28 Dirk Eddelbuettel * src/api.cpp (Rcpp): No longer use Rd_format(Real|Complex) which is Modified: pkg/Rcpp/DESCRIPTION =================================================================== --- pkg/Rcpp/DESCRIPTION 2013-05-18 01:39:13 UTC (rev 4319) +++ pkg/Rcpp/DESCRIPTION 2013-05-18 01:48:15 UTC (rev 4320) @@ -1,6 +1,6 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.10.3.2 +Version: 0.10.3.3 Date: $Date$ Author: Dirk Eddelbuettel and Romain Francois, with contributions by Douglas Bates, John Chambers and JJ Allaire Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-05-18 01:39:13 UTC (rev 4319) +++ pkg/Rcpp/inst/NEWS.Rd 2013-05-18 01:48:15 UTC (rev 4320) @@ -5,7 +5,13 @@ \section{Changes in Rcpp version 0.10.4 (future)}{ \itemize{ \item Changes in R code: - \item Changes in Rcpp attributes: + \item Changes in Rcpp attributes: + \itemize{ + \item Fixed problem whereby the interaction between the gc and the + RNGScope destructor could cause a crash. + \item Don't include package header file in generated C++ interface + header files. + } \item Changes in Rcpp API: \itemize{ \item The \code{DataFrame::create} set of functions has been reworked @@ -13,6 +19,7 @@ constructor \item The \code{operator-()} semantics for \code{Date} and \code{Datetime} are now more inline with standard C++ behaviour. + \item RNGScope counter now uses unsigned long rather than int. } \item Changes in Rcpp sugar: \itemize{ From noreply at r-forge.r-project.org Tue May 21 12:36:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 21 May 2013 12:36:05 +0200 (CEST) Subject: [Rcpp-commits] r4321 - in pkg/Rcpp: . R inst man Message-ID: <20130521103605.1313C184479@r-forge.r-project.org> Author: jjallaire Date: 2013-05-21 12:36:04 +0200 (Tue, 21 May 2013) New Revision: 4321 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/R/Attributes.R pkg/Rcpp/inst/NEWS.Rd pkg/Rcpp/man/pluginsAttribute.Rd Log: Lookup plugins in inline package if they aren't found within the Rcpp package Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-05-18 01:48:15 UTC (rev 4320) +++ pkg/Rcpp/ChangeLog 2013-05-21 10:36:04 UTC (rev 4321) @@ -1,3 +1,9 @@ +2013-05-21 J.J. Allaire + + * R/Attributes.R: Lookup plugins in inline package if they aren't + found within the Rcpp package + * man/pluginsAttribute.Rd: Documentation updates. + 2013-05-17 J.J. Allaire * src/attributes.cpp: prevent gc problems with RNGScope destructor Modified: pkg/Rcpp/R/Attributes.R =================================================================== --- pkg/Rcpp/R/Attributes.R 2013-05-18 01:48:15 UTC (rev 4320) +++ pkg/Rcpp/R/Attributes.R 2013-05-21 10:36:04 UTC (rev 4321) @@ -198,7 +198,7 @@ # append plugin includes for (pluginName in plugins) { - plugin <- .plugins[[pluginName]] + plugin <- .findPlugin(pluginName) settings <- plugin() scaffolding <- c(scaffolding, settings$includes, recursive=TRUE) } @@ -445,6 +445,25 @@ error = function(e) NULL) } +# Lookup a plugin (first in our package then in the inline package) +.findPlugin <- function(pluginName) { + # lookup in our plugins + plugin <- .plugins[[pluginName]] + + # if necessary lookup in the inline package + if (is.null(plugin)) + if (length(find.package("inline", quiet=TRUE)) > 0) + plugin <- inline:::plugins[[pluginName]] + + # error if plugin not found + if (is.null(plugin)) + stop("Inline plugin '", pluginName, "' could not be found ", + "within either the Rcpp or inline package. You should be ", + "sure to call registerPlugin before using a plugin.") + + return(plugin) +} + # Setup the build environment based on the specified dependencies. Returns an # opaque object that can be passed to .restoreEnvironment to reverse whatever # changes that were made @@ -507,9 +526,7 @@ # process plugins for (pluginName in plugins) { - plugin <- .plugins[[pluginName]] - if (is.null(plugin)) - stop("Inline plugin '", pluginName, "' could not be found.") + plugin <- .findPlugin(pluginName) setDependenciesFromPlugin(plugin) } Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-05-18 01:48:15 UTC (rev 4320) +++ pkg/Rcpp/inst/NEWS.Rd 2013-05-21 10:36:04 UTC (rev 4321) @@ -11,6 +11,8 @@ RNGScope destructor could cause a crash. \item Don't include package header file in generated C++ interface header files. + \item Lookup plugins in \pkg{inline} package if they aren't found + within the \pkg{Rcpp} package. } \item Changes in Rcpp API: \itemize{ Modified: pkg/Rcpp/man/pluginsAttribute.Rd =================================================================== --- pkg/Rcpp/man/pluginsAttribute.Rd 2013-05-18 01:48:15 UTC (rev 4320) +++ pkg/Rcpp/man/pluginsAttribute.Rd 2013-05-21 10:36:04 UTC (rev 4321) @@ -21,6 +21,9 @@ Plugins must be registered using the \code{\link{registerPlugin}} function. +If a plugin is not found within the \pkg{Rcpp} package then the +\pkg{inline} package will also be searched for a matching plugin. + When included within a \code{\link{sourceCpp}} translation unit, the configuration-related fields of the plugin (e.g. \code{env} and \code{LinkingTo}) are utilized, however the code-generation fields From noreply at r-forge.r-project.org Fri May 24 23:53:33 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 24 May 2013 23:53:33 +0200 (CEST) Subject: [Rcpp-commits] r4322 - in pkg/Rcpp: . R inst Message-ID: <20130524215334.0924B184FA3@r-forge.r-project.org> Author: jjallaire Date: 2013-05-24 23:53:33 +0200 (Fri, 24 May 2013) New Revision: 4322 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/R/Attributes.R pkg/Rcpp/inst/NEWS.Rd Log: Disallow compilation for files that don't have extensions supported by R CMD SHLIB Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-05-21 10:36:04 UTC (rev 4321) +++ pkg/Rcpp/ChangeLog 2013-05-24 21:53:33 UTC (rev 4322) @@ -1,3 +1,8 @@ +2013-05-24 J.J. Allaire + + * R/Attributes.R: Disallow compilation for files that don't have + extensions supported by R CMD SHLIB + 2013-05-21 J.J. Allaire * R/Attributes.R: Lookup plugins in inline package if they aren't Modified: pkg/Rcpp/R/Attributes.R =================================================================== --- pkg/Rcpp/R/Attributes.R 2013-05-21 10:36:04 UTC (rev 4321) +++ pkg/Rcpp/R/Attributes.R 2013-05-24 21:53:33 UTC (rev 4322) @@ -35,6 +35,12 @@ # resolve the file path file <- normalizePath(file, winslash = "/") + # error if the file extension isn't one supported by R CMD SHLIB + if (! tools::file_ext(file) %in% c("cc", "cpp")) { + stop("The filename '", basename(file), "' does not have an ", + "extension of .cc or .cpp so cannot be compiled.") + } + # validate that there are no spaces in the path on windows if (.Platform$OS.type == "windows") { if (grepl(' ', basename(file), fixed=TRUE)) { Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-05-21 10:36:04 UTC (rev 4321) +++ pkg/Rcpp/inst/NEWS.Rd 2013-05-24 21:53:33 UTC (rev 4322) @@ -13,6 +13,8 @@ header files. \item Lookup plugins in \pkg{inline} package if they aren't found within the \pkg{Rcpp} package. + \item Disallow compilation for files that don't have extensions + supported by R CMD SHLIB } \item Changes in Rcpp API: \itemize{ From noreply at r-forge.r-project.org Sun May 26 21:52:23 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 26 May 2013 21:52:23 +0200 (CEST) Subject: [Rcpp-commits] r4323 - in pkg/Rcpp: . src Message-ID: <20130526195223.339FF184B55@r-forge.r-project.org> Author: edd Date: 2013-05-26 21:52:22 +0200 (Sun, 26 May 2013) New Revision: 4323 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/src/api.cpp Log: Minor tweak for internal formatting Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-05-24 21:53:33 UTC (rev 4322) +++ pkg/Rcpp/ChangeLog 2013-05-26 19:52:22 UTC (rev 4323) @@ -1,3 +1,7 @@ +2013-05-26 Dirk Eddelbuettel + + * src/api.cpp: Minor tweak for internal formatting + 2013-05-24 J.J. Allaire * R/Attributes.R: Disallow compilation for files that don't have Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-05-24 21:53:33 UTC (rev 4322) +++ pkg/Rcpp/src/api.cpp 2013-05-26 19:52:22 UTC (rev 4323) @@ -1767,8 +1767,7 @@ // char* tmp = const_cast( Rf_EncodeReal(x, w, d, e, '.') ); // so approximate it poorly as static char tmp[128]; - //snprintf(tmp, 127, "%*.*f", w, d, x); - snprintf(tmp, 127, "%f", x); // FIXME: barebones defaults + snprintf(tmp, 127, "%f", x); return dropTrailing0(tmp, '.'); } @@ -1778,10 +1777,13 @@ // we are no longer allowed to use this: // Rf_EncodeComplex(x, wr, dr, er, wi, di, ei, '.' ); // so approximate it poorly as - static char tmp[128]; + static char tmp1[128], tmp2[128], tmp3[256]; //snprintf(tmp, 127, "%*.*f+%*.*fi", wr, dr, x.r, wi, di, x.i); - snprintf(tmp, 127, "%*.*f+%*.*fi", x.r, x.i); // FIXEM: barebones default formatting - return tmp; + //snprintf(tmp, 127, "%f+%fi", x.r, x.i); // FIXEM: barebones default formatting + snprintf(tmp1, 127, "%f", x.r); + snprintf(tmp2, 127, "%f", x.i); + snprintf(tmp3, 255, "%s+%si", dropTrailing0(tmp1, '.'), dropTrailing0(tmp2, '.')); + return tmp3; } } // internal From noreply at r-forge.r-project.org Thu May 30 16:13:18 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 30 May 2013 16:13:18 +0200 (CEST) Subject: [Rcpp-commits] r4324 - in pkg/Rcpp: . inst inst/include/Rcpp/sugar/functions inst/include/Rcpp/traits inst/unitTests inst/unitTests/cpp Message-ID: <20130530141318.8560B185749@r-forge.r-project.org> Author: romain Date: 2013-05-30 16:13:18 +0200 (Thu, 30 May 2013) New Revision: 4324 Added: pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_finite.h pkg/Rcpp/inst/include/Rcpp/traits/is_finite.h Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/NEWS.Rd pkg/Rcpp/inst/include/Rcpp/sugar/functions/all.h pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_na.h pkg/Rcpp/inst/include/Rcpp/traits/traits.h pkg/Rcpp/inst/unitTests/cpp/sugar.cpp pkg/Rcpp/inst/unitTests/runit.sugar.R Log: added is_finite Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-05-26 19:52:22 UTC (rev 4323) +++ pkg/Rcpp/ChangeLog 2013-05-30 14:13:18 UTC (rev 4324) @@ -1,3 +1,11 @@ +2013-05-30 Romain Francois + + * include/Rcpp/sugar/functions/all.h : bug fixed for the NA=false case + * include/Rcpp/sugar/functions/is_na.h : header + * include/Rcpp/sugar/functions/is_finite.h : added sugar is_finite function + * include/Rcpp/traits/is_finite.h : added is_finite trait + * unitTests/runit.sugar.R : added test for is_finite + 2013-05-26 Dirk Eddelbuettel * src/api.cpp: Minor tweak for internal formatting Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-05-26 19:52:22 UTC (rev 4323) +++ pkg/Rcpp/inst/NEWS.Rd 2013-05-30 14:13:18 UTC (rev 4324) @@ -29,6 +29,8 @@ \itemize{ \item New function \code{na_omit} based on the StackOverflow thread http://stackoverflow.com/questions/15953768/templated-rcpp-function-to-erase-na-values + \item New function \code{is_finite} that reproduces the behavior of + R's \code{is.finite} function } \item Changes in Rcpp build tools: \itemize{ Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/all.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/functions/all.h 2013-05-26 19:52:22 UTC (rev 4323) +++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/all.h 2013-05-30 14:13:18 UTC (rev 4324) @@ -2,7 +2,7 @@ // // all.h: Rcpp R/C++ interface class library -- all // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -67,7 +67,7 @@ int n = object.size() ; PARENT::set_true() ; for( int i=0 ; i #include #include +#include #include #include #include Added: pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_finite.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_finite.h (rev 0) +++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_finite.h 2013-05-30 14:13:18 UTC (rev 4324) @@ -0,0 +1,55 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// is_finite.h: Rcpp R/C++ interface class library -- is_finite +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// +// 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__sugar__is_finite_h +#define Rcpp__sugar__is_finite_h + +namespace Rcpp{ +namespace sugar{ + +template +class IsFinite : public ::Rcpp::VectorBase< LGLSXP, false, IsFinite > { +public: + + IsFinite( const VEC_TYPE& obj_) : obj(obj_){} + + inline int operator[]( int i ) const { + return ::Rcpp::traits::is_finite( obj[i] ) ; + } + + inline int size() const { return obj.size() ; } + +private: + const VEC_TYPE& obj ; + +} ; + + +} // sugar + +template +inline sugar::IsFinite is_finite( const Rcpp::VectorBase& t){ + return sugar::IsFinite( t.get_ref() ) ; +} + +} // Rcpp +#endif + Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_na.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_na.h 2013-05-26 19:52:22 UTC (rev 4323) +++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_na.h 2013-05-30 14:13:18 UTC (rev 4324) @@ -1,8 +1,8 @@ // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- // -// any.h: Rcpp R/C++ interface class library -- any +// is_na.h: Rcpp R/C++ interface class library -- is_na // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // Added: pkg/Rcpp/inst/include/Rcpp/traits/is_finite.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/is_finite.h (rev 0) +++ pkg/Rcpp/inst/include/Rcpp/traits/is_finite.h 2013-05-30 14:13:18 UTC (rev 4324) @@ -0,0 +1,56 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// is_finite.h: Rcpp R/C++ interface class library -- is finite +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// +// 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_is_finite_h +#define Rcpp__traits_is_finite_h + +namespace Rcpp{ +namespace traits{ + + // default for complex, + template + bool is_finite( typename storage_type::type) ; + + template <> + inline bool is_finite( int x ){ + return x != NA_INTEGER ; + } + + template <> + inline bool is_finite( double x ){ + return R_finite(x) ; + } + + template <> + inline bool is_finite( Rcomplex x ){ + return !( !R_finite(x.r) || !R_finite(x.i) ); + } + + template <> + inline bool is_finite( SEXP x ){ return x != NA_STRING ; } + + template <> + inline bool is_finite( int x ){ return x != NA_LOGICAL ; } + +} +} + +#endif Modified: pkg/Rcpp/inst/include/Rcpp/traits/traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-05-26 19:52:22 UTC (rev 4323) +++ pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-05-30 14:13:18 UTC (rev 4324) @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include Modified: pkg/Rcpp/inst/unitTests/cpp/sugar.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/sugar.cpp 2013-05-26 19:52:22 UTC (rev 4323) +++ pkg/Rcpp/inst/unitTests/cpp/sugar.cpp 2013-05-30 14:13:18 UTC (rev 4324) @@ -180,6 +180,11 @@ } // [[Rcpp::export]] +LogicalVector runit_isfinite( NumericVector xx){ + return is_finite(xx) ; +} + +// [[Rcpp::export]] LogicalVector runit_isna_isna( NumericVector xx ){ return wrap( is_na( is_na( xx ) ) ) ; } Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.sugar.R 2013-05-26 19:52:22 UTC (rev 4323) +++ pkg/Rcpp/inst/unitTests/runit.sugar.R 2013-05-30 14:13:18 UTC (rev 4324) @@ -1,7 +1,7 @@ #!/usr/bin/r -t # -*- mode: R; ess-indent-level: 4; indent-tabs-mode: nil; -*- # -# Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -266,6 +266,13 @@ checkEquals( fx( 1:10) , rep(FALSE,10) ) } +test.sugar.isfinite <- function( ){ + checkEquals( + runit_isfinite( c(1, NA, Inf, -Inf, NaN) ) , + c(TRUE, FALSE, FALSE, FALSE, FALSE) + ) +} + test.sugar.isna.isna <- function( ){ fx <- runit_isna_isna checkEquals( fx( c(1:5,NA,7:10) ) , rep(FALSE,10) ) From noreply at r-forge.r-project.org Thu May 30 18:01:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 30 May 2013 18:01:04 +0200 (CEST) Subject: [Rcpp-commits] r4325 - in pkg/Rcpp: . inst/unitTests inst/unitTests/cpp Message-ID: <20130530160104.89178184F6E@r-forge.r-project.org> Author: romain Date: 2013-05-30 18:01:04 +0200 (Thu, 30 May 2013) New Revision: 4325 Added: pkg/Rcpp/inst/unitTests/cpp/Reference.cpp pkg/Rcpp/inst/unitTests/cpp/S4.cpp pkg/Rcpp/inst/unitTests/runit.Reference.R Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/unitTests/runit.S4.R Log: added Reference unit test Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-05-30 14:13:18 UTC (rev 4324) +++ pkg/Rcpp/ChangeLog 2013-05-30 16:01:04 UTC (rev 4325) @@ -5,6 +5,10 @@ * include/Rcpp/sugar/functions/is_finite.h : added sugar is_finite function * include/Rcpp/traits/is_finite.h : added is_finite trait * unitTests/runit.sugar.R : added test for is_finite + * unitTests/cpp/S4.cpp : new cpp file to host S4 unit tests + * unitTests/runit.S4.R : rework unit tests to use attributes + * unitTests/runit.Reference.R : unit tests for Rcpp::Reference + * unitTests/cpp/Reference.cpp : unit tests c++ code 2013-05-26 Dirk Eddelbuettel Added: pkg/Rcpp/inst/unitTests/cpp/Reference.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/Reference.cpp (rev 0) +++ pkg/Rcpp/inst/unitTests/cpp/Reference.cpp 2013-05-30 16:01:04 UTC (rev 4325) @@ -0,0 +1,30 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// Reference.cpp: Rcpp R/C++ interface class library -- Reference unit tests +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// +// 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 . + +#include +using namespace Rcpp ; + +// [[Rcpp::export]] +std::string runit_Reference_getId(Reference obj) { + std::string txt = obj.field("id"); + return txt; +} + Added: pkg/Rcpp/inst/unitTests/cpp/S4.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/S4.cpp (rev 0) +++ pkg/Rcpp/inst/unitTests/cpp/S4.cpp 2013-05-30 16:01:04 UTC (rev 4325) @@ -0,0 +1,82 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// S4.cpp: Rcpp R/C++ interface class library -- S4 unit tests +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// +// 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 . + +#include +using namespace Rcpp ; + +// [[Rcpp::export]] +List S4_methods( RObject y ){ + List res(5) ; + res[0] = y.isS4() ; + res[1] = y.hasSlot("x") ; + res[2] = y.hasSlot("z") ; + res[3] = y.slot("x") ; + res[4] = y.slot("y") ; + return res ; +} + +// [[Rcpp::export]] +void S4_getslots( S4 y){ + y.slot( "x" ) = 10.0 ; + y.slot( "y" ) = 20.0 ; +} + +// [[Rcpp::export]] +void S4_setslots( S4 y ){ + y.slot( "foo" ) = 10.0 ; +} + +// [[Rcpp::export]] +void S4_setslots_2( S4 y){ + y.slot( "foo" ) ; +} + +// [[Rcpp::export]] +S4 S4_ctor( std::string cl){ + return S4( cl ); +} + +// [[Rcpp::export]] +bool S4_is_track(S4 tr){ + return tr.is("track") ; +} + +// [[Rcpp::export]] +bool S4_is_trackCurve(S4 tr){ + return tr.is("trackCurve") ; +} + +// [[Rcpp::export]] +NumericVector S4_get_slot_x(S4 o){ + return NumericVector(o.slot("x")) ; +} + +// [[Rcpp::export]] +CharacterVector S4_get_attr_x(IntegerVector o){ + return CharacterVector(o.attr("foo")) ; +} + +// [[Rcpp::export]] +S4 S4_dotdata(S4 foo){ + foo.slot( ".Data" ) = "foooo" ; + return foo ; +} + Added: pkg/Rcpp/inst/unitTests/runit.Reference.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.Reference.R (rev 0) +++ pkg/Rcpp/inst/unitTests/runit.Reference.R 2013-05-30 16:01:04 UTC (rev 4325) @@ -0,0 +1,41 @@ +#!/usr/bin/r -t +# +# Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +# +# 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/Reference.cpp")) +} + +test.Reference <- function(){ + Instrument <-setRefClass( + Class="Instrument", + fields=list("id"="character", "description"="character") + ) + Instrument$accessors(c("id", "description")) + + instrument <- Instrument$new(id="AAPL", description="Apple") + + checkEquals( runit_Reference_getId(instrument), "AAPL", msg = ".field" ) +} + + +} Modified: pkg/Rcpp/inst/unitTests/runit.S4.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.S4.R 2013-05-30 14:13:18 UTC (rev 4324) +++ pkg/Rcpp/inst/unitTests/runit.S4.R 2013-05-30 16:01:04 UTC (rev 4325) @@ -1,6 +1,6 @@ #!/usr/bin/r -t # -# Copyright (C) 2010 -2012 Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -21,135 +21,40 @@ if (.runThisTest) { -definitions <- function(){ - list( - "S4_methods" = list( - signature(x = "ANY" ), ' - RObject y(x) ; - List res(5) ; - res[0] = y.isS4() ; - res[1] = y.hasSlot("x") ; - res[2] = y.hasSlot("z") ; - res[3] = y.slot("x") ; - res[4] = y.slot("y") ; - return res ; - ' - ), - "S4_getslots" = list( - signature(x = "ANY" ), ' - RObject y(x) ; - y.slot( "x" ) = 10.0 ; - y.slot( "y" ) = 20.0 ; - return R_NilValue ; - ' - ), - "S4_setslots" = list( - signature(x = "ANY" ), ' - RObject y(x) ; - y.slot( "foo" ) = 10.0 ; - return R_NilValue ; - ' - ), - "S4_setslots_2" = list( - signature(x = "ANY" ), ' - RObject y(x) ; - y.slot( "foo" ) ; - return R_NilValue ; - ' - ), - "S4_ctor" = list( - signature( clazz = "character" ), - ' - std::string cl = as( clazz ); - return S4( cl ); - ' - ), - "S4_is" = list( - signature(tr="ANY"), ' - S4 o(tr) ; - return wrap( o.is( "track" ) ) ; - ' - ), - "S4_is_2" = list( - signature(tr="ANY"), ' - S4 o(tr) ; - return wrap( o.is( "trackCurve" ) ) ; - ' - ), - "S4_slotproxy" = list( - signature(tr="ANY"), - ' S4 o(tr); return NumericVector(o.slot("x")); ' - ), - "S4_attrproxy" = list( - signature(tr="ANY"), - ' IntegerVector o(tr); return CharacterVector(o.attr("foo")); ' - ), - "S4_dotdata" = list( - signature( x = "ANY" ), - ' - S4 foo( x ) ; - foo.slot( ".Data" ) = "foooo" ; - return foo ; - ' - ) - ) - -} - -cxxargs <- function(){ - ifelse(Rcpp:::capabilities()[["initializer lists"]],"-std=c++0x","") -} - .setUp <- function() { - tests <- ".rcpp.S4" - if( ! exists( tests, globalenv() )) { - fun <- Rcpp:::compile_unit_tests( - definitions(), - cxxargs = cxxargs() - ) - assign( tests, fun, globalenv() ) - } + sourceCpp(file.path(pathRcppTests, "cpp/S4.cpp")) } test.RObject.S4methods <- function(){ - fx <- .rcpp.S4$S4_methods - setClass("track", - representation(x="numeric", y="numeric")) + setClass("track", representation(x="numeric", y="numeric")) tr <- new( "track", x = 2, y = 2 ) - checkEquals( fx(tr), - list( TRUE, TRUE, FALSE, 2.0, 2.0 ) - , msg = "slot management" ) + checkEquals( + S4_methods(tr), + list( TRUE, TRUE, FALSE, 2.0, 2.0 ), + msg = "slot management" ) - fx <- .rcpp.S4$S4_getslots - fx( tr ) + S4_getslots( tr ) checkEquals( tr at x, 10.0 , msg = "slot('x') = 10" ) checkEquals( tr at y, 20.0 , msg = "slot('y') = 20" ) - fx <- .rcpp.S4$S4_setslots - checkException( fx( tr ), msg = "slot does not exist" ) + checkException( S4_setslots( tr ), msg = "slot does not exist" ) + checkException( S4_setslots_2( tr ), msg = "slot does not exist" ) - fx <- .rcpp.S4$S4_setslots_2 - checkException( fx( tr ), msg = "slot does not exist" ) - } test.S4 <- function(){ setClass("track", representation(x="numeric", y="numeric")) tr <- new( "track", x = 2, y = 3 ) - fx <- cxxfunction( signature( x = "ANY" ), - 'S4 o(x); return o.slot( "x" ) ;', plugin = "Rcpp" ) - checkEquals( fx( tr ), 2, msg = "S4( SEXP )" ) + checkEquals( S4_get_slot_x( tr ), 2, msg = "S4( SEXP )" ) + checkException( S4_get_slot_x( list( x = 2, y = 3 ) ), msg = "not S4" ) + checkException( S4_get_slot_x( structure( list( x = 2, y = 3 ), class = "track" ) ), msg = "S3 is not S4" ) - checkException( fx( list( x = 2, y = 3 ) ), msg = "not S4" ) - checkException( fx( structure( list( x = 2, y = 3 ), class = "track" ) ), msg = "S3 is not S4" ) - - fx <- .rcpp.S4$S4_ctor - tr <- fx( "track" ) + tr <- S4_ctor( "track" ) checkTrue( inherits( tr, "track" ) ) checkEquals( tr at x, numeric(0) ) checkEquals( tr at y, numeric(0) ) - checkException( fx( "someclassthatdoesnotexist" ) ) + checkException( S4_ctor( "someclassthatdoesnotexist" ) ) } @@ -160,13 +65,11 @@ tr1 <- new( "track", x = 2, y = 3 ) tr2 <- new( "trackCurve", x = 2, y = 3, smooth = 5 ) - fx <- .rcpp.S4$S4_is - checkTrue( fx( tr1 ), msg = 'track is track' ) - checkTrue( fx( tr2 ), msg = 'trackCurve is track' ) + checkTrue( S4_is_track( tr1 ), msg = 'track is track' ) + checkTrue( S4_is_track( tr2 ), msg = 'trackCurve is track' ) - fx <- .rcpp.S4$S4_is_2 - checkTrue( !fx( tr1 ), msg = 'track is not trackCurve' ) - checkTrue( fx( tr2 ), msg = 'trackCurve is trackCurve' ) + checkTrue( !S4_is_trackCurve( tr1 ), msg = 'track is not trackCurve' ) + checkTrue( S4_is_trackCurve( tr2 ), msg = 'trackCurve is trackCurve' ) } @@ -175,8 +78,7 @@ setClass("trackCurve", representation(smooth = "numeric"), contains = "track") tr1 <- new( "track", x = 2, y = 3 ) - fx <- .rcpp.S4$S4_slotproxy - checkEquals( fx(tr1), 2, "Vector( SlotProxy ) ambiguity" ) + checkEquals( S4_get_slot_x(tr1), 2, "Vector( SlotProxy ) ambiguity" ) } @@ -184,15 +86,13 @@ x <- 1:10 attr( x, "foo" ) <- "bar" - fx <- .rcpp.S4$S4_attrproxy - checkEquals( fx(x), "bar", "Vector( AttributeProxy ) ambiguity" ) + checkEquals( S4_get_attr_x(x), "bar", "Vector( AttributeProxy ) ambiguity" ) } test.S4.dotdataslot <- function(){ setClass( "Foo", contains = "character", representation( x = "numeric" ) ) - fx <- .rcpp.S4$S4_dotdata - foo <- fx( new( "Foo", "bla", x = 10 ) ) + foo <- S4_dotdata( new( "Foo", "bla", x = 10 ) ) checkEquals( as.character( foo) , "foooo" ) } From noreply at r-forge.r-project.org Fri May 31 11:04:22 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 31 May 2013 11:04:22 +0200 (CEST) Subject: [Rcpp-commits] r4326 - in pkg/Rcpp: . inst inst/include/Rcpp/sugar/functions inst/include/Rcpp/traits inst/unitTests inst/unitTests/cpp Message-ID: <20130531090422.7796F183F44@r-forge.r-project.org> Author: romain Date: 2013-05-31 11:04:22 +0200 (Fri, 31 May 2013) New Revision: 4326 Added: pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_infinite.h pkg/Rcpp/inst/include/Rcpp/traits/is_infinite.h Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/NEWS.Rd pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h pkg/Rcpp/inst/include/Rcpp/traits/traits.h pkg/Rcpp/inst/unitTests/cpp/sugar.cpp pkg/Rcpp/inst/unitTests/runit.sugar.R Log: added is_infinite Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-05-30 16:01:04 UTC (rev 4325) +++ pkg/Rcpp/ChangeLog 2013-05-31 09:04:22 UTC (rev 4326) @@ -1,3 +1,10 @@ +2013-05-31 Romain Francois + + * unitTests/runit.sugar.R : new test for is_infinite + * unitTests/cpp/sugar.cpp : new test for is_infinite + * include/Rcpp/sugar/functions/is_infinite.h : new function is_infinite + * include/Rcpp/traits/is_infinite.h : new function is_infinite + 2013-05-30 Romain Francois * include/Rcpp/sugar/functions/all.h : bug fixed for the NA=false case Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-05-30 16:01:04 UTC (rev 4325) +++ pkg/Rcpp/inst/NEWS.Rd 2013-05-31 09:04:22 UTC (rev 4326) @@ -29,13 +29,13 @@ \itemize{ \item New function \code{na_omit} based on the StackOverflow thread http://stackoverflow.com/questions/15953768/templated-rcpp-function-to-erase-na-values - \item New function \code{is_finite} that reproduces the behavior of - R's \code{is.finite} function + \item New function \code{is_finite} and \code{is_infinite} that reproduces + the behavior of R's \code{is.finite} and \code{is.infinite} functions } \item Changes in Rcpp build tools: \itemize{ \item Fix (from Martyn Plummer) for solaris in handling SingleLogicalResult. - \item The \code{src/Makevars} file can now optionally ovveride the + \item The \code{src/Makevars} file can now optionally override the path for \code{/usr/bin/install_name_tool} which is used on OS X. } } Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h 2013-05-30 16:01:04 UTC (rev 4325) +++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h 2013-05-31 09:04:22 UTC (rev 4326) @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include Added: pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_infinite.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_infinite.h (rev 0) +++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_infinite.h 2013-05-31 09:04:22 UTC (rev 4326) @@ -0,0 +1,55 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// is_infinite.h: Rcpp R/C++ interface class library -- is_infinite +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// +// 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__sugar__is_infinite_h +#define Rcpp__sugar__is_infinite_h + +namespace Rcpp{ +namespace sugar{ + +template +class IsInfinite : public ::Rcpp::VectorBase< LGLSXP, false, IsInfinite > { +public: + + IsInfinite( const VEC_TYPE& obj_) : obj(obj_){} + + inline int operator[]( int i ) const { + return ::Rcpp::traits::is_infinite( obj[i] ) ; + } + + inline int size() const { return obj.size() ; } + +private: + const VEC_TYPE& obj ; + +} ; + + +} // sugar + +template +inline sugar::IsInfinite is_infinite( const Rcpp::VectorBase& t){ + return sugar::IsInfinite( t.get_ref() ) ; +} + +} // Rcpp +#endif + Added: pkg/Rcpp/inst/include/Rcpp/traits/is_infinite.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/is_infinite.h (rev 0) +++ pkg/Rcpp/inst/include/Rcpp/traits/is_infinite.h 2013-05-31 09:04:22 UTC (rev 4326) @@ -0,0 +1,47 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// is_infinite.h: Rcpp R/C++ interface class library -- is infinite +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// +// 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_is_infinite_h +#define Rcpp__traits_is_infinite_h + +namespace Rcpp{ +namespace traits{ + + // default for all but REALSXP and CPLXSXP + template + bool is_infinite( typename storage_type::type){ + return false ; + } + + template <> + inline bool is_infinite( double x ){ + return !( ISNAN(x) || R_FINITE(x) ) ; + } + + template <> + inline bool is_infinite( Rcomplex x ){ + return is_infinite(x.r) || is_infinite(x.i) ; + } + +} +} + +#endif Modified: pkg/Rcpp/inst/include/Rcpp/traits/traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-05-30 16:01:04 UTC (rev 4325) +++ pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-05-31 09:04:22 UTC (rev 4326) @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include Modified: pkg/Rcpp/inst/unitTests/cpp/sugar.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/sugar.cpp 2013-05-30 16:01:04 UTC (rev 4325) +++ pkg/Rcpp/inst/unitTests/cpp/sugar.cpp 2013-05-31 09:04:22 UTC (rev 4326) @@ -185,8 +185,13 @@ } // [[Rcpp::export]] +LogicalVector runit_isinfinite( NumericVector xx){ + return is_infinite(xx) ; +} + +// [[Rcpp::export]] LogicalVector runit_isna_isna( NumericVector xx ){ - return wrap( is_na( is_na( xx ) ) ) ; + return is_na( is_na( xx ) ) ; } // [[Rcpp::export]] Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.sugar.R 2013-05-30 16:01:04 UTC (rev 4325) +++ pkg/Rcpp/inst/unitTests/runit.sugar.R 2013-05-31 09:04:22 UTC (rev 4326) @@ -269,10 +269,19 @@ test.sugar.isfinite <- function( ){ checkEquals( runit_isfinite( c(1, NA, Inf, -Inf, NaN) ) , - c(TRUE, FALSE, FALSE, FALSE, FALSE) + c(TRUE, FALSE, FALSE, FALSE, FALSE), + msg = "is_finite" ) } +test.sugar.isinfinite <- function( ){ + checkEquals( + runit_isinfinite( c(1, NA, Inf, -Inf, NaN) ) , + c(FALSE, FALSE, TRUE, TRUE, FALSE), + msg = "is_infinite" + ) +} + test.sugar.isna.isna <- function( ){ fx <- runit_isna_isna checkEquals( fx( c(1:5,NA,7:10) ) , rep(FALSE,10) ) From noreply at r-forge.r-project.org Fri May 31 11:25:27 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 31 May 2013 11:25:27 +0200 (CEST) Subject: [Rcpp-commits] r4327 - in pkg/Rcpp: . inst/include/Rcpp/sugar/functions inst/include/Rcpp/traits inst/unitTests inst/unitTests/cpp Message-ID: <20130531092527.3C234184BC0@r-forge.r-project.org> Author: romain Date: 2013-05-31 11:25:26 +0200 (Fri, 31 May 2013) New Revision: 4327 Added: pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_nan.h pkg/Rcpp/inst/include/Rcpp/traits/is_nan.h Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h pkg/Rcpp/inst/include/Rcpp/traits/traits.h pkg/Rcpp/inst/unitTests/cpp/sugar.cpp pkg/Rcpp/inst/unitTests/runit.sugar.R Log: is_nan Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-05-31 09:04:22 UTC (rev 4326) +++ pkg/Rcpp/ChangeLog 2013-05-31 09:25:26 UTC (rev 4327) @@ -1,9 +1,11 @@ 2013-05-31 Romain Francois - * unitTests/runit.sugar.R : new test for is_infinite - * unitTests/cpp/sugar.cpp : new test for is_infinite + * unitTests/runit.sugar.R : new test for is_infinite and is_nan + * unitTests/cpp/sugar.cpp : new test for is_infinite and is_nan * include/Rcpp/sugar/functions/is_infinite.h : new function is_infinite * include/Rcpp/traits/is_infinite.h : new function is_infinite + * include/Rcpp/sugar/functions/is_nan.h : new function is_nan + * include/Rcpp/traits/is_nan.h : new function is_nan 2013-05-30 Romain Francois Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h 2013-05-31 09:04:22 UTC (rev 4326) +++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h 2013-05-31 09:25:26 UTC (rev 4327) @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include Added: pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_nan.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_nan.h (rev 0) +++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/is_nan.h 2013-05-31 09:25:26 UTC (rev 4327) @@ -0,0 +1,55 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// is_nan.h: Rcpp R/C++ interface class library -- is_nan +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// +// 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__sugar__is_nan_h +#define Rcpp__sugar__is_nan_h + +namespace Rcpp{ +namespace sugar{ + +template +class IsNaN : public ::Rcpp::VectorBase< LGLSXP, false, IsNaN > { +public: + + IsNaN( const VEC_TYPE& obj_) : obj(obj_){} + + inline int operator[]( int i ) const { + return ::Rcpp::traits::is_nan( obj[i] ) ; + } + + inline int size() const { return obj.size() ; } + +private: + const VEC_TYPE& obj ; + +} ; + + +} // sugar + +template +inline sugar::IsNaN is_nan( const Rcpp::VectorBase& t){ + return sugar::IsNaN( t.get_ref() ) ; +} + +} // Rcpp +#endif + Added: pkg/Rcpp/inst/include/Rcpp/traits/is_nan.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/is_nan.h (rev 0) +++ pkg/Rcpp/inst/include/Rcpp/traits/is_nan.h 2013-05-31 09:25:26 UTC (rev 4327) @@ -0,0 +1,47 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// is_nan.h: Rcpp R/C++ interface class library -- is NaN +// +// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// +// 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_is_nan_h +#define Rcpp__traits_is_nan_h + +namespace Rcpp{ +namespace traits{ + + // default for most types + template + bool is_nan( typename storage_type::type){ + return false ; + } + + template <> + inline bool is_nan( double x ){ + return R_IsNaN(x) ; + } + + template <> + inline bool is_nan( Rcomplex x ){ + return R_IsNaN(x.r) || R_IsNaN(x.i) ; + } + +} +} + +#endif Modified: pkg/Rcpp/inst/include/Rcpp/traits/traits.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-05-31 09:04:22 UTC (rev 4326) +++ pkg/Rcpp/inst/include/Rcpp/traits/traits.h 2013-05-31 09:25:26 UTC (rev 4327) @@ -3,7 +3,7 @@ // // traits.h: Rcpp R/C++ interface class library -- traits to help wrap // -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include Modified: pkg/Rcpp/inst/unitTests/cpp/sugar.cpp =================================================================== --- pkg/Rcpp/inst/unitTests/cpp/sugar.cpp 2013-05-31 09:04:22 UTC (rev 4326) +++ pkg/Rcpp/inst/unitTests/cpp/sugar.cpp 2013-05-31 09:25:26 UTC (rev 4327) @@ -190,6 +190,11 @@ } // [[Rcpp::export]] +LogicalVector runit_isnan( NumericVector xx){ + return is_nan(xx) ; +} + +// [[Rcpp::export]] LogicalVector runit_isna_isna( NumericVector xx ){ return is_na( is_na( xx ) ) ; } Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.sugar.R 2013-05-31 09:04:22 UTC (rev 4326) +++ pkg/Rcpp/inst/unitTests/runit.sugar.R 2013-05-31 09:25:26 UTC (rev 4327) @@ -282,6 +282,15 @@ ) } + +test.sugar.isnan <- function( ){ + checkEquals( + runit_isnan( c(1, NA, Inf, -Inf, NaN) ) , + c(FALSE, FALSE, FALSE, FALSE, TRUE), + msg = "is_nan" + ) +} + test.sugar.isna.isna <- function( ){ fx <- runit_isna_isna checkEquals( fx( c(1:5,NA,7:10) ) , rep(FALSE,10) )