From noreply at r-forge.r-project.org Fri Mar 1 15:22:45 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 1 Mar 2013 15:22:45 +0100 (CET) Subject: [Rcpp-commits] r4275 - in pkg/RcppArmadillo: . inst inst/doc inst/include inst/include/armadillo_bits Message-ID: <20130301142245.C5ADF184BAA@r-forge.r-project.org> Author: edd Date: 2013-03-01 15:22:44 +0100 (Fri, 01 Mar 2013) New Revision: 4275 Added: pkg/RcppArmadillo/inst/CITATION pkg/RcppArmadillo/inst/doc/elsarticle-harv.bst pkg/RcppArmadillo/inst/doc/elsarticle.cls pkg/RcppArmadillo/inst/include/armadillo_bits/op_toeplitz_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_toeplitz_meat.hpp Modified: pkg/RcppArmadillo/.Rinstignore pkg/RcppArmadillo/ChangeLog pkg/RcppArmadillo/DESCRIPTION pkg/RcppArmadillo/inst/NEWS.Rd pkg/RcppArmadillo/inst/doc/Makefile pkg/RcppArmadillo/inst/doc/RcppArmadillo-intro.Rnw pkg/RcppArmadillo/inst/doc/RcppArmadillo.bib pkg/RcppArmadillo/inst/include/armadillo pkg/RcppArmadillo/inst/include/armadillo_bits/BaseCube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/BaseCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Base_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Base_meat.hpp 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/GenCube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/GenCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Gen_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Gen_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/GlueCube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/GlueCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Glue_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Glue_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/OpCube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/OpCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Op_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Op_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/Proxy.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/ProxyCube.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/SpBase_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpBase_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpCol_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpGlue_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpGlue_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpMat_bones.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/SpOp_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpOp_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpProxy.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpRow_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/SpValProxy_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/SpValProxy_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/access.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arma_config.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arma_ostream_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arma_static_check.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arrayops_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/arrayops_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/atlas_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/atlas_wrapper.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/auxlib_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/auxlib_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/blas_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/blas_wrapper.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/cmath_wrap.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/compiler_setup.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/cond_rel_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/cond_rel_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/config.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/constants.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/constants_compat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/debug.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/diagmat_proxy.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/diagview_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eGlueCube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eGlueCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eGlue_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eGlue_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eOpCube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eOpCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eOp_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eOp_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eglue_core_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eglue_core_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eop_aux.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/eop_core_bones.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_accu.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_as_scalar.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_chol.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_conv.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_conv_to.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_cor.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_cov.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_cross.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_cumsum.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_det.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_diagmat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_diagvec.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_dot.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_eig.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_elem.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_eps.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_eye.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_flip.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_hist.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_histc.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_inv.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_join.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_kron.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_log_det.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_lu.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_max.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_mean.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_median.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_min.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_misc.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_n_unique.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_norm.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_ones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_pinv.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_princomp.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_prod.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_qr.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_randn.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_randu.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_rank.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_repmat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_reshape.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_resize.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_shuffle.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_solve.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_sort.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_sort_index.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_speye.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_spones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_sprandn.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_sprandu.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_stddev.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_strans.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_sum.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_svd.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_syl_lyap.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_symmat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_toeplitz.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trace.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trans.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trig.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trimat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trunc_exp.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_trunc_log.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_unique.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_var.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/fn_zeros.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/format_wrap.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/forward_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/gemm.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/gemm_mixed.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/gemv.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_conv_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_conv_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_cor_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_cor_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_cov_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_cov_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_cross_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_cross_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_hist_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_hist_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_histc_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_histc_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_join_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_join_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_kron_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_kron_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_mixed_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_mixed_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_relational_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_relational_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_solve_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_solve_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/glue_toeplitz_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/glue_toeplitz_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/hdf5_misc.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/include_atlas.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/injector_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/injector_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/lapack_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/lapack_wrapper.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/memory.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtGlueCube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtGlueCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtGlue_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtGlue_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtOpCube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtOpCube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtOp_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtOp_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtSpOp_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/mtSpOp_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_chol_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_chol_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cor_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cor_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cov_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cov_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cumsum_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cumsum_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cx_scalar_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_cx_scalar_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_diagmat_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_diagmat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_diagvec_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_diagvec_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_dotext_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_dotext_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_find_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_find_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_flip_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_flip_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_hist_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_hist_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_htrans_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_htrans_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_inv_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_inv_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_max_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_max_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_mean_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_mean_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_median_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_median_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_min_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_min_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_misc_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_misc_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_pinv_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_pinv_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_princomp_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_princomp_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_prod_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_prod_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_relational_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_relational_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_repmat_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_repmat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_reshape_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_reshape_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_resize_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_shuffle_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_shuffle_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_sort_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_sort_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_stddev_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_stddev_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_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_sum_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_symmat_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_symmat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_trimat_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_trimat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_unique_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_unique_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_var_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/op_var_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_cube_div.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_cube_minus.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_cube_plus.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_cube_relational.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_cube_schur.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_cube_times.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_div.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_minus.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_ostream.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_plus.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_relational.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_schur.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/operator_times.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/podarray_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/podarray_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/promote_type.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/restrictors.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_vec_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/running_stat_vec_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/span.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spglue_minus_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spglue_minus_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spglue_plus_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spglue_plus_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spglue_times_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spglue_times_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_htrans_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_htrans_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_max_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_max_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_mean_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_mean_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_min_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_min_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_misc_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_misc_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_strans_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_strans_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_sum_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_sum_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_var_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/spop_var_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/strip.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_cube_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_cube_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_each_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_each_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_elem1_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_elem1_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_elem2_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_elem2_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_field_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_field_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/subview_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/traits.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/typedef.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/typedef_blas_int.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/typedef_fixed.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/undefine_conflicts.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/unwrap.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/unwrap_cube.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/unwrap_spmat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/upgrade_val.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/wall_clock_bones.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/wall_clock_meat.hpp Log: RcppArmadillo 0.3.800.0 with Armadillo 3.800.0 Updated vignette to CSDA paper Added CITATION Modified: pkg/RcppArmadillo/.Rinstignore =================================================================== --- pkg/RcppArmadillo/.Rinstignore 2013-02-28 20:14:48 UTC (rev 4274) +++ pkg/RcppArmadillo/.Rinstignore 2013-03-01 14:22:44 UTC (rev 4275) @@ -1 +1,3 @@ inst/doc/Makefile +inst/doc/elsarticle-harv.bst +inst/doc/elsarticle.cls Modified: pkg/RcppArmadillo/ChangeLog =================================================================== --- pkg/RcppArmadillo/ChangeLog 2013-02-28 20:14:48 UTC (rev 4274) +++ pkg/RcppArmadillo/ChangeLog 2013-03-01 14:22:44 UTC (rev 4275) @@ -1,3 +1,18 @@ +2013-03-01 Dirk Eddelbuettel + + * DESCRIPTION: Release 0.3.800.0 + * DESCRIPTION: Updated Description to reflect change of Armadillo + license to MPL 2.0 (which is fully compatible with GPL so no change + or net effect to RcppArmadillo) + + * inst/include/*: Upgraded to new release 3.800.0 of Armadillo + + * inst/doc/RcppArmadillo-intro.Rnw: Updated vignette to preprint of + the Computational Statistics & Data Analysis paper in press + * inst/doc/*: Added or updated relevant support files + + * inst/CITATION: Added with reference to CSDA paper + 2013-02-20 Dirk Eddelbuettel * DESCRIPTION: Release 0.3.6.3 Modified: pkg/RcppArmadillo/DESCRIPTION =================================================================== --- pkg/RcppArmadillo/DESCRIPTION 2013-02-28 20:14:48 UTC (rev 4274) +++ pkg/RcppArmadillo/DESCRIPTION 2013-03-01 14:22:44 UTC (rev 4275) @@ -1,7 +1,7 @@ Package: RcppArmadillo Type: Package Title: Rcpp integration for Armadillo templated linear algebra library -Version: 0.3.6.3 +Version: 0.3.800.0 Date: $Date$ Author: Romain Francois, Dirk Eddelbuettel and Doug Bates Maintainer: Dirk Eddelbuettel @@ -21,15 +21,15 @@ (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.3). Thus users do not need to + Armadillo library (currently version 3.800.0). Thus users do not need to install Armadillo itself in order to use RcppArmadillo. . This Armadillo integration provides a nice illustration of the capabilities of the Rcpp package for seamless R and C++ integration. . - Armadillo is licensed under the GNU LGPL version 3 or later, while - RcppArmadillo (the Rcpp bindings/bridge to Armadillo) is licensed under - the GNU GPL version 2 or later, as is the rest of Rcpp. + Armadillo is licensed under the MPL 2.0, while RcppArmadillo (the Rcpp + bindings/bridge to Armadillo) is licensed under the GNU GPL version 2 + or later, as is the rest of Rcpp. License: GPL (>= 2) LazyLoad: yes Depends: R (>= 2.14.0), Rcpp (>= 0.9.10) Added: pkg/RcppArmadillo/inst/CITATION =================================================================== --- pkg/RcppArmadillo/inst/CITATION (rev 0) +++ pkg/RcppArmadillo/inst/CITATION 2013-03-01 14:22:44 UTC (rev 4275) @@ -0,0 +1,19 @@ +citHeader("To cite RcppArmadillo in publications use:") + +citEntry(entry = "Article", + title = "RcppArmadillo: Accelerating R with high-performance C++ linear algebra", + author = personList(as.person("Dirk Eddelbuettel"), + as.person("Conrad Sanderson")), + journal = "Computational Statistics and Data Analysis", + year = "2013", + volume = "in press", + number = "", + pages = "", + url = "http://dx.doi.org/10.1016/j.csda.2013.02.005", + + textVersion = + paste("Dirk Eddelbuettel, Conrad Sanderson (2013).", + "RcppArmadillo: Accelerating R with high-performance C++ linear algebra.", + "Computational Statistics and Data Analysis, in press.", + "URL http://dx.doi.org/10.1016/j.csda.2013.02.005") +) Modified: pkg/RcppArmadillo/inst/NEWS.Rd =================================================================== --- pkg/RcppArmadillo/inst/NEWS.Rd 2013-02-28 20:14:48 UTC (rev 4274) +++ pkg/RcppArmadillo/inst/NEWS.Rd 2013-03-01 14:22:44 UTC (rev 4275) @@ -2,6 +2,25 @@ \title{News for Package 'RcppArmadillo'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{Changes in RcppArmadillo version 0.3.800.0 (2013-03-01)}{ + \itemize{ + \item Upgraded to Armadillo release Version 3.800.0 (Miami Beach) + \itemize{ + \item Armadillo is now licensed using the Mozilla Public License 2.0 + \item added \code{.imbue()} for filling a matrix/cube with values provided by a functor or lambda expression + \item added \code{.swap()} for swapping contents with another matrix + \item added \code{.transform()} for transforming a matrix/cube using a functor or lambda expression + \item added \code{round()} for rounding matrix elements towards nearest integer + \item faster \code{find()} + \item fixes for handling non-square matrices by \code{qr()} and \code{qr_econ()} + \item minor fixes for handling empty matrices + \item reduction of pedantic compiler warnings + } + \item Updated vignette to paper now in press at CSDA + \item Added CITATION file with reference to CSDA paper + } +} + \section{Changes in RcppArmadillo version 0.3.6.3 (2013-02-20)}{ \itemize{ \item Upgraded to Armadillo release Version 3.6.3 @@ -27,7 +46,7 @@ \section{Changes in RcppArmadillo version 0.3.6.1 (2012-12-17)}{ \itemize{ - \item Upgraded to Armadillo release Version 3.6.1 + \item Upgraded to Armadillo release Version 3.6.1 (Piazza del Duomo) \itemize{ \item faster \code{trace()} \item fix for handling sparse matrices by \code{dot()} Modified: pkg/RcppArmadillo/inst/doc/Makefile =================================================================== --- pkg/RcppArmadillo/inst/doc/Makefile 2013-02-28 20:14:48 UTC (rev 4274) +++ pkg/RcppArmadillo/inst/doc/Makefile 2013-03-01 14:22:44 UTC (rev 4275) @@ -24,8 +24,8 @@ RcppArmadillo-intro.pdf: ${RPROG} CMD Sweave RcppArmadillo-intro.Rnw - pdflatex RcppArmadillo-intro + pdflatex -shell-escape RcppArmadillo-intro bibtex RcppArmadillo-intro - pdflatex RcppArmadillo-intro - pdflatex RcppArmadillo-intro - rm RcppArmadillo-intro.aux RcppArmadillo-intro.log RcppArmadillo-intro.bbl RcppArmadillo-intro.blg RcppArmadillo-intro.tex \ No newline at end of file + pdflatex -shell-escape RcppArmadillo-intro + pdflatex -shell-escape RcppArmadillo-intro + rm RcppArmadillo-intro.aux RcppArmadillo-intro.log RcppArmadillo-intro.bbl RcppArmadillo-intro.blg RcppArmadillo-intro.tex RcppArmadillo-intro.spl Modified: pkg/RcppArmadillo/inst/doc/RcppArmadillo-intro.Rnw =================================================================== --- pkg/RcppArmadillo/inst/doc/RcppArmadillo-intro.Rnw 2013-02-28 20:14:48 UTC (rev 4274) +++ pkg/RcppArmadillo/inst/doc/RcppArmadillo-intro.Rnw 2013-03-01 14:22:44 UTC (rev 4275) @@ -1,54 +1,35 @@ -\documentclass[11pt]{article} +\documentclass[preprint,authoryear,times]{elsarticle} %\VignetteIndexEntry{RcppArmadillo-introduction} %\VignetteKeywords{R, C++, Armadillo, linear algebra, kalman filter} %\VignettePackage{RcppArmadillo} -\usepackage[USletter]{vmargin} -%\setmargrb{0.75in}{0.75in}{0.75in}{0.75in} -\setmargrb{1in}{1in}{1in}{1in} +\usepackage{url} % break URLs +\usepackage{booktabs} % fancier tables +\usepackage{color} % color use +\usepackage{minted} +%\usemintedstyle{bw} % enfore black/white for publication +\newminted{r}{linenos,firstnumber=1,stepnumber=2,frame=lines,fontsize=\small} +\newminted{cpp}{linenos,firstnumber=1,stepnumber=2,frame=lines,fontsize=\small} +\newminted{matlab}{linenos,firstnumber=1,stepnumber=2,frame=lines,fontsize=\small} -\usepackage{ae} % 'almost european' computer modern font +\usepackage[colorlinks]{hyperref}% for \href +\definecolor{link}{rgb}{0,0,0.3} % next few lines courtesy of RJournal.sty +\hypersetup{ + colorlinks,% + citecolor=link,% + filecolor=link,% + linkcolor=link,% + urlcolor=link +} -\usepackage[authoryear,round,longnamesfirst]{natbib} -\usepackage{url} % break URLs -\usepackage{booktabs} % fancier tables -\usepackage{color} % color use -\usepackage{listings} % code examples -\definecolor{darkgray}{rgb}{0.975,0.975,0.975} -\lstset{backgroundcolor=\color{darkgray}} -\lstset{numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt} -\lstset{keywordstyle=\color{black}\bfseries\tt} -\lstset{ % - %language=Octave, % the language of the code - %basicstyle=\footnotesize, % the size of the fonts that are used for the code - basicstyle=\small, % the size of the fonts that are used for the code - numbers=left, % where to put the line-numbers - %numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers - stepnumber=2, % the step between two line-numbers. If it's 1, each line - % will be numbered - numbersep=5pt, % how far the line-numbers are from the code - %backgroundcolor=\color{white}, % choose the background color. You must add \usepackage{color} - showspaces=false, % show spaces adding particular underscores - showstringspaces=false, % underline spaces within strings - showtabs=false, % show tabs within strings adding particular underscores - %frame=single, % adds a frame around the code - tabsize=2, % sets default tabsize to 2 spaces - captionpos=b, % sets the caption-position to bottom - breaklines=true, % sets automatic line breaking - breakatwhitespace=false % sets if automatic breaks should only happen at whitespace - %title=\lstname, % show the filename of files included with \lstinputlisting; - % also try caption instead of title - %escapeinside={\%*}{*)}, % if you want to add a comment within your code - %morekeywords={*,...} % if you want to add more keywords to the set -} %%% from jss.cls defs \makeatletter \newcommand\code{\bgroup\@makeother\_\@makeother\~\@makeother\$\@codex} \def\@codex#1{{\normalfont\ttfamily\hyphenchar\font=-1 #1}\egroup} \makeatother -\newcommand{\proglang}[1]{\textsf{#1}} -%\newcommand{\proglang}[1]{#1} % also neutering the proglang macro +%\newcommand{\proglang}[1]{\textsf{#1}} +\newcommand{\proglang}[1]{#1} % also neutering the proglang macro \newcommand{\R}{\proglang{R}\ } % NB forces a space so not good before % fullstop etc. \newcommand{\Rns}{\proglang{R}} % without the space \newcommand{\Cpp}{\proglang{C++}\ } @@ -57,6 +38,9 @@ %\newcommand{\pkg}[1]{{\it #1}} \newcommand{\pkg}[1]{{#1}} % null op for now +\journal{Computational Statistics and Data Analysis} + + <>= prettyVersion <- packageDescription("RcppArmadillo")$Version prettyDate <- format(Sys.Date(), "%B %e, %Y") @@ -64,6 +48,833 @@ \begin{document} +\begin{frontmatter} + + \title{RcppArmadillo: Accelerating R \\with High-Performance C++ Linear Algebra\footnote{ + This vignette corresponds to a + \href{http://dx.doi.org/10.1016/j.csda.2013.02.005}{paper published} in + \href{http://www.journals.elsevier.com/computational-statistics-and-data-analysis/}{Computational Statistics and Data Analysis}. + Currently still identical to the paper, this vignette version may over time receive minor updates. + For citations, please use \citet{Eddelbuettel+Sanderson:2013:RcppArmadillo} as provided by \code{citation("RcppArmadillo")}. + % + This version corresponds to \pkg{RcppArmadillo} version \Sexpr{prettyVersion} and was + typeset on \Sexpr{prettyDate}. + } + } + + \author[de]{Dirk Eddelbuettel}%\corref{cor}} + %\ead[de]{edd at debian.org} + % \ead[de,url]{http://dirk.eddelbuettel.com} + %\cortext[cor]{Corresponding author. Email: \url{edd at debian.org}.}% Postal address: 711 Monroe Avenue, + %River Forest, IL 60305, USA. } %he \pkg{RcppArmadillo} package is available + %with the electronic version of this article, as well as via every CRAN mirror.} + \address[de]{Debian Project, \url{http://www.debian.org}} + + \author[cs1,cs2]{Conrad Sanderson} + %\ead[cs1]{nowhere} % CS i'd prefer to leave out my email address + %\ead[cs1,url]{http://www.nicta.com.au/people/sandersonc} + %\ead[cs2,url]{http://itee.uq.edu.au/~conrad/} + \address[cs1]{NICTA, PO Box 6020, St Lucia, QLD 4067, Australia} + \address[cs2]{Queensland University of Technology (QUT), Brisbane, QLD 4000, Australia} + + \begin{abstract} + + \noindent + The \proglang{R} statistical environment and language has demonstrated + particular strengths for interactive development of statistical + algorithms, as well as data modelling and visualisation. Its current + implementation has an interpreter at its core which may result in a + performance penalty in comparison to directly executing user algorithms + in the native machine code of the host CPU. In contrast, the + \proglang{C++} language has no built-in visualisation capabilities, + handling of linear algebra or even basic statistical algorithms; however, + user programs are converted to high-performance machine code, ahead of + execution. + % + A new method avoids possible speed penalties in + \proglang{R} by using the \pkg{Rcpp} extension package in conjunction + with the \pkg{Armadillo} \Cpp matrix library. In addition to the + inherent performance advantages of compiled code, \pkg{Armadillo} + provides an easy-to-use template-based meta-programming framework, + allowing the automatic pooling of several linear algebra operations into + one, which in turn can lead to further speedups. + With the aid of \pkg{Rcpp} and \pkg{Armadillo}, conversion of linear + algebra centered algorithms from \proglang{R} to \proglang{C++} becomes + straightforward. The algorithms retains the overall structure as + well as readability, all while maintaining a bidirectional link with the + host R environment. Empirical timing comparisons of \proglang{R} and + \proglang{C++} implementations of a Kalman filtering algorithm indicate a + speedup of several orders of magnitude. + + \end{abstract} + + \begin{keyword} + Software \sep R \sep C++ \sep linear algebra + \end{keyword} + +\end{frontmatter} + + +\section{Overview} + +Linear algebra is a cornerstone of statistical computing and statistical +software systems. Various matrix decompositions, linear program solvers, and +eigenvalue / eigenvector computations are key to many estimation and analysis +routines. As generally useful procedures, these are often abstracted and +regrouped in specific libraries for linear algebra which statistical +programmers have provided for various programming languages and environments. + +One such environment and statistical programming language is R +\citep{R:Main}. It has become a tool of choice for data analysis and applied +statistics \citep{Morandat_2012}. While R has particular strengths +at fast prototyping and easy visualisation of data, its +implementation has an interpreter at its core. In comparison to running user +algorithms in the native machine code of the host CPU, the use of an +interpreter often results in a performance penalty for non-trivial algorithms +that perform elaborate data manipulation \citep{Morandat_2012}. With user +algorithms becoming more complex and increasing in functionality, as well as +with data sets which continue to increase in size, the issue of execution +speed becomes more important. + +The \Cpp language offers a complementary set of attributes: while it has no +built-in visualisation capabilities nor handling of linear algebra or +statistical methods, user programs are converted to high-performance machine +code ahead of execution. It is also inherently flexible. One key feature is +\textit{operator overloading} which allows the programmer to define custom +behaviour for mathematical operators such as $+$, $-$, $*$ +\citep{Meyers:2005:EffectiveC++}. \Cpp also provides language constructs +known as {\it templates}, originally intended to easily allow the reuse of +algorithms for various object types, and later extended to a programming +construct in its own right called \textit{template meta-programming} +\citep{Vandevoorde_2002,Abrahams_2004} + +Operator overloading allows mathematical operations to be extended to +user-defined objects, such as matrices. This in turn allows linear algebra +expressions to be written in a more natural manner (eg.~\mbox{$X = 0.1*A + + 0.2*B$}), rather than the far less readable traditional function call +syntax, eg.~\mbox{$X = \mbox{\it add}(\mbox{\it multiply}(0.1,A), \mbox{\it + multiply}(0.2,B))$}. + +Template meta-programming is the process of inducing the \Cpp compiler to +execute, at compile time, Turing-complete programs written in a somewhat +opaque subset of the \Cpp language~\citep{Vandevoorde_2002,Abrahams_2004}. +These meta-programs in effect generate further \Cpp code (often specialised +for particular object types), which is finally converted into machine code. + +An early and influential example of exploiting both meta-programming and +overloading of mathematical operators was provided by the Blitz++ library +\citep{Veldhuizen:1998:Blitz}, targeted for efficient processing of arrays. +Blitz++ employed elaborate meta-programming to avoid the generation of +temporary array objects during the evaluation of mathematical expressions. +However, the library's capabilities and usage were held back at the time by +the limited availability of compilers correctly implementing all the +necessary features and nuances of the \Cpp language. + +We present a new method of avoiding the speed penalty in R by +using the Rcpp extension package \citep{Eddelbuettel+Francois:2011:Rcpp, + CRAN:Rcpp,Eddelbuettel:2013:Rcpp} in conjunction with the \pkg{Armadillo} \Cpp linear algebra +library \citep{Sanderson:2010:Armadillo}. Similar to Blitz++, +\pkg{Armadillo} uses operator overloading and various template +meta-programming techniques to attain efficiency. However, it has been +written to target modern \Cpp compilers as well as providing a much larger +set of linear algebra operations than Blitz++. R programs augmented to use +\pkg{Armadillo} retain the overall structure as well as readability, all +while retaining a bidirectional link with the host R environment. + +Section~\ref{sec:arma} provides an overview of \pkg{Armadillo}, followed by +its integration with the Rcpp extension package. Section~\ref{sec:kalman} +shows an example of an R program and its conversion to \Cpp via Rcpp and +\pkg{Armadillo}. Section~\ref{sec:speed} discusses an empirical timing +comparison between the R and \Cpp versions before +Section~\ref{sec:conclusion} concludes. + + +\section{Armadillo} +\label{sec:arma} + +The \pkg{Armadillo} \Cpp library provides vector, matrix and cube types +(supporting integer, floating point and complex numbers) as well as a subset +of trigonometric and statistics functions~\citep{Sanderson:2010:Armadillo}. +In addition to elementary operations such as addition and matrix +multiplication, various matrix factorisations and submatrix manipulation +operations are provided. The corresponding application programming interface +(syntax) enables the programmer to write code which is both concise and +easy-to-read to those familiar with scripting languages such as +\proglang{Matlab} and \proglang{R}. Table~\ref{tab:arma} lists a few common +\pkg{Armadillo} functions. + +Matrix multiplication and factorisations are accomplished through integration +with the underlying operations stemming from standard numerical libraries +such as BLAS and LAPACK~\citep{Demmel_1997}. Similar to how environments +such as R are implemented, these underlying libraries can be replaced in a +transparent manner with variants that are optimised to the specific hardware +platform and/or multi-threaded to automatically take advantage of the +now-common multi-core platforms~\citep{Kurzak_2010}. + +\begin{table}[!b] + \centering + \footnotesize + \begin{tabular}{ll} + \toprule + \textbf{Armadillo function} \phantom{XXXXXXX} & \textbf{Description} \\ + \midrule + \code{X(1,2) = 3} & Assign value 3 to element at location (1,2) of matrix $X$ \\ % DE shortened to fit on \textwidth + \code{X = A + B} & Add matrices $A$ and $B$ \\ + \code{X( span(1,2), span(3,4) )} & Provide read/write access to submatrix of $X$ \\ + \code{zeros(rows [, cols [, slices]))} & Generate vector (or matrix or cube) of zeros\\ + \code{ones(rows [, cols [, slices]))} & Generate vector (or matrix or cube) of ones\\ + \code{eye(rows, cols)} & Matrix diagonal set to 1, off-diagonal elements set to 0 \\ + %\code{linspace(start, end, N=100)} & $N$ element vector with elements from start to end \\ + \code{repmat(X, row_copies, col_copies)} & Replicate matrix $X$ in block-like manner \\ + \code{det(X)} & Returns the determinant of matrix $X$\\ + %\code{dot(A, B)} & Dot-product of confirming vectors $A$ and $B$ \\ + \code{norm(X, p)} & Compute the $p$-norm of matrix or vector $X$\\ + \code{rank(X)} & Compute the rank of matrix $X$ \\ + %\code{trace(X)} & Compute the trace of matrix $X$ \\ + %\code{diagvec(X, k=0)} & Extracts the $k$-th diagnonal from matrix $X$\\ + \code{min(X, dim=0)};~ \code{max(X, dim=0)} & Extremum value of each column~of $X$~(row if \code{dim=1}) \\ + \code{trans(X)} ~or~ \code{X.t()} & Return transpose of $X$ \\ + \code{R = chol(X)} & Cholesky decomposition of $X$ such that $R^{T} R = X$ \\ + \code{inv(X)} ~or~ \code{X.i()} & Returns the inverse of square matrix $X$ \\ + \code{pinv(X)} & Returns the pseudo-inverse of matrix $X$ \\ + \code{lu(L, U, P, X)} & LU decomp.~with partial pivoting; also \code{lu(L, U, X)} \\ + %\code{lu(L, U, P, X)} & LU decomposition with partial pivoting \\ + \code{qr(Q, R, X)} & QR decomp.~into orthogonal $Q$ and right-triangular $R$\\ + \code{X = solve(A, B)} & Solve system $AX = B$ for $X$ \\ + \code{s = svd(X); svd(U, s, V, X)} & Singular-value decomposition of $X$ \\ + \bottomrule + \end{tabular} +\caption{Selected \pkg{Armadillo} functions with brief descriptions; see + \texttt{http://arma.sf.net/docs.html} for more complete + documentation. Several optional additional arguments have been omitted + here for brevity.\label{tab:arma}} +\end{table} + +\pkg{Armadillo} uses a delayed evaluation approach to combine several +operations into one and reduce (or eliminate) the need for temporary objects. +In contrast to brute-force evaluations, delayed evaluation can provide +considerable performance improvements as well as reduced memory usage. +The delayed evaluation machinery is accomplished through template +meta-programming~\citep{Vandevoorde_2002,Abrahams_2004}, where the \Cpp +compiler is induced to reason about mathematical expressions at {\it compile + time}. Where possible, the \Cpp compiler can generate machine code that is +tailored for each expression. + +As an example of the possible efficiency gains, let us consider the +expression \mbox{$X = A - B + C$}, where $A$, $B$ and $C$ are matrices. A +brute-force implementation would evaluate $A-B$ first and store the result in +a temporary matrix $T$. The next operation would be \mbox{$T + C$}, with the +result finally stored in $X$. The creation of the temporary matrix, and +using two separate loops for the subtraction and addition of matrix elements +is suboptimal from an efficiency point of view. + +Through the overloading of mathematical operators, \pkg{Armadillo} avoids the +generation of the temporary matrix by first converting the expression into a +set of lightweight \code{Glue} objects, which only store references to the +matrices and \pkg{Armadillo}'s representations of mathematical expressions +(eg.~other \code{Glue} objects). To indicate that an operation comprised of +subtraction and addition is required, the exact type of the \code{Glue} +objects is automatically inferred from the given expression through template +meta-programming. More specifically, given the expression \mbox{$X = A - B + + C$}, \pkg{Armadillo} automatically induces the compiler to generate an +instance of the lightweight \code{Glue} storage object with the following +\Cpp {\it type}: + +\centerline{~} +\centerline{\code{Glue< Glue, Mat, glue\_plus>}} +\centerline{~} + +\noindent +where \code{Glue<...>} indicates that \code{Glue} is a C++ template class, +with the items between `\code{<}' and `\code{>}' specifying template +parameters; the outer \code{Glue<..., Mat, glue\_plus>} is the \code{Glue} +object indicating an addition operation, storing a reference to a matrix as +well as a reference to another \code{Glue} object; the inner \code{Glue} stores references to two matrices and indicates a +subtraction operation. In both the inner and outer \code{Glue}, the type +\code{Mat} specifies that a reference to a matrix object is to be held. + +The expression evaluator in \pkg{Armadillo} is then automatically invoked +through the ``\code{=}'' operation, which interprets (at compile time) the +template parameters of the compound \code{Glue} object and generates \Cpp +code equivalent to: + +\centerline{~} +\centerline{\code{for(int i=0; i library(inline) +R> +R> g <- cxxfunction(signature(vs="numeric"), ++ plugin="RcppArmadillo", body=' ++ arma::vec v = Rcpp::as(vs); ++ arma::mat op = v * v.t(); ++ double ip = arma::as_scalar(v.t() * v); ++ return Rcpp::List::create(Rcpp::Named("outer")=op, ++ Rcpp::Named("inner")=ip); ++') +R> g(7:11) +$outer + [,1] [,2] [,3] [,4] [,5] +[1,] 49 56 63 70 77 +[2,] 56 64 72 80 88 +[3,] 63 72 81 90 99 +[4,] 70 80 90 100 110 +[5,] 77 88 99 110 121 + +$inner +[1] 415 +\end{rcode} +\end{listing} + +Consider the simple example in Listing~\ref{code:RcppArmaEx}. Given a +vector, the \code{g()} function returns both the outer and inner products. +We load the inline package \citep{CRAN:inline}, which provides +\code{cxxfunction()} that we use to compile, link and load the \Cpp code +which is passed as the \code{body} argument. We declare the function +signature to contain a single argument named `\code{vs}'. On line five, this +argument is used to instantiate an \pkg{Armadillo} column vector object named +`\code{v}' (using the templated conversion function \code{as()} from Rcpp). +In lines six and seven, the outer and inner product of the column vector +are calculated by appropriately multiplying the vector with its transpose. +This shows how the \code{*} operator for multiplication has been overloaded +to provide the appropriate operation for the types implemented by +\pkg{Armadillo}. The inner product creates a scalar variable, and in +contrast to \R where each object is a vector type (even if of length one), we +have to explicitly convert using \code{as_scalar()} to assign the value to a +variable of type \code{double}. + + +Finally, the last line creates an \R named list type containing both results. +As a result of calling \code{cxxfunction()}, a new function is created. It +contains a reference to the native code, compiled on the fly based on the +\Cpp code provided to \code{cxxfunction()} and makes it available directly +from \R under a user-assigned function name, here \code{g()}. The listing +also shows how the \code{Rcpp} and \code{arma} namespaces are used to +disambiguate symbols from the two libraries; the \code{::} operator is +already familiar to R programmers who use the NAMESPACE directive in \R in a +similar fashion. + +The listing also demonstrates how the new function \code{g()} can be called +with a suitable argument. Here we create a vector of five elements, +containing values ranging from 7 to 11. The function's output, here the list +containing both outer and inner product, is then displayed as it is not +assigned to a variable. + +This simple example illustrates how \R objects can be transferred directly +into corresponding \pkg{Armadillo} objects using the interface code provided +by \pkg{Rcpp}. It also shows how deployment of \pkg{RcppArmadillo} is +straightforward, even for interactive work where functions can be compiled on +the fly. Similarly, usage in packages is also uncomplicated and follows the +documentation provided with \pkg{Rcpp}~\citep{CRAN:Rcpp,Eddelbuettel:2013:Rcpp}. + + +\section{Kalman Filtering Example} +\label{sec:kalman} + +The Kalman filter is ubiquitous in many engineering disciplines as well as in +statistics and econometrics~\citep{Tusell:2010:Kalman}. A recent example of an +application is volatility extraction in a diffusion option pricing model~\citep{Li_CSDA_2013}. +Even in its simplest linear form, the Kalman filter can provide simple estimates +by recursively applying linear updates which are robust to noise and can cope +with missing data. Moreover, the estimation process is lightweight and fast, +and consumes only minimal amounts of memory as few state variables are required. +% +We discuss a standard example below. The (two-dimensional) position of an +object is estimated based on past values. A $6 \times 1$ state vector +includes $X$ and $Y$ coordinates determining the position, two variables for +speed (or velocity) $V_X$ and $V_Y$ relative to the two coordinates, as well +as two acceleration variables $A_X$ and $A_Y$. + +We have the positions being updated as a function of the velocity + +\begin{displaymath} + X = X_0 + V_X dt + \mbox{\phantom{XX} and \phantom{XX}} + Y = Y_0 + V_Y dt, +\end{displaymath} + +\noindent +and the velocity being updated as a function of the (unobserved) acceleration: + +\begin{displaymath} + V_x = V_{X,0} + A_X dt + \mbox{\phantom{XX} and \phantom{XX}} + V_y = V_{Y,0} + A_Y dt. +\end{displaymath} + +% \begin{eqnarray*} +% X & = & X_0 + V_x dt \\ +% Y & = & Y_0 + V_y dt \\ +% V_x & = & V_{x,0} + A_x dt \\ +% V_y & = & V_{y,0} + A_y dt \\ +% \end{eqnarray*} + +With covariance matrices $Q$ and $R$ for (Gaussian) error terms, the standard +Kalman filter estimation involves a linear prediction step resulting in a new +predicted state vector, and a new covariance estimate. This leads to a +residuals vector and a covariance matrix for residuals which are used to +determine the (optimal) Kalman gain, which is then used to update the state +estimate and covariance matrix. + +All of these steps involve only matrix multiplication and inversions, making +the algorithm very suitable for an implementation in any language which +can use matrix expressions. An example for \proglang{Matlab} is provided on +the Mathworks website\footnote{See + \url{http://www.mathworks.com/products/matlab-coder/demos.html?file=/products/demos/shipping/coder/coderdemo_kalman_filter.html}.} +and shown in Listing~\ref{code:matlabkalman}. + +\begin{listing}[t!] +\caption{Basic Kalman Filter in \proglang{Matlab}.\label{code:matlabkalman}} +\begin{matlabcode} +% Copyright 2010 The MathWorks, Inc. +function y = kalmanfilter(z) + dt=1; + % Initialize state transition matrix + A=[ 1 0 dt 0 0 0; 0 1 0 dt 0 0;... % [x ], [y ] [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/rcpp -r 4275 From noreply at r-forge.r-project.org Fri Mar 1 21:29:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 1 Mar 2013 21:29:25 +0100 (CET) Subject: [Rcpp-commits] r4276 - in pkg/Rcpp: . inst inst/include/Rcpp/platform Message-ID: <20130301202925.CD93E184E90@r-forge.r-project.org> Author: edd Date: 2013-03-01 21:29:25 +0100 (Fri, 01 Mar 2013) New Revision: 4276 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/DESCRIPTION pkg/Rcpp/inst/THANKS pkg/Rcpp/inst/include/Rcpp/platform/compiler.h Log: improved compile-time test for long long (using __LONG_LONG_MAX__ from limits.h) Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-01 14:22:44 UTC (rev 4275) +++ pkg/Rcpp/ChangeLog 2013-03-01 20:29:25 UTC (rev 4276) @@ -15,6 +15,12 @@ * src/attributes.cpp: handle Rcpp module definitions in sourceCpp * man/sourceCpp.Rd: documentation updates +2013-02-20 Dirk Eddelbuettel + + * inst/include/Rcpp/platform/compiler.h: As deteced by Gong-Yi Liao, + we need to test for __LONG_LONG_MAX__ (defined in limits.h) and not + LONG_LONG_MAX (defined climits which we do not include) + 2013-02-19 Romain Francois * src/api.cpp : more debugging Modified: pkg/Rcpp/DESCRIPTION =================================================================== --- pkg/Rcpp/DESCRIPTION 2013-03-01 14:22:44 UTC (rev 4275) +++ pkg/Rcpp/DESCRIPTION 2013-03-01 20:29:25 UTC (rev 4276) @@ -1,6 +1,6 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.10.2.4 +Version: 0.10.2.5 Date: $Date$ Author: Dirk Eddelbuettel and Romain Francois, with contributions by Douglas Bates, John Chambers and JJ Allaire Modified: pkg/Rcpp/inst/THANKS =================================================================== --- pkg/Rcpp/inst/THANKS 2013-03-01 14:22:44 UTC (rev 4275) +++ pkg/Rcpp/inst/THANKS 2013-03-01 20:29:25 UTC (rev 4276) @@ -10,6 +10,7 @@ Rainer Hurling for help debugging builds issues on FreeBSD Gregor Kastner for noticing a bug in IntegerVector initialization Glenn Lawyer for sending in documentation patches +Gong-Yi Liao for a corrected compile-time test for long long variables Uwe Ligges for help with Windows (32 and 64 bit) build issues Tama Ma for a patch that extends Module constructors Karl Millar for a patch helping with a non-g++ compiler Modified: pkg/Rcpp/inst/include/Rcpp/platform/compiler.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/platform/compiler.h 2013-03-01 14:22:44 UTC (rev 4275) +++ pkg/Rcpp/inst/include/Rcpp/platform/compiler.h 2013-03-01 20:29:25 UTC (rev 4276) @@ -183,7 +183,7 @@ #ifdef __GNUC__ #ifdef __GXX_EXPERIMENTAL_CXX0X__ -#ifdef LONG_LONG_MAX +#ifdef __LONG_LONG_MAX__ __extension__ typedef long long int rcpp_long_long_type; __extension__ typedef unsigned long long int rcpp_ulong_long_type; #define RCPP_HAS_LONG_LONG_TYPES From noreply at r-forge.r-project.org Fri Mar 8 17:15:20 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Mar 2013 17:15:20 +0100 (CET) Subject: [Rcpp-commits] r4277 - in pkg/Rcpp: . inst/include/Rcpp/platform Message-ID: <20130308161521.1341F184E8F@r-forge.r-project.org> Author: edd Date: 2013-03-08 17:15:20 +0100 (Fri, 08 Mar 2013) New Revision: 4277 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/platform/compiler.h Log: improved g++ version check by Yan Zhou Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-01 20:29:25 UTC (rev 4276) +++ pkg/Rcpp/ChangeLog 2013-03-08 16:15:20 UTC (rev 4277) @@ -1,3 +1,8 @@ +2013-03-08 Dirk Eddelbuettel + + * inst/include/Rcpp/platform/compiler.h: Improved g++ version + detection with thanks to Yan Zhou + 2013-02-28 JJ Allaire * src/attributes.cpp: standalone roxygen chunks (e.g. to document Modified: pkg/Rcpp/inst/include/Rcpp/platform/compiler.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/platform/compiler.h 2013-03-01 20:29:25 UTC (rev 4276) +++ pkg/Rcpp/inst/include/Rcpp/platform/compiler.h 2013-03-08 16:15:20 UTC (rev 4277) @@ -90,7 +90,7 @@ #include #if defined(__INTEL_COMPILER) || (defined(__GNUC__) && !defined(__clang__)) #if defined(__GLIBCXX__) && defined(__GXX_EXPERIMENTAL_CXX0X__) - #if __GLIBCXX__ >= 20090421 // GCC 4.4.0 + #if GCC_VERSION >= 40400 #define HAS_CXX0X_UNORDERED_MAP #define HAS_CXX0X_UNORDERED_SET #define HAS_CXX0X_INITIALIZER_LIST @@ -113,7 +113,7 @@ // Check TR1 Headers #if defined(__INTEL_COMPILER) || (defined(__GNUC__) && !defined(__clang__)) #if defined(__GLIBCXX__) - #if __GLIBCXX__ >= 20070719 // GCC 4.2.1 + #if GCC_VERSION >= 40400 #define HAS_TR1_UNORDERED_MAP #define HAS_TR1_UNORDERED_SET #endif From noreply at r-forge.r-project.org Tue Mar 12 03:07:44 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Mar 2013 03:07:44 +0100 (CET) Subject: [Rcpp-commits] r4278 - in pkg/RcppArmadillo: . inst inst/include inst/include/RcppArmadilloExtensions inst/unitTests inst/unitTests/cpp tests Message-ID: <20130312020744.72224184882@r-forge.r-project.org> Author: edd Date: 2013-03-12 03:07:42 +0100 (Tue, 12 Mar 2013) New Revision: 4278 Added: pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/ pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/sample.h pkg/RcppArmadillo/inst/unitTests/cpp/ pkg/RcppArmadillo/inst/unitTests/cpp/sample.cpp pkg/RcppArmadillo/inst/unitTests/runit.sample.R Modified: pkg/RcppArmadillo/ChangeLog pkg/RcppArmadillo/DESCRIPTION pkg/RcppArmadillo/inst/NEWS.Rd pkg/RcppArmadillo/tests/doRUnit.R Log: committinh Christian Gunning's nice sample() contribution, including unit tests (which we reworked slightly) Modified: pkg/RcppArmadillo/ChangeLog =================================================================== --- pkg/RcppArmadillo/ChangeLog 2013-03-08 16:15:20 UTC (rev 4277) +++ pkg/RcppArmadillo/ChangeLog 2013-03-12 02:07:42 UTC (rev 4278) @@ -1,3 +1,15 @@ +2013-03-11 Dirk Eddelbuettel + + * inst/unitTests/cpp/sample.cpp: Regrouping C++ tests for sample() + * inst/unitTests/runit.sample.R: Rewritten for sole external cpp file + +2013-03-10 Dirk Eddelbuettel + + * inst/include/add-ons/sample.h: Added sample() function contributed + by Christian Gunning + * inst/unitTests/runit.sample.R: Added unit test for sample() + contributed by Christian Gunning + 2013-03-01 Dirk Eddelbuettel * DESCRIPTION: Release 0.3.800.0 Modified: pkg/RcppArmadillo/DESCRIPTION =================================================================== --- pkg/RcppArmadillo/DESCRIPTION 2013-03-08 16:15:20 UTC (rev 4277) +++ pkg/RcppArmadillo/DESCRIPTION 2013-03-12 02:07:42 UTC (rev 4278) @@ -1,7 +1,7 @@ Package: RcppArmadillo Type: Package Title: Rcpp integration for Armadillo templated linear algebra library -Version: 0.3.800.0 +Version: 0.3.800.0.1 Date: $Date$ Author: Romain Francois, Dirk Eddelbuettel and Doug Bates Maintainer: Dirk Eddelbuettel Modified: pkg/RcppArmadillo/inst/NEWS.Rd =================================================================== --- pkg/RcppArmadillo/inst/NEWS.Rd 2013-03-08 16:15:20 UTC (rev 4277) +++ pkg/RcppArmadillo/inst/NEWS.Rd 2013-03-12 02:07:42 UTC (rev 4278) @@ -2,6 +2,13 @@ \title{News for Package 'RcppArmadillo'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{Changes in RcppArmadillo version 0.3.800.0.1 (2013-03-31)}{ + \itemize{ + \item UNRELEASED -- version and date subject to change + \item Added new sample() function contributed by Christian Gunning + } +} + \section{Changes in RcppArmadillo version 0.3.800.0 (2013-03-01)}{ \itemize{ \item Upgraded to Armadillo release Version 3.800.0 (Miami Beach) Added: pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/sample.h =================================================================== --- pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/sample.h (rev 0) +++ pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/sample.h 2013-03-12 02:07:42 UTC (rev 4278) @@ -0,0 +1,168 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- +// +// sample.cpp: Rcpp/Armadillo equivalent to R's sample(). +// This is to be used in C++ functions, and should *not* be called from R. +// It should yield identical results to R in most cases +// (note that Walker's alias method is not implemented). +// +// Copyright (C) 2012 -2013 Christian Gunning +// +// This file is part of RcppArmadillo. +// +// RcppArmadillo 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. +// +// RcppArmadillo 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 RcppArmadillo. If not, see . + +#include + + +namespace Rcpp{ + + namespace RcppArmadillo{ + + //Declarations + void SampleReplace( IntegerVector &index, int nOrig, int size); + void SampleNoReplace( IntegerVector &index, int nOrig, int size); + void ProbSampleReplace(IntegerVector &index, int nOrig, int size, arma::vec &prob); + void ProbSampleNoReplace(IntegerVector &index, int nOrig, int size, arma::vec &prob); + void FixProb(NumericVector &prob, int size, bool replace); + + template + T sample(const T &x, const int size, const bool replace, NumericVector prob_ = NumericVector(0) ) { + // Templated sample -- should work on any Rcpp Vector + int ii, jj; + int nOrig = x.size(); + int probsize = prob_.size(); + // Create return object + T ret(size); + if ( size > nOrig && !replace) throw std::range_error( "Tried to sample more elements than in x without replacement" ) ; + // Store the sample ids here, modify in-place + IntegerVector index(size); + if (probsize == 0) { // No probabilities given + if (replace) { + SampleReplace(index, nOrig, size); + } else { + SampleNoReplace(index, nOrig, size); + } + } else { + if (probsize != nOrig) throw std::range_error( "Number of probabilities must equal input vector length" ) ; + // normalize, error-check probability vector + // fixprob will be modified in-place + NumericVector fixprob = clone(prob_); + FixProb(fixprob, size, replace); + // + // Copy the given probabilities into an arma vector + arma::vec prob(fixprob.begin(), fixprob.size()); + if (replace) { + // check for walker alias conditions here?? + ProbSampleReplace(index, nOrig, size, prob); + } else { + ProbSampleNoReplace(index, nOrig, size, prob); + } + } + // copy the results into the return vector + for (ii=0; ii 0.0) { + nPos++; + sum += prob[ii]; + } + } + if (nPos == 0 || (!replace && size > nPos)) { + throw std::range_error("Not enough positive probabilities"); + } + prob = prob / sum; //sugar + } + + // Unequal probability sampling with replacement + void ProbSampleReplace(IntegerVector &index, int nOrig, int size, arma::vec &prob){ + double rU; + int ii, jj; + int nOrig_1 = nOrig - 1; + arma::uvec perm = arma::sort_index(prob, 1); //descending sort of index + prob = arma::sort(prob, 1); // descending sort of prob + // cumulative probabilities + prob = arma::cumsum(prob); + // compute the sample + for (ii = 0; ii < size; ii++) { + rU = unif_rand(); + for (jj = 0; jj < nOrig_1; jj++) { + if (rU <= prob[jj]) + break; + } + index[ii] = perm[jj]; + } + } + + // Unequal probability sampling without replacement + void ProbSampleNoReplace(IntegerVector &index, int nOrig, int size, arma::vec &prob){ + int ii, jj, kk; + int nOrig_1 = nOrig - 1; + double rT, mass, totalmass = 1.0; + arma::uvec perm = arma::sort_index(prob, 1); //descending sort of index + prob = arma::sort(prob, 1); // descending sort of prob + // compute the sample + for (ii = 0; ii < size; ii++, nOrig_1--) { + rT = totalmass * unif_rand(); + mass = 0; + for (jj = 0; jj < nOrig_1; jj++) { + mass += prob[jj]; + if (rT <= mass) + break; + } + index[ii] = perm[jj]; + totalmass -= prob[jj]; + for ( kk = jj; kk < nOrig_1; kk++) { + prob[kk] = prob[kk+1]; + perm[kk] = perm[kk+1]; + } + } + } + } +} Added: pkg/RcppArmadillo/inst/unitTests/cpp/sample.cpp =================================================================== --- pkg/RcppArmadillo/inst/unitTests/cpp/sample.cpp (rev 0) +++ pkg/RcppArmadillo/inst/unitTests/cpp/sample.cpp 2013-03-12 02:07:42 UTC (rev 4278) @@ -0,0 +1,68 @@ +#!/usr/bin/r -t +# +# Copyright (C) 2012 - 2013 Christian Gunning and Dirk Eddelbuettel +# +# This file is part of RcppArmadillo. +# +# RcppArmadillo 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. +# +# RcppArmadillo 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 RcppArmadillo. If not, see . + +// [[Rcpp::depends(RcppArmadillo)]] +#include + +#include + +using namespace Rcpp; + +// function defns exported to R -- instantiate templated sample +// functions are identical except for class of sampled vector and return val + +// [[Rcpp::export]] +IntegerVector csample_integer( IntegerVector x, int size, bool replace, + NumericVector prob = NumericVector::create()) { + RNGScope scope; + IntegerVector ret = RcppArmadillo::sample(x, size, replace, prob); + return ret; +} + +// [[Rcpp::export]] +NumericVector csample_numeric( NumericVector x, int size, bool replace, + NumericVector prob = NumericVector::create()) { + RNGScope scope; + NumericVector ret = RcppArmadillo::sample(x, size, replace, prob); + return ret; +} + +// [[Rcpp::export]] +ComplexVector csample_complex( ComplexVector x, int size, bool replace, + NumericVector prob = NumericVector::create()) { + RNGScope scope; + ComplexVector ret = RcppArmadillo::sample(x, size, replace, prob); + return ret; +} + +// [[Rcpp::export]] +CharacterVector csample_character( CharacterVector x, int size, bool replace, + NumericVector prob = NumericVector::create()) { + RNGScope scope; + CharacterVector ret = RcppArmadillo::sample(x, size, replace, prob); + return ret; +} + +// [[Rcpp::export]] +LogicalVector csample_logical( LogicalVector x, int size, bool replace, + NumericVector prob = NumericVector::create()) { + RNGScope scope; + LogicalVector ret = RcppArmadillo::sample(x, size, replace, prob); + return ret; +} Added: pkg/RcppArmadillo/inst/unitTests/runit.sample.R =================================================================== --- pkg/RcppArmadillo/inst/unitTests/runit.sample.R (rev 0) +++ pkg/RcppArmadillo/inst/unitTests/runit.sample.R 2013-03-12 02:07:42 UTC (rev 4278) @@ -0,0 +1,92 @@ +#!/usr/bin/r -t +# +# Copyright (C) 2012 - 2013 Christian Gunning +# +# This file is part of RcppArmadillo. +# +# RcppArmadillo 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. +# +# RcppArmadillo 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 RcppArmadillo. If not, see . + +.setUp <- function(){ + suppressMessages(require(RcppArmadillo)) + sourceCpp(file.path(pathRcppArmadilloTests, "cpp/sample.cpp")) +} + +test.sample <- function() { + ## Seed needs to be reset to compare R to C++ + seed <- 441 + + ## Input vectors to sample + N <- 100 + + ## Number of samples + ## works for size == N?! + size <- N%/%2 + + ## set up S3 dispatching, + ## simplifies lapply(tests, ...) below + csample <- function(x, ...) UseMethod("csample") + csample.numeric <- csample_numeric + csample.integer <- csample_integer + csample.complex <- csample_complex + csample.character <- csample_character + csample.logical <- csample_logical + + ## all atomic vector classes except raw + ## for each list element, check that sampling works + ## with and without replacement, with and without prob + tests <- list() + tests <- within(tests, { + int <- 1:N + num <- (1:N)/10 + cpx <- (1:N)/10 + 1i + char <-rep(letters, 4)[1:N] + bool <- rep(c(T,F), times=N/2) + }) + + ## Un-normalized probs + probs <- seq(from=0, to=1, length.out=N) + #probs <- probs/sum(probs) + + + ## Run the S3 generic function csample + ## and associated R function on each data type + ## ReplaceYN.ProbsYN + lapply(tests, function(dat) { + .class <- class(dat) + set.seed(seed) + ## R + r.no.no <- sample(dat, size, replace=F) + set.seed(seed) + r.yes.no <- sample(dat, size, replace=T) + set.seed(seed) + r.no.yes <- sample(dat, size, replace=F, prob=1:N) + set.seed(seed) + r.yes.yes <- sample(dat, size, replace=T, prob=1:N) + ## C + set.seed(seed) + c.no.no <- csample(dat, size, replace=F) + set.seed(seed) + c.yes.no <- csample(dat, size, replace=T) + set.seed(seed) + c.no.yes <- csample(dat, size, replace=F, prob=1:N) + set.seed(seed) + c.yes.yes <- csample(dat, size, replace=T, prob=1:N) + ## comparisons + checkEquals(r.no.no, c.no.no, msg=sprintf("sample.%s.no_replace.no_prob",.class)) + checkEquals(r.yes.no, c.yes.no, msg=sprintf("sample.%s.replace.no_prob",.class)) + ## the following don't pass + checkEquals(r.no.yes, c.no.yes, msg=sprintf("sample.%s.no_replace.prob",.class)) + checkEquals(r.yes.yes, c.yes.yes, msg=sprintf("sample.%s.replace.prob",.class)) + }) +} Modified: pkg/RcppArmadillo/tests/doRUnit.R =================================================================== --- pkg/RcppArmadillo/tests/doRUnit.R 2013-03-08 16:15:20 UTC (rev 4277) +++ pkg/RcppArmadillo/tests/doRUnit.R 2013-03-12 02:07:42 UTC (rev 4278) @@ -13,13 +13,14 @@ ## ----> put the bulk of the code e.g. in ../inst/unitTests/runTests.R : if(require("RUnit", quietly = TRUE)) { + pkg <- "RcppArmadillo" - require( pkg, character.only=TRUE) - path <- system.file("unitTests", package = pkg) - stopifnot(file.exists(path), file.info(path.expand(path))$isdir) + pathRcppArmadilloTests <<- system.file("unitTests", package = pkg) + stopifnot(file.exists(pathRcppArmadilloTests), + file.info(path.expand(pathRcppArmadilloTests))$isdir) ## without this, we get unit test failures Sys.setenv( R_TESTS = "" ) From noreply at r-forge.r-project.org Tue Mar 12 03:34:00 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Mar 2013 03:34:00 +0100 (CET) Subject: [Rcpp-commits] r4279 - pkg/RcppArmadillo/inst/unitTests/cpp Message-ID: <20130312023401.06D5A184882@r-forge.r-project.org> Author: edd Date: 2013-03-12 03:33:57 +0100 (Tue, 12 Mar 2013) New Revision: 4279 Modified: pkg/RcppArmadillo/inst/unitTests/cpp/sample.cpp Log: brown bag fix Modified: pkg/RcppArmadillo/inst/unitTests/cpp/sample.cpp =================================================================== --- pkg/RcppArmadillo/inst/unitTests/cpp/sample.cpp 2013-03-12 02:07:42 UTC (rev 4278) +++ pkg/RcppArmadillo/inst/unitTests/cpp/sample.cpp 2013-03-12 02:33:57 UTC (rev 4279) @@ -1,26 +1,28 @@ -#!/usr/bin/r -t -# -# Copyright (C) 2012 - 2013 Christian Gunning and Dirk Eddelbuettel -# -# This file is part of RcppArmadillo. -# -# RcppArmadillo 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. -# -# RcppArmadillo 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 RcppArmadillo. If not, see . +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- +// +// sample.cpp: RcppArmadillo unit test code for sample() function +// +// Copyright (C) 2012 - 2013 Christian Gunning and Dirk Eddelbuettel +// +// This file is part of RcppArmadillo. +// +// RcppArmadillo 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. +// +// RcppArmadillo 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 RcppArmadillo. If not, see . // [[Rcpp::depends(RcppArmadillo)]] #include -#include +#include using namespace Rcpp; From noreply at r-forge.r-project.org Tue Mar 12 18:59:41 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Mar 2013 18:59:41 +0100 (CET) Subject: [Rcpp-commits] r4280 - in pkg/RcppArmadillo: . inst inst/include/armadillo_bits inst/unitTests inst/unitTests/cpp Message-ID: <20130312175941.CCB3E184C16@r-forge.r-project.org> Author: edd Date: 2013-03-12 18:59:41 +0100 (Tue, 12 Mar 2013) New Revision: 4280 Added: pkg/RcppArmadillo/inst/unitTests/cpp/armadillo.cpp Modified: pkg/RcppArmadillo/ChangeLog pkg/RcppArmadillo/DESCRIPTION pkg/RcppArmadillo/inst/NEWS.Rd pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp pkg/RcppArmadillo/inst/include/armadillo_bits/gemv.hpp pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R Log: RcppArmadillo 0.3.800.1 with Armadillo 3.800.1 Also factored out cpp/armadillo.cpp from runit.RcppArmadillo.R to accelerate unit test runs Modified: pkg/RcppArmadillo/ChangeLog =================================================================== --- pkg/RcppArmadillo/ChangeLog 2013-03-12 02:33:57 UTC (rev 4279) +++ pkg/RcppArmadillo/ChangeLog 2013-03-12 17:59:41 UTC (rev 4280) @@ -1,3 +1,13 @@ +2013-03-12 Dirk Eddelbuettel + + * DESCRIPTION: Release 0.3.800.1 + + * inst/include/*: Upgraded to new release 3.800.1 of Armadillo + + * inst/unitTests/cpp/armadillo.cpp: Factored out of + runit.RcppArmadillo.R to accelerate unit test run + * inst/unitTests/runit.RcppArmadillo.R: Deploy refactored cpp code + 2013-03-11 Dirk Eddelbuettel * inst/unitTests/cpp/sample.cpp: Regrouping C++ tests for sample() Modified: pkg/RcppArmadillo/DESCRIPTION =================================================================== --- pkg/RcppArmadillo/DESCRIPTION 2013-03-12 02:33:57 UTC (rev 4279) +++ pkg/RcppArmadillo/DESCRIPTION 2013-03-12 17:59:41 UTC (rev 4280) @@ -1,7 +1,7 @@ Package: RcppArmadillo Type: Package Title: Rcpp integration for Armadillo templated linear algebra library -Version: 0.3.800.0.1 +Version: 0.3.800.1 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.800.0). Thus users do not need to + Armadillo library (currently version 3.800.1). 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-03-12 02:33:57 UTC (rev 4279) +++ pkg/RcppArmadillo/inst/NEWS.Rd 2013-03-12 17:59:41 UTC (rev 4280) @@ -2,10 +2,15 @@ \title{News for Package 'RcppArmadillo'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} -\section{Changes in RcppArmadillo version 0.3.800.0.1 (2013-03-31)}{ +\section{Changes in RcppArmadillo version 0.3.800.1 (2013-03-12)}{ \itemize{ - \item UNRELEASED -- version and date subject to change - \item Added new sample() function contributed by Christian Gunning + \item Upgraded to Armadillo release Version 3.800.1 (Miami Beach) + \itemize{ + \item workaround for a bug in ATLAS 3.8 on 64 bit systems + \item faster matrix-vector multiply for small matrices + } + \item Added new sample() function and tests contributed by Christian Gunning + \item Refactored unit testing code for faster unit test performance } } Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2013-03-12 02:33:57 UTC (rev 4279) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/arma_version.hpp 2013-03-12 17:59:41 UTC (rev 4280) @@ -13,7 +13,7 @@ #define ARMA_VERSION_MAJOR 3 #define ARMA_VERSION_MINOR 800 -#define ARMA_VERSION_PATCH 0 +#define ARMA_VERSION_PATCH 1 #define ARMA_VERSION_NAME "Miami Beach" Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp 2013-03-12 02:33:57 UTC (rev 4279) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/diskio_meat.hpp 2013-03-12 17:59:41 UTC (rev 4280) @@ -897,8 +897,8 @@ if( (is_float::value == true) || (is_double::value == true) ) { f.setf(ios::scientific); - f.precision(10); - cell_width = 18; + f.precision(12); + cell_width = 20; } for(uword row=0; row < x.n_rows; ++row) @@ -1023,8 +1023,8 @@ if( (is_float::value == true) || (is_double::value == true) ) { f.setf(ios::scientific); - f.precision(10); - cell_width = 18; + f.precision(12); + cell_width = 20; } for(uword row=0; row < x.n_rows; ++row) @@ -1100,7 +1100,7 @@ if( (is_float::value == true) || (is_double::value == true) ) { f.setf(ios::scientific); - f.precision(10); + f.precision(12); } uword x_n_rows = x.n_rows; @@ -2303,7 +2303,7 @@ if( (is_float::value == true) || (is_double::value == true) ) { f.setf(ios::scientific); - f.precision(10); + f.precision(12); } f << (*iter) << '\n'; @@ -2357,7 +2357,7 @@ if( (is_float::value == true) || (is_double::value == true) ) { f.setf(ios::scientific); - f.precision(10); + f.precision(12); } const eT val = (*iter); @@ -3097,8 +3097,8 @@ if( (is_float::value == true) || (is_double::value == true) ) { f.setf(ios::scientific); - f.precision(10); - cell_width = 18; + f.precision(12); + cell_width = 20; } for(uword slice=0; slice < x.n_slices; ++slice) @@ -3226,8 +3226,8 @@ if( (is_float::value == true) || (is_double::value == true) ) { f.setf(ios::scientific); - f.precision(10); - cell_width = 18; + f.precision(12); + cell_width = 20; } for(uword slice=0; slice < x.n_slices; ++slice) Modified: pkg/RcppArmadillo/inst/include/armadillo_bits/gemv.hpp =================================================================== --- pkg/RcppArmadillo/inst/include/armadillo_bits/gemv.hpp 2013-03-12 02:33:57 UTC (rev 4279) +++ pkg/RcppArmadillo/inst/include/armadillo_bits/gemv.hpp 2013-03-12 17:59:41 UTC (rev 4280) @@ -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 @@ -131,6 +131,74 @@ +class gemv_emul_large_helper + { + public: + + template + arma_hot + inline + static + typename arma_not_cx::result + dot_row_col( const Mat& A, const eT* x, const uword row, const uword N) + { + eT acc1 = eT(0); + eT acc2 = eT(0); + + uword i,j; + for(i=0, j=1; j < N; i+=2, j+=2) + { + const eT xi = x[i]; + const eT xj = x[j]; + + acc1 += A.at(row,i) * xi; + acc2 += A.at(row,j) * xj; + } + + if(i < N) + { + acc1 += A.at(row,i) * x[i]; + } + + return (acc1 + acc2); + } + + + + template + arma_hot + inline + static + typename arma_cx_only::result + dot_row_col( const Mat& A, const eT* x, const uword row, const uword N) + { + typedef typename get_pod_type::result T; + + T val_real = T(0); + T val_imag = T(0); + + for(uword i=0; i& Ai = A.at(row,i); + const std::complex& xi = x[i]; + + const T a = Ai.real(); + const T b = Ai.imag(); + + const T c = xi.real(); + const T d = xi.imag(); + + val_real += (a*c) - (b*d); + val_imag += (a*d) + (b*c); + } + + return std::complex(val_real, val_imag); + } + + }; + + + //! \brief //! Partial emulation of ATLAS/BLAS gemv(). //! 'y' is assumed to have been set to the correct size (i.e. taking into account the transpose) @@ -181,13 +249,8 @@ else for(uword row=0; row < A_n_rows; ++row) { - eT acc = eT(0); + const eT acc = gemv_emul_large_helper::dot_row_col(A, x, row, A_n_cols); - for(uword i=0; i < A_n_cols; ++i) - { - acc += A.at(row,i) * x[i]; - } - if( (use_alpha == false) && (use_beta == false) ) { y[row] = acc; @@ -337,7 +400,8 @@ { arma_extra_debug_sigprint(); - const uword threshold = (is_complex::value == true) ? 16u : 64u; + //const uword threshold = (is_complex::value == true) ? 16u : 64u; + const uword threshold = (is_complex::value == true) ? 64u : 100u; if(A.n_elem <= threshold) { @@ -347,23 +411,50 @@ { #if defined(ARMA_USE_ATLAS) { - arma_extra_debug_print("atlas::cblas_gemv()"); - - atlas::cblas_gemv - ( - atlas::CblasColMajor, - (do_trans_A) ? ( is_complex::value ? CblasConjTrans : atlas::CblasTrans ) : atlas::CblasNoTrans, - A.n_rows, - A.n_cols, - (use_alpha) ? alpha : eT(1), - A.mem, - A.n_rows, - x, - 1, - (use_beta) ? beta : eT(0), - y, - 1 - ); + if(is_complex::value == false) + { + // use gemm() instead of gemv() to work around a speed issue in Atlas 3.8.4 + + arma_extra_debug_print("atlas::cblas_gemm()"); + + atlas::cblas_gemm + ( + atlas::CblasColMajor, + (do_trans_A) ? ( is_complex::value ? CblasConjTrans : atlas::CblasTrans ) : atlas::CblasNoTrans, + atlas::CblasNoTrans, + (do_trans_A) ? A.n_cols : A.n_rows, + 1, + (do_trans_A) ? A.n_rows : A.n_cols, + (use_alpha) ? alpha : eT(1), + A.mem, + A.n_rows, + x, + (do_trans_A) ? A.n_rows : A.n_cols, + (use_beta) ? beta : eT(0), + y, + (do_trans_A) ? A.n_cols : A.n_rows + ); + } + else + { + arma_extra_debug_print("atlas::cblas_gemv()"); + + atlas::cblas_gemv + ( + atlas::CblasColMajor, + (do_trans_A) ? ( is_complex::value ? CblasConjTrans : atlas::CblasTrans ) : atlas::CblasNoTrans, + A.n_rows, + A.n_cols, + (use_alpha) ? alpha : eT(1), + A.mem, + A.n_rows, + x, + 1, + (use_beta) ? beta : eT(0), + y, + 1 + ); + } } #elif defined(ARMA_USE_BLAS) { Added: pkg/RcppArmadillo/inst/unitTests/cpp/armadillo.cpp =================================================================== --- pkg/RcppArmadillo/inst/unitTests/cpp/armadillo.cpp (rev 0) +++ pkg/RcppArmadillo/inst/unitTests/cpp/armadillo.cpp 2013-03-12 17:59:41 UTC (rev 4280) @@ -0,0 +1,212 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- +// +// armadillo.cpp: RcppArmadillo unit test code +// +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel, Romain Francois and Douglas Bates +// +// This file is part of RcppArmadillo. +// +// RcppArmadillo 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. +// +// RcppArmadillo 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 RcppArmadillo. If not, see . + +// [[Rcpp::depends(RcppArmadillo)]] +#include + +using namespace Rcpp; + +// [[Rcpp::export]] +List wrap_() { + + // using the Named(.) = . notation + List cols = List::create(Named( "Col" ) = arma::zeros(5,1), + Named( "Col" ) = arma::zeros(5,1)); + + // using the Named(., .) notation + List rows = List::create(Named( "Row", arma::zeros(1,5) ), + Named( "Row" , arma::zeros(1,5) )); + + // using the _[.] = . notation + List matrices = List::create(_["Mat"] = arma::eye( 3,3 ), + _["Mat"] = arma::eye( 3,3 ), + _["Mat"] = arma::eye( 3, 3 ), + _["Mat"] = arma::eye( 3, 3 )); + + // creating an empty list and grow it on demand + List fields; + arma::field f1( 2, 2 ); + f1( 0, 0 ) = 0; + f1( 1, 0 ) = 1; + f1( 0, 1 ) = 2; + f1( 1, 1 ) = 3; + fields["field"] = f1; + + arma::field f2(2,2); + f2( 0, 0 ) = "a"; + f2( 1, 0 ) = "b"; + f2( 0, 1 ) = "c"; + f2( 1, 1 ) = "d"; + fields["field"] = f2; + + arma::field f3(2,2); + f3(0,0) = arma::zeros(5,1); + f3(1,0) = arma::zeros(4,1); + f3(0,1) = arma::zeros(3,1); + f3(1,1) = arma::zeros(2,1); + fields["field"] = f3; + + List output = List::create(_["matrices : Mat"] = matrices, + _["rows : Row"] = rows, + _["columns : Col"] = cols, + _["fields : field"] = fields ); + + return output; +} + +// [[Rcpp::export]] +List wrapGlue_() { + arma::mat m1 = arma::eye( 3, 3 ); + arma::mat m2 = arma::eye( 3, 3 ); + + List res; + res["mat+mat"] = m1 + m2; + return res; +} + +// [[Rcpp::export]] +List wrapOp_() { + arma::mat m1 = arma::eye( 3, 3 ); + + List res; + res["- mat"] = - m1; + return res; +} + +// [[Rcpp::export]] +List asMat_(List input) { + arma::imat m1 = input[0]; /* implicit as */ + arma::mat m2 = input[1]; /* implicit as */ + arma::umat m3 = input[0]; /* implicit as */ + arma::fmat m4 = input[1]; /* implicit as */ + + List res = List::create(arma::accu( m1 ), + arma::accu( m2 ), + arma::accu( m3 ), + arma::accu( m4 ) ); + + return res; +} + +// [[Rcpp::export]] +List asCol_(List input) { + arma::icolvec m1 = input[0]; /* implicit as */ + arma::colvec m2 = input[1]; /* implicit as */ + arma::ucolvec m3 = input[0]; /* implicit as */ + arma::fcolvec m4 = input[1]; /* implicit as */ + + List res = List::create(arma::accu( m1 ), + arma::accu( m2 ), + arma::accu( m3 ), + arma::accu( m4 ) ); + return res; +} + +// [[Rcpp::export]] +List asRow_(List input) { + arma::irowvec m1 = input[0]; /* implicit as */ + arma::rowvec m2 = input[1]; /* implicit as */ + arma::urowvec m3 = input[0]; /* implicit as */ + arma::frowvec m4 = input[1]; /* implicit as */ + + List res = List::create(arma::accu( m1 ), + arma::accu( m2 ), + arma::accu( m3 ), + arma::accu( m4 ) ); + return res; +} + +// [[Rcpp::export]] +List cxMat_() { + arma::cx_mat m1 = arma::eye ( 3, 3 ); + arma::cx_fmat m2 = arma::eye( 3, 3 ); + return List::create( _["double"] = m1, _["float"] = m2 ); +} + +// [[Rcpp::export]] +ComplexMatrix mtOp_() { + std::complex x( 1.0, 2.0 ); + arma::mat m1 = arma::eye ( 3, 3 ); + + return wrap( x * m1 ); +} + +// [[Rcpp::export]] +NumericMatrix mtGlue_() { + arma::imat m2 = arma::eye ( 3, 3 ); + arma::mat m1 = arma::eye ( 3, 3 ); + + return wrap( m1 + m2 ); +} + +// [[Rcpp::export]] +NumericMatrix sugar_(NumericVector xx) { + arma::mat m = xx + xx; + return wrap( m ); +} + +// [[Rcpp::export]] +ComplexMatrix sugarCplx_(ComplexVector xx) { + arma::cx_mat m = exp( xx ); + return wrap( m ); +} + +// [[Rcpp::export]] +List sugarCtor_(NumericVector xx) { + arma::mat m = xx + xx; + arma::colvec co = xx; + arma::rowvec ro = xx; + return List::create(_["mat"] = m + m, + _["rowvec"] = ro, + _["colvec"] = co); +} + +double norm( double x, double y){ + return ::sqrt( x*x + y*y ); +} + +// [[Rcpp::export]] +List sugarMatrixCtor_(NumericVector xx) { + NumericVector yy = NumericVector::create( 1 ); + arma::mat m = diag( xx ); + arma::colvec co = outer( xx, yy, ::norm ); + arma::rowvec ro = outer( yy, xx, ::norm ); + return List::create(_["mat"] = m + m , + _["rowvec"] = ro, + _["colvec"] = co); +} + +// test.armadillo.rtti.check <- function() { + +// inc <- ' +// void blah(arma::mat& X) { +// X.set_size(5,5); +// } +// ' +// src <- ' +// arma::vec V; +// blah(V); // if blah() worked, we have a problem +// ' +// fun <- cxxfunction(signature(), body=src, inc=inc, plugin = "RcppArmadillo") + +// checkException(fun(), msg="RTTI check on matrix constructor exception") + +// } Modified: pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R =================================================================== --- pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R 2013-03-12 02:33:57 UTC (rev 4279) +++ pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R 2013-03-12 17:59:41 UTC (rev 4280) @@ -19,64 +19,11 @@ .setUp <- function(){ suppressMessages(require(inline)) + sourceCpp(file.path(pathRcppArmadilloTests, "cpp/armadillo.cpp")) } test.wrap.R <- function(){ - - fx <- cxxfunction( , ' - - // using the Named(.) = . notation - List cols = List::create( - Named( "Col" ) = arma::zeros(5,1), - Named( "Col" ) = arma::zeros(5,1) - ) ; - - // using the Named(., .) notation - List rows = List::create( - Named( "Row", arma::zeros(1,5) ), - Named( "Row" , arma::zeros(1,5) ) - ) ; - - // using the _[.] = . notation - List matrices = List::create( - _["Mat"] = arma::eye( 3,3 ), - _["Mat"] = arma::eye( 3,3 ), - _["Mat"] = arma::eye( 3, 3 ), - _["Mat"] = arma::eye( 3, 3 ) - ) ; - - // creating an empty list and grow it on demand - List fields ; - arma::field f1( 2, 2 ) ; - f1( 0, 0 ) = 0 ; - f1( 1, 0 ) = 1 ; - f1( 0, 1 ) = 2 ; - f1( 1, 1 ) = 3 ; - fields["field"] = f1 ; - - arma::field f2(2,2) ; - f2( 0, 0 ) = "a" ; - f2( 1, 0 ) = "b" ; - f2( 0, 1 ) = "c" ; - f2( 1, 1 ) = "d" ; - fields["field"] = f2 ; - - arma::field f3(2,2) ; - f3(0,0) = arma::zeros(5,1) ; - f3(1,0) = arma::zeros(4,1) ; - f3(0,1) = arma::zeros(3,1) ; - f3(1,1) = arma::zeros(2,1) ; - fields["field"] = f3 ; - - List output = List::create( - _["matrices : Mat"] = matrices, - _["rows : Row"] = rows, - _["columns : Col"] = cols, - _["fields : field"] = fields ) ; - - return output ; - ' , plugin = "RcppArmadillo" ) - + fx <- wrap_ res <- fx() checkEquals( res[[1]][[1]], matrix(as.integer((diag(3))),nr=3), msg = "eye(3,3)" ) @@ -95,55 +42,19 @@ } test.wrap.Glue <- function(){ - - fx <- cxxfunction( , ' - - arma::mat m1 = arma::eye( 3, 3 ) ; - arma::mat m2 = arma::eye( 3, 3 ) ; - - List res ; - res["mat+mat"] = m1 + m2 ; - return res ; - - ', plugin = "RcppArmadillo" ) - - res <- fx() + fx <- wrapGlue_ + res <- fx() checkEquals( res[[1]], 2*diag(3), msg = "wrap(Glue)" ) } test.wrap.Op <- function(){ - - fx <- cxxfunction( , ' - - arma::mat m1 = arma::eye( 3, 3 ) ; - - List res ; - res["- mat"] = - m1 ; - return res ; - - ', plugin = "RcppArmadillo" ) + fx <- wrapOp_ res <- fx() checkEquals( res[[1]], -1*diag(3), msg = "wrap(Op)" ) } test.as.Mat <- function(){ - - fx <- cxxfunction( signature(input_ = "list" ) , ' - List input(input_) ; - arma::imat m1 = input[0] ; /* implicit as */ - arma::mat m2 = input[1] ; /* implicit as */ - arma::umat m3 = input[0] ; /* implicit as */ - arma::fmat m4 = input[1] ; /* implicit as */ - - List res = List::create( - arma::accu( m1 ), - arma::accu( m2 ), - arma::accu( m3 ), - arma::accu( m4 ) ) ; - - return res ; - ', plugin = "RcppArmadillo" ) - + fx <- asMat_ integer_mat <- matrix( as.integer(diag(4)), ncol = 4, nrow = 4 ) numeric_mat <- diag(5) res <- fx( list( integer_mat, numeric_mat ) ) @@ -151,180 +62,78 @@ } test.as.Col <- function(){ - fx <- cxxfunction( signature(input_ = "list" ) , ' - - List input(input_) ; - arma::icolvec m1 = input[0] ; /* implicit as */ - arma::colvec m2 = input[1] ; /* implicit as */ - arma::ucolvec m3 = input[0] ; /* implicit as */ - arma::fcolvec m4 = input[1] ; /* implicit as */ - - List res = List::create( - arma::accu( m1 ), - arma::accu( m2 ), - arma::accu( m3 ), - arma::accu( m4 ) ) ; - - return res ; - - ', plugin = "RcppArmadillo" ) - + fx <- asCol_ res <- fx( list( 1:10, as.numeric(1:10) ) ) checkEquals( unlist( res ), rep(55.0, 4 ), msg = "as" ) } test.as.Row <- function(){ - fx <- cxxfunction( signature(input_ = "list" ) , ' - - List input(input_) ; - arma::irowvec m1 = input[0] ; /* implicit as */ - arma::rowvec m2 = input[1] ; /* implicit as */ - arma::urowvec m3 = input[0] ; /* implicit as */ - arma::frowvec m4 = input[1] ; /* implicit as */ - - List res = List::create( - arma::accu( m1 ), - arma::accu( m2 ), - arma::accu( m3 ), - arma::accu( m4 ) ) ; - return res ; - - ', plugin = "RcppArmadillo" ) - + fx <- asRow_ res <- fx( list( 1:10, as.numeric(1:10) ) ) checkEquals( unlist( res ), rep(55.0, 4 ), msg = "as" ) } test.cxmat <- function(){ - - fx <- cxxfunction( signature() , ' - - arma::cx_mat m1 = arma::eye ( 3, 3 ) ; - arma::cx_fmat m2 = arma::eye( 3, 3 ) ; - return List::create( _["double"] = m1, _["float"] = m2 ) ; - - ', plugin = "RcppArmadillo" ) - checkEquals( fx(), + fx <- cxMat_ + checkEquals(fx(), list( double = (1+0i)*diag(3), float = (1+0i)*diag(3) ), msg = "support for complex matrices" ) } test.mtOp <- function(){ - - fx <- cxxfunction( signature() , ' - - std::complex x( 1.0, 2.0 ) ; - arma::mat m1 = arma::eye ( 3, 3 ) ; - - return wrap( x * m1 ) ; - - ', plugin = "RcppArmadillo" ) - checkEquals( fx(), + fx <- mtOp_ + checkEquals(fx(), (1+2i)*diag(3), msg = "support for mtOp" ) } test.mtGlue <- function(){ - - fx <- cxxfunction( signature() , ' - - arma::imat m2 = arma::eye ( 3, 3 ) ; - arma::mat m1 = arma::eye ( 3, 3 ) ; - - return wrap( m1 + m2 ) ; - - ', plugin = "RcppArmadillo" ) - checkEquals( fx(), + fx <- mtGlue_ + checkEquals(fx(), 2.0 * diag(3) , - msg = "support for mtOp" ) + msg = "support for mtGlue" ) } test.sugar <- function(){ - - fx <- cxxfunction( signature(x= "numeric") , ' - NumericVector xx(x) ; - arma::mat m = xx + xx ; - return wrap( m ) ; - - ', plugin = "RcppArmadillo" ) - checkEquals( fx(1:10), + fx <- sugar_ + checkEquals(fx(1:10), matrix( 2*(1:10), nrow = 10 ) , msg = "RcppArmadillo and sugar" ) } test.sugar.cplx <- function(){ - - fx <- cxxfunction( signature(x= "complex") , ' - ComplexVector xx(x) ; - arma::cx_mat m = exp( xx ) ; - - return wrap( m ) ; - - ', plugin = "RcppArmadillo" ) + fx <- sugarCplx_ x <- 1:10*(1+1i) - checkEquals( fx(x), + checkEquals(fx(x), matrix( exp(x), nrow = 10 ) , msg = "RcppArmadillo and sugar (complex)" ) } test.armadillo.sugar.ctor <- function(){ - - fx <- cxxfunction( signature(x= "numeric") , ' - NumericVector xx(x) ; - arma::mat m = xx + xx ; - arma::colvec co = xx ; - arma::rowvec ro = xx ; - return List::create( - _["mat"] = m + m, - _["rowvec"] = ro, - _["colvec"] = co - ); - ', plugin = "RcppArmadillo" ) - checkEquals( fx(1:10), - list( - mat = matrix( 4*(1:10), nrow = 10 ), + fx <- sugarCtor_ + checkEquals(fx(1:10), + list(mat = matrix( 4*(1:10), nrow = 10 ), rowvec = matrix( 1:10, nrow = 1 ), - colvec = matrix( 1:10, ncol = 1 ) - ) - , + colvec = matrix( 1:10, ncol = 1 )) , msg = "Mat( sugar expression )" ) } test.armadillo.sugar.matrix.ctor <- function(){ - - inc <- ' - double norm( double x, double y){ - return ::sqrt( x*x + y*y ); - } - ' - fx <- cxxfunction( signature(x= "numeric") , ' - NumericVector xx(x) ; - NumericVector yy = NumericVector::create( 1 ) ; - arma::mat m = diag( xx ) ; - arma::colvec co = outer( xx, yy, ::norm ) ; - arma::rowvec ro = outer( yy, xx, ::norm ) ; - return List::create( - _["mat"] = m + m , - _["rowvec"] = ro, - _["colvec"] = co - ); - ', plugin = "RcppArmadillo", includes = inc ) + fx <- sugarMatrixCtor_ res <- fx(1:10) norm <- function(x, y) sqrt( x*x + y*y ) - checkEquals( res, - list( - mat = diag(2*(1:10)), + checkEquals(res, + list(mat = diag(2*(1:10)), rowvec = outer( 1, 1:10, norm ), - colvec = outer( 1:10, 1, norm ) - ), + colvec = outer( 1:10, 1, norm )), msg = "Mat( sugar expression )" ) } From noreply at r-forge.r-project.org Tue Mar 12 19:02:22 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Mar 2013 19:02:22 +0100 (CET) Subject: [Rcpp-commits] r4281 - in pkg/Rcpp: . inst/include/Rcpp Message-ID: <20130312180222.255ED184C16@r-forge.r-project.org> Author: romain Date: 2013-03-12 19:02:21 +0100 (Tue, 12 Mar 2013) New Revision: 4281 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/Module.h Log: added virtual destructor to CppProperty Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-12 17:59:41 UTC (rev 4280) +++ pkg/Rcpp/ChangeLog 2013-03-12 18:02:21 UTC (rev 4281) @@ -1,3 +1,7 @@ +2013-03-12 Romain Francois + + * include/Rcpp/Module.h: added virtual destructor to CppProperty + 2013-03-08 Dirk Eddelbuettel * inst/include/Rcpp/platform/compiler.h: Improved g++ version Modified: pkg/Rcpp/inst/include/Rcpp/Module.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/Module.h 2013-03-12 17:59:41 UTC (rev 4280) +++ pkg/Rcpp/inst/include/Rcpp/Module.h 2013-03-12 18:02:21 UTC (rev 4281) @@ -279,6 +279,7 @@ typedef Rcpp::XPtr XP ; CppProperty(const char* doc = 0) : docstring( doc == 0 ? "" : doc ) {} ; + virtual ~CppProperty(){} ; virtual SEXP get(Class* ) { throw std::range_error("cannot retrieve property"); } virtual void set(Class*, SEXP) { throw std::range_error("cannot set property"); } virtual bool is_readonly(){ return false; } From noreply at r-forge.r-project.org Wed Mar 13 15:27:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 13 Mar 2013 15:27:01 +0100 (CET) Subject: [Rcpp-commits] r4282 - pkg/RcppArmadillo Message-ID: <20130313142701.D2B00183E28@r-forge.r-project.org> Author: edd Date: 2013-03-13 15:27:01 +0100 (Wed, 13 Mar 2013) New Revision: 4282 Modified: pkg/RcppArmadillo/DESCRIPTION Log: updated Depends: on Rcpp to Rcpp (>= 0.10.2) as we use sourceCpp() in tests Modified: pkg/RcppArmadillo/DESCRIPTION =================================================================== --- pkg/RcppArmadillo/DESCRIPTION 2013-03-12 18:02:21 UTC (rev 4281) +++ pkg/RcppArmadillo/DESCRIPTION 2013-03-13 14:27:01 UTC (rev 4282) @@ -32,7 +32,7 @@ or later, as is the rest of Rcpp. License: GPL (>= 2) LazyLoad: yes -Depends: R (>= 2.14.0), Rcpp (>= 0.9.10) +Depends: R (>= 2.14.0), Rcpp (>= 0.10.2) LinkingTo: Rcpp Suggests: inline, RUnit URL: http://arma.sourceforge.net/, http://dirk.eddelbuettel.com/code/rcpp.armadillo.html, http://romainfrancois.blog.free.fr/index.php?category/R-package/RcppArmadillo From noreply at r-forge.r-project.org Wed Mar 20 02:39:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Mar 2013 02:39:53 +0100 (CET) Subject: [Rcpp-commits] r4283 - in pkg/Rcpp: . inst inst/include/Rcpp src Message-ID: <20130320013953.2C03C184E8E@r-forge.r-project.org> Author: edd Date: 2013-03-20 02:39:52 +0100 (Wed, 20 Mar 2013) New Revision: 4283 Modified: pkg/Rcpp/DESCRIPTION pkg/Rcpp/inst/NEWS.Rd pkg/Rcpp/inst/include/Rcpp/config.h pkg/Rcpp/src/api.cpp Log: attempt to roll back to to R_PreserveObject / R_ReleaseObject via a simple #define but blows up in unit test for modules Modified: pkg/Rcpp/DESCRIPTION =================================================================== --- pkg/Rcpp/DESCRIPTION 2013-03-13 14:27:01 UTC (rev 4282) +++ pkg/Rcpp/DESCRIPTION 2013-03-20 01:39:52 UTC (rev 4283) @@ -1,6 +1,6 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.10.2.5 +Version: 0.10.2.6 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-03-13 14:27:01 UTC (rev 4282) +++ pkg/Rcpp/inst/NEWS.Rd 2013-03-20 01:39:52 UTC (rev 4283) @@ -2,7 +2,7 @@ \title{News for Package 'Rcpp'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} -\section{Changes in Rcpp 0.10.3 (future)}{ +\section{Changes in Rcpp 0.10.3 (2013-xx-yy)}{ \itemize{ \item Changes in R code: \itemize{ @@ -41,7 +41,7 @@ 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 + \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 } Modified: pkg/Rcpp/inst/include/Rcpp/config.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/config.h 2013-03-13 14:27:01 UTC (rev 4282) +++ pkg/Rcpp/inst/include/Rcpp/config.h 2013-03-20 01:39:52 UTC (rev 4283) @@ -26,6 +26,10 @@ // All three digits have to be integers for g++-4.7 or later #define RCPP_VERSION Rcpp_Version(0,10,3) + +// Rcpp 0.10.3 has initial support for new preserve/release semantics +// This switch enables a rollback to the standard R preserve/release semantics +#define RCPP_USE_NEW_PRESERVE_RELEASE 1 #endif Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-03-13 14:27:01 UTC (rev 4282) +++ pkg/Rcpp/src/api.cpp 2013-03-20 01:39:52 UTC (rev 4283) @@ -48,6 +48,7 @@ } SEXP Rcpp_PreserveObject(SEXP x){ +#if RCPP_USE_NEW_PRESERVE_RELEASE if( x != R_NilValue ){ init_ProtectionStack(); int top = GET_TOP() ; @@ -60,9 +61,15 @@ #if RCPP_DEBUG_LEVEL > 1 Rcpp_Stack_Debug() ; #endif +#else + if( x != R_NilValue ) { + R_PreserveObject(x); + } +#endif return x ; } void Rcpp_ReleaseObject(SEXP x){ +#if RCPP_USE_NEW_PRESERVE_RELEASE if( x != R_NilValue ){ init_ProtectionStack(); @@ -96,13 +103,20 @@ Rcpp_Stack_Debug() ; #endif } +#else + if (x != R_NilValue) { + R_ReleaseObject(x); + } +#endif } + SEXP Rcpp_ReplaceObject(SEXP x, SEXP y){ if( x == R_NilValue ){ Rcpp_PreserveObject( y ) ; } else if( y == R_NilValue ){ Rcpp_ReleaseObject( x ) ; } else { +#if RCPP_USE_NEW_PRESERVE_RELEASE init_ProtectionStack(); int top = GET_TOP(); @@ -122,6 +136,7 @@ Rcpp_Stack_Debug() ; #endif +#endif } return y ; } From noreply at r-forge.r-project.org Wed Mar 20 03:30:57 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Mar 2013 03:30:57 +0100 (CET) Subject: [Rcpp-commits] r4284 - in pkg/Rcpp: . inst inst/include/Rcpp src Message-ID: <20130320023057.A91D318466F@r-forge.r-project.org> Author: edd Date: 2013-03-20 03:30:56 +0100 (Wed, 20 Mar 2013) New Revision: 4284 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/NEWS.Rd pkg/Rcpp/inst/include/Rcpp/config.h pkg/Rcpp/src/api.cpp Log: second pass at api.cpp with now complete fallback to R's preserve/release Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-20 01:39:52 UTC (rev 4283) +++ pkg/Rcpp/ChangeLog 2013-03-20 02:30:56 UTC (rev 4284) @@ -1,3 +1,12 @@ +2013-03-19 Dirk Eddelbuettel + + * inst/include/Rcpp/config.h: Define RCPP_USE_NEW_PRESERVE_RELEASE + with default value of 0 to enable/disable new preserve/release code + + * src/api.cpp: Bracket the new Rcpp object preserve / release code + with the new variable RCPP_USE_NEW_PRESERVE_RELEASE and fall back + to R behaviour if not set + 2013-03-12 Romain Francois * include/Rcpp/Module.h: added virtual destructor to CppProperty @@ -36,8 +45,8 @@ * 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. - + * 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/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-03-20 01:39:52 UTC (rev 4283) +++ pkg/Rcpp/inst/NEWS.Rd 2013-03-20 02:30:56 UTC (rev 4284) @@ -38,7 +38,10 @@ 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 + treated as a stack instead of a pairlist in the R + implementation. + \item As the preserve / release code is still a little rough at + the edges, a new #define is used (in config.h) to disable it for now. \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 Modified: pkg/Rcpp/inst/include/Rcpp/config.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/config.h 2013-03-20 01:39:52 UTC (rev 4283) +++ pkg/Rcpp/inst/include/Rcpp/config.h 2013-03-20 02:30:56 UTC (rev 4284) @@ -29,7 +29,7 @@ // Rcpp 0.10.3 has initial support for new preserve/release semantics // This switch enables a rollback to the standard R preserve/release semantics -#define RCPP_USE_NEW_PRESERVE_RELEASE 1 +#define RCPP_USE_NEW_PRESERVE_RELEASE 0 #endif Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-03-20 01:39:52 UTC (rev 4283) +++ pkg/Rcpp/src/api.cpp 2013-03-20 02:30:56 UTC (rev 4284) @@ -135,7 +135,18 @@ #if RCPP_DEBUG_LEVEL > 1 Rcpp_Stack_Debug() ; #endif - +#else + // if we are setting to the same SEXP as we already have, do nothing + if (x != y) { + + // the previous SEXP was not NULL, so release it + Rcpp_ReleaseObject(x); + + // the new SEXP is not NULL, so preserve it + Rcpp_PreserveObject(y); + + //update(); + } #endif } return y ; From noreply at r-forge.r-project.org Wed Mar 20 20:00:57 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Mar 2013 20:00:57 +0100 (CET) Subject: [Rcpp-commits] r4285 - in pkg/Rcpp: . inst/include/Rcpp/internal inst/include/Rcpp/traits Message-ID: <20130320190057.304B51849EB@r-forge.r-project.org> Author: romain Date: 2013-03-20 20:00:56 +0100 (Wed, 20 Mar 2013) New Revision: 4285 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/internal/wrap.h pkg/Rcpp/inst/include/Rcpp/traits/is_wide_string.h Log: make httpuv happy Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-20 02:30:56 UTC (rev 4284) +++ pkg/Rcpp/ChangeLog 2013-03-20 19:00:56 UTC (rev 4285) @@ -1,3 +1,9 @@ +2013-03-20 Romain Francois + + * include/Rcpp/traits/is_wide_string.h : fixes to re-enable wrap( vector ) + and wrap( vector ), needed to support package httpuv + * include/Rcpp/internal/wrap.h : same + 2013-03-19 Dirk Eddelbuettel * inst/include/Rcpp/config.h: Define RCPP_USE_NEW_PRESERVE_RELEASE Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-03-20 02:30:56 UTC (rev 4284) +++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h 2013-03-20 19:00:56 UTC (rev 4285) @@ -47,12 +47,23 @@ wcstombs( buffer, data, MAXELTSIZE ) ; return Rf_mkChar(buffer) ; } + inline SEXP make_charsexp__impl__wstring( wchar_t data ){ + wchar_t x[2] ; x[0] = data ; x[1] = '\0' ; + char* buffer = get_string_buffer() ; + wcstombs( buffer, x, 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( char data ){ + char x[2]; x[0] = data ; x[1] = '\0' ; + return Rf_mkChar( x ) ; + } + inline SEXP make_charsexp__impl__cstring( const std::string& st ){ return make_charsexp__impl__cstring( st.c_str() ) ; } Modified: pkg/Rcpp/inst/include/Rcpp/traits/is_wide_string.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/is_wide_string.h 2013-03-20 02:30:56 UTC (rev 4284) +++ pkg/Rcpp/inst/include/Rcpp/traits/is_wide_string.h 2013-03-20 19:00:56 UTC (rev 4285) @@ -33,6 +33,9 @@ template <> struct is_wide_string< const wchar_t* > : public true_type{} ; template <> struct is_wide_string< const char* > : public false_type{} ; + template <> struct is_wide_string< wchar_t > : public true_type{} ; + template <> struct is_wide_string< char > : public false_type{} ; + } // traits } // Rcpp From noreply at r-forge.r-project.org Wed Mar 20 23:45:49 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Mar 2013 23:45:49 +0100 (CET) Subject: [Rcpp-commits] r4286 - in pkg/Rcpp: . inst inst/include/Rcpp Message-ID: <20130320224549.55A32185215@r-forge.r-project.org> Author: edd Date: 2013-03-20 23:45:49 +0100 (Wed, 20 Mar 2013) New Revision: 4286 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/DESCRIPTION pkg/Rcpp/inst/CITATION pkg/Rcpp/inst/include/Rcpp/config.h Log: correct one copyright year add upcoming book to CITATION add another minor version to trigger R-Forge build and tarballs Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-20 19:00:56 UTC (rev 4285) +++ pkg/Rcpp/ChangeLog 2013-03-20 22:45:49 UTC (rev 4286) @@ -1,3 +1,7 @@ +2013-03-20 Dirk Eddelbuettel + + * inst/CITATION: Add information about forthcoming book + 2013-03-20 Romain Francois * include/Rcpp/traits/is_wide_string.h : fixes to re-enable wrap( vector ) Modified: pkg/Rcpp/DESCRIPTION =================================================================== --- pkg/Rcpp/DESCRIPTION 2013-03-20 19:00:56 UTC (rev 4285) +++ pkg/Rcpp/DESCRIPTION 2013-03-20 22:45:49 UTC (rev 4286) @@ -1,6 +1,6 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.10.2.6 +Version: 0.10.2.7 Date: $Date$ Author: Dirk Eddelbuettel and Romain Francois, with contributions by Douglas Bates, John Chambers and JJ Allaire Modified: pkg/Rcpp/inst/CITATION =================================================================== --- pkg/Rcpp/inst/CITATION 2013-03-20 19:00:56 UTC (rev 4285) +++ pkg/Rcpp/inst/CITATION 2013-03-20 22:45:49 UTC (rev 4286) @@ -18,4 +18,15 @@ "URL http://www.jstatsoft.org/v40/i08/.") ) +citEntry(entry = "Book", + title = "Seamless {R} and {C++} Integration with {Rcpp}", + author = personList(as.person("Dirk Eddelbuettel")), + publisher = "Springer", + address = "New York", + year = 2013, + note = "ISBN 978-1-4614-6867-7", + textVersion = paste("Eddelbuettel, Dirk (2013)", + "Seamless R and C++ Integration with Rcpp.", + "Springer, New York. ISBN 978-1-4614-6867-7.") +) Modified: pkg/Rcpp/inst/include/Rcpp/config.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/config.h 2013-03-20 19:00:56 UTC (rev 4285) +++ pkg/Rcpp/inst/include/Rcpp/config.h 2013-03-20 22:45:49 UTC (rev 4286) @@ -2,7 +2,7 @@ // // config.h: Rcpp R/C++ interface class library -- Rcpp configuration // -// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // From noreply at r-forge.r-project.org Thu Mar 21 03:22:02 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Mar 2013 03:22:02 +0100 (CET) Subject: [Rcpp-commits] r4287 - in pkg/Rcpp: . inst/doc Message-ID: <20130321022203.3E35F1813AD@r-forge.r-project.org> Author: edd Date: 2013-03-21 03:22:01 +0100 (Thu, 21 Mar 2013) New Revision: 4287 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/doc/Rcpp.bib Log: updated Rcpp.bib Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-20 22:45:49 UTC (rev 4286) +++ pkg/Rcpp/ChangeLog 2013-03-21 02:22:01 UTC (rev 4287) @@ -1,13 +1,16 @@ 2013-03-20 Dirk Eddelbuettel + * inst/doc/Rcpp.bib: Updated versions for several CRAN packages + * inst/CITATION: Add information about forthcoming book 2013-03-20 Romain Francois - * include/Rcpp/traits/is_wide_string.h : fixes to re-enable wrap( vector ) - and wrap( vector ), needed to support package httpuv + * include/Rcpp/traits/is_wide_string.h : fixes to re-enable wrap( + vector ) and wrap( vector ), needed to support package + httpuv * include/Rcpp/internal/wrap.h : same - + 2013-03-19 Dirk Eddelbuettel * inst/include/Rcpp/config.h: Define RCPP_USE_NEW_PRESERVE_RELEASE Modified: pkg/Rcpp/inst/doc/Rcpp.bib =================================================================== --- pkg/Rcpp/inst/doc/Rcpp.bib 2013-03-20 22:45:49 UTC (rev 4286) +++ pkg/Rcpp/inst/doc/Rcpp.bib 2013-03-21 02:22:01 UTC (rev 4287) @@ -92,7 +92,7 @@ title = {RInside: C++ classes to embed R in C++ applications}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, year = 2012, - note = {R package version 0.2.7}, + note = {R package version 0.2.10}, url = CRAN # "package=RInside" } @@ -100,15 +100,15 @@ title = {RProtoBuf: 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}, + note = {R package version 0.2.6}, url = CRAN # "package=RProtoBuf" } @Manual{CRAN:RQuantLib, title = {RQuantLib: {R} interface to the {QuantLib} library}, author = {Dirk Eddelbuettel and Khanh Nguyen}, - year = 2011, - note = {R package version 0.3.8}, + year = 2013, + note = {R package version 0.3.10}, url = CRAN # "package=RQuantLib" } @@ -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.10.2}, + note = {R package version 0.10.3}, url = CRAN # "package=Rcpp" } @@ -144,8 +144,8 @@ 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}, + year = 2013, + note = {R package version 0.3.800.1}, url = CRAN # "package=RcppArmadillo" } @@ -153,7 +153,7 @@ title = {RcppClassic: Deprecated 'classic' Rcpp API}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, year = 2012, - note = {R package version 0.9.2}, + note = {R package version 0.9.3}, url = CRAN # "package=RcppClassic" } @@ -169,8 +169,8 @@ 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}, + year = 2013, + note = {{R} package version 0.3.1.2.1}, url = CRAN # "package=RcppEigen" } @@ -190,8 +190,8 @@ title = {RcppExamples: Examples using {Rcpp} to interface {R} and {C++}}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2012, - note = {R package version 0.1.4}, + year = 2013, + note = {R package version 0.1.6}, url = CRAN # "package=RcppExamples" } @@ -224,7 +224,7 @@ title = {highlight: Syntax highlighter}, author = {Romain Fran\c{c}ois}, year = 2012, - note = {R package version 0.3.2}, + note = {Archived R package with last version 0.3.2}, url = CRAN # "package=highlight" } @@ -233,16 +233,16 @@ R}, author = {Oleg Sklyar and Duncan Murdoch and Mike Smith and Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2012, - note = {R package version 0.3.10}, + year = 2013, + note = {R package version 0.3.11}, url = CRAN # "package=inline" } @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}, + year = 2013, + note = {R package version 1.0-11}, url = CRAN # "package=Matrix" } @@ -260,7 +260,7 @@ title = {roxygen2: In-source documentation for R}, author = {Hadley Wickham and Peter Danenberg and Manuel Eugster}, year = 2011, - note = {R package version 2.2.12}, + note = {R package version 2.2.2}, url = CRAN # "package=roxygen2" } @@ -273,6 +273,16 @@ isbn = {978-1-4614-6867-7} } + at Article{Eddelbuettel+Sanderson:2013:RcppArmadillo, + title = {{RcppArmadillo}: Accelerating {R} with High-Performance {C++} Linear Algebra}, + author = {Dirk Eddelbuettel and Conrad Sanderson}, + journal = {Computational Statistics and Data Analysis}, + year = 2013, + volume = {(in press)}, + doi = {10.1016/j.csda.2013.02.005}, + url = {http://dx.doi.org/10.1016/j.csda.2013.02.005} +} + ; see http://eigen.tuxfamily.org/index.php?title=BibTeX ; replaced 'howpublished' with 'url' and updated year to 2011, and again to 2012 @MISC{Eigen:Web, From noreply at r-forge.r-project.org Thu Mar 21 13:04:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Mar 2013 13:04:53 +0100 (CET) Subject: [Rcpp-commits] r4288 - pkg/Rcpp Message-ID: <20130321120453.593E41805B5@r-forge.r-project.org> Author: jjallaire Date: 2013-03-21 13:04:53 +0100 (Thu, 21 Mar 2013) New Revision: 4288 Modified: pkg/Rcpp/TODO Log: update todo Modified: pkg/Rcpp/TODO =================================================================== --- pkg/Rcpp/TODO 2013-03-21 02:22:01 UTC (rev 4287) +++ pkg/Rcpp/TODO 2013-03-21 12:04:53 UTC (rev 4288) @@ -112,6 +112,8 @@ o Solution for the problem of sharing/propagating typedefs to RcppExports + o Allow use of 'inline' keyword on exported functions + o Allow sourceCpp to build an entire directory o Consider allowing local includes in sourceCpp (but compilation cache @@ -123,8 +125,6 @@ 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 Thu Mar 21 20:29:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Mar 2013 20:29:07 +0100 (CET) Subject: [Rcpp-commits] r4289 - in pkg/Rcpp: . inst/unitTests Message-ID: <20130321192907.74F09180BAE@r-forge.r-project.org> Author: edd Date: 2013-03-21 20:29:07 +0100 (Thu, 21 Mar 2013) New Revision: 4289 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/unitTests/runit.wstring.R Log: replace the "?\226?\130?\172" symbol with its unicode equivalent "\u20ac" in unit test file Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-21 12:04:53 UTC (rev 4288) +++ pkg/Rcpp/ChangeLog 2013-03-21 19:29:07 UTC (rev 4289) @@ -1,3 +1,8 @@ +2013-03-21 Dirk Eddelbuettel + + * inst/unitTests/runit.wstring.R (test.as_vector_wstring): replace + the "?" symbol with its unicode equivalent "\u20ac" + 2013-03-20 Dirk Eddelbuettel * inst/doc/Rcpp.bib: Updated versions for several CRAN packages Modified: pkg/Rcpp/inst/unitTests/runit.wstring.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.wstring.R 2013-03-21 12:04:53 UTC (rev 4288) +++ pkg/Rcpp/inst/unitTests/runit.wstring.R 2013-03-21 19:29:07 UTC (rev 4289) @@ -28,25 +28,26 @@ } test.CharacterVector_wstring <- function(){ - res <- CharacterVector_wstring() + res <- CharacterVector_wstring() print(res) checkEquals( res, c("foobar", "foobar" ) ) } test.wstring_return <- function(){ - checkEquals( wstring_return(), "foo" ) + checkEquals( wstring_return(), "foo" ) } - + test.wstring_param <- function(){ - checkEquals( wstring_param( "foo", "bar" ), "foobar" ) + checkEquals( wstring_param( "foo", "bar" ), "foobar" ) } test.wrap_vector_wstring <- function(){ - checkEquals( wrap_vector_wstring( ), c("foo", "bar" ) ) + checkEquals( wrap_vector_wstring( ), c("foo", "bar" ) ) } test.as_vector_wstring <- function(){ - checkEquals( as_vector_wstring(letters), paste( letters, "?", sep = "" ) ) + ## the "?" did not survive on Windows, so trying its unicode equivalent + checkEquals( as_vector_wstring(letters), paste0( letters, "\u20ac" ) ) } } From noreply at r-forge.r-project.org Thu Mar 21 20:47:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Mar 2013 20:47:50 +0100 (CET) Subject: [Rcpp-commits] r4290 - in pkg/Rcpp: . inst Message-ID: <20130321194750.7D1F2184867@r-forge.r-project.org> Author: edd Date: 2013-03-21 20:47:50 +0100 (Thu, 21 Mar 2013) New Revision: 4290 Modified: pkg/Rcpp/DESCRIPTION pkg/Rcpp/inst/NEWS.Rd Log: new minor to make it distinct in R-Forge set this (temp.) version in NEWS.Rd too to suppress one warning Modified: pkg/Rcpp/DESCRIPTION =================================================================== --- pkg/Rcpp/DESCRIPTION 2013-03-21 19:29:07 UTC (rev 4289) +++ pkg/Rcpp/DESCRIPTION 2013-03-21 19:47:50 UTC (rev 4290) @@ -1,6 +1,6 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.10.2.7 +Version: 0.10.2.8 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-03-21 19:29:07 UTC (rev 4289) +++ pkg/Rcpp/inst/NEWS.Rd 2013-03-21 19:47:50 UTC (rev 4290) @@ -2,7 +2,7 @@ \title{News for Package 'Rcpp'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} -\section{Changes in Rcpp 0.10.3 (2013-xx-yy)}{ +\section{Changes in Rcpp 0.10.2.8 (2013-03-21)}{ \itemize{ \item Changes in R code: \itemize{ From noreply at r-forge.r-project.org Thu Mar 21 21:10:10 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Mar 2013 21:10:10 +0100 (CET) Subject: [Rcpp-commits] r4291 - pkg/Rcpp/inst Message-ID: <20130321201011.03A81184601@r-forge.r-project.org> Author: edd Date: 2013-03-21 21:10:10 +0100 (Thu, 21 Mar 2013) New Revision: 4291 Modified: pkg/Rcpp/inst/NEWS.Rd Log: corrected section header adding missing 'version' Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-03-21 19:47:50 UTC (rev 4290) +++ pkg/Rcpp/inst/NEWS.Rd 2013-03-21 20:10:10 UTC (rev 4291) @@ -2,7 +2,7 @@ \title{News for Package 'Rcpp'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} -\section{Changes in Rcpp 0.10.2.8 (2013-03-21)}{ +\section{Changes in Rcpp version 0.10.2.8 (2013-03-21)}{ \itemize{ \item Changes in R code: \itemize{ From noreply at r-forge.r-project.org Fri Mar 22 01:42:51 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 22 Mar 2013 01:42:51 +0100 (CET) Subject: [Rcpp-commits] r4292 - pkg/Rcpp/inst/unitTests Message-ID: <20130322004251.B7F39184426@r-forge.r-project.org> Author: edd Date: 2013-03-22 01:42:51 +0100 (Fri, 22 Mar 2013) New Revision: 4292 Modified: pkg/Rcpp/inst/unitTests/runit.wstring.R Log: disabling a test which passes under g++ but not clang Modified: pkg/Rcpp/inst/unitTests/runit.wstring.R =================================================================== --- pkg/Rcpp/inst/unitTests/runit.wstring.R 2013-03-21 20:10:10 UTC (rev 4291) +++ pkg/Rcpp/inst/unitTests/runit.wstring.R 2013-03-22 00:42:51 UTC (rev 4292) @@ -24,12 +24,13 @@ if (.runThisTest) { .setUp <- function(){ + if (!exists("pathRcppTests")) pathRcppTests <- getwd() sourceCpp(file.path(pathRcppTests, "cpp/wstring.cpp")) } test.CharacterVector_wstring <- function(){ res <- CharacterVector_wstring() - print(res) + #print(res) checkEquals( res, c("foobar", "foobar" ) ) } @@ -45,9 +46,9 @@ checkEquals( wrap_vector_wstring( ), c("foo", "bar" ) ) } -test.as_vector_wstring <- function(){ - ## the "?" did not survive on Windows, so trying its unicode equivalent - checkEquals( as_vector_wstring(letters), paste0( letters, "\u20ac" ) ) -} +#test.as_vector_wstring <- function(){ +# ## the "?" did not survive on Windows, so trying its unicode equivalent +# checkEquals( as_vector_wstring(letters), paste0( letters, "\u20ac" ) ) +#} } From noreply at r-forge.r-project.org Sat Mar 23 15:49:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 23 Mar 2013 15:49:01 +0100 (CET) Subject: [Rcpp-commits] r4293 - in pkg/Rcpp: . debian inst Message-ID: <20130323144901.19E91184D4D@r-forge.r-project.org> Author: edd Date: 2013-03-23 15:49:00 +0100 (Sat, 23 Mar 2013) New Revision: 4293 Added: pkg/Rcpp/debian/compat Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/DESCRIPTION pkg/Rcpp/debian/changelog pkg/Rcpp/debian/r-cran-rcpp.lintian-overrides pkg/Rcpp/inst/NEWS.Rd Log: Release 0.10.3 set version in DESCRIPTION, debian/changelog, inst/NEWS.Rd usual updates in debian/* for new build Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-22 00:42:51 UTC (rev 4292) +++ pkg/Rcpp/ChangeLog 2013-03-23 14:49:00 UTC (rev 4293) @@ -1,3 +1,10 @@ +2013-03-23 Dirk Eddelbuettel + + * DESCRIPTION: Release 0.10.3 + * inst/NEWS.Rd: Release 0.10.3 + * inst/include/Rcpp/config.h: Release 0.10.3 + * debian/*: Similarly updated for new release to Debian + 2013-03-21 Dirk Eddelbuettel * inst/unitTests/runit.wstring.R (test.as_vector_wstring): replace @@ -63,7 +70,7 @@ * 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. + * include/Rcpp/internal/wrap.h : more debugging. more dispatch. 2013-02-18 Romain Francois @@ -225,19 +232,19 @@ * 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 + 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 + * 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. + 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 + * 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 @@ -248,13 +255,13 @@ * 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/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 + * include/Rcpp/Language.h : added update_language_object to replace update which was virtual * include/Rcpp/RObject.h : only keep declarations here Modified: pkg/Rcpp/DESCRIPTION =================================================================== --- pkg/Rcpp/DESCRIPTION 2013-03-22 00:42:51 UTC (rev 4292) +++ pkg/Rcpp/DESCRIPTION 2013-03-23 14:49:00 UTC (rev 4293) @@ -1,6 +1,6 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.10.2.8 +Version: 0.10.3 Date: $Date$ Author: Dirk Eddelbuettel and Romain Francois, with contributions by Douglas Bates, John Chambers and JJ Allaire @@ -37,7 +37,7 @@ package development. Attributes are built on top of Rcpp modules and their implementation is based on previous work in the inline package. . - Many examples are included, and over 870 unit tests in over 390 unit + Many examples are included, and over 870 unit tests in over 400 unit test functions provide additional usage examples. . An earlier version of Rcpp, containing what we now call the 'classic Rcpp Modified: pkg/Rcpp/debian/changelog =================================================================== --- pkg/Rcpp/debian/changelog 2013-03-22 00:42:51 UTC (rev 4292) +++ pkg/Rcpp/debian/changelog 2013-03-23 14:49:00 UTC (rev 4293) @@ -1,3 +1,11 @@ +rcpp (0.10.3-1) unstable; urgency=low + + * New release + + * src/Timer.cpp: Changed to permit *BSD builds (Closes: #697032) + + -- Dirk Eddelbuettel Sat, 23 Mar 2013 07:42:26 -0500 + rcpp (0.10.2-1) unstable; urgency=low * New release @@ -9,7 +17,7 @@ * New release * inst/include/Rcpp/iostream/Rostream.h: Additional fix that didn't make - into 0.10.1 + it into 0.10.1 -- Dirk Eddelbuettel Tue, 27 Nov 2012 08:20:54 -0600 Added: pkg/Rcpp/debian/compat =================================================================== --- pkg/Rcpp/debian/compat (rev 0) +++ pkg/Rcpp/debian/compat 2013-03-23 14:49:00 UTC (rev 4293) @@ -0,0 +1 @@ +7 Modified: pkg/Rcpp/debian/r-cran-rcpp.lintian-overrides =================================================================== --- pkg/Rcpp/debian/r-cran-rcpp.lintian-overrides 2013-03-22 00:42:51 UTC (rev 4292) +++ pkg/Rcpp/debian/r-cran-rcpp.lintian-overrides 2013-03-23 14:49:00 UTC (rev 4293) @@ -71,3 +71,4 @@ r-cran-rcpp: script-not-executable usr/lib/R/site-library/Rcpp/examples/Misc/newFib.r r-cran-rcpp: script-not-executable usr/lib/R/site-library/Rcpp/unitTests/runit.rmath.R r-cran-rcpp: script-not-executable usr/lib/R/site-library/Rcpp/unitTests/runit.String.R +r-cran-rcpp: script-not-executable usr/lib/R/site-library/Rcpp/unitTests/runit.wstring.R Modified: pkg/Rcpp/inst/NEWS.Rd =================================================================== --- pkg/Rcpp/inst/NEWS.Rd 2013-03-22 00:42:51 UTC (rev 4292) +++ pkg/Rcpp/inst/NEWS.Rd 2013-03-23 14:49:00 UTC (rev 4293) @@ -2,12 +2,12 @@ \title{News for Package 'Rcpp'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} -\section{Changes in Rcpp version 0.10.2.8 (2013-03-21)}{ +\section{Changes in Rcpp version 0.10.3 (2013-03-23)}{ \itemize{ \item Changes in R code: \itemize{ - \item Prevent build failures when Rcpp is installed in a library - path with spaces on Windows (transform paths in the same manner + \item Prevent build failures on Windowsn when Rcpp is installed + in a library path with spaces (transform paths in the same manner that R does before passing them to the build system). } \item Changes in Rcpp attributes: @@ -39,9 +39,9 @@ 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 As the preserve / release code is still a little rough at - the edges, a new #define is used (in config.h) to disable it for now. + implementation. However, as this preserve / release code is still + a little rough at the edges, a new #define is used (in config.h) + to disable it for now. \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 From noreply at r-forge.r-project.org Wed Mar 27 10:36:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 27 Mar 2013 10:36:19 +0100 (CET) Subject: [Rcpp-commits] r4294 - in pkg/Rcpp: . inst/include/Rcpp/vector Message-ID: <20130327093619.5003E1846DF@r-forge.r-project.org> Author: romain Date: 2013-03-27 10:36:18 +0100 (Wed, 27 Mar 2013) New Revision: 4294 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h Log: removed unintended message Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-23 14:49:00 UTC (rev 4293) +++ pkg/Rcpp/ChangeLog 2013-03-27 09:36:18 UTC (rev 4294) @@ -1,3 +1,8 @@ +2013-03-27 Romain Francois + + * include/Rcpp/vector/MatrixRow.h : removed unintended printed messaged + (reported on Rcpp-devel by Michaeal Love) + 2013-03-23 Dirk Eddelbuettel * DESCRIPTION: Release 0.10.3 Modified: pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h 2013-03-23 14:49:00 UTC (rev 4293) +++ pkg/Rcpp/inst/include/Rcpp/vector/MatrixRow.h 2013-03-27 09:36:18 UTC (rev 4294) @@ -164,8 +164,7 @@ 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 ) ; + RCPP_DEBUG_4( "MatrixRow<%d>::get_parent_index(int = %d), parent_nrow = %d >> %d\n", RTYPE, i, parent_nrow, i*parent_nrow ) return i * parent_nrow ; } } ; From noreply at r-forge.r-project.org Fri Mar 29 08:33:00 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 29 Mar 2013 08:33:00 +0100 (CET) Subject: [Rcpp-commits] r4295 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/api/meat inst/include/Rcpp/traits src Message-ID: <20130329073300.BFB52183E7A@r-forge.r-project.org> Author: romain Date: 2013-03-29 08:33:00 +0100 (Fri, 29 Mar 2013) New Revision: 4295 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/inst/include/Rcpp/DottedPair.h pkg/Rcpp/inst/include/Rcpp/Named.h pkg/Rcpp/inst/include/Rcpp/api/meat/DottedPair.h pkg/Rcpp/inst/include/Rcpp/traits/named_object.h pkg/Rcpp/src/api.cpp Log: fix data frame creation performance issue Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-27 09:36:18 UTC (rev 4294) +++ pkg/Rcpp/ChangeLog 2013-03-29 07:33:00 UTC (rev 4295) @@ -1,3 +1,11 @@ +2013-03-29 Romain Francois + + * include/Rcpp/traits/named_object.h: only keep named_object + * include/Rcpp/Named.h: Named generates named_object + * include/Rcpp/api/meat/DottedPair.h: adapt to changes above + * include/Rcpp/DottedPair.h: idem + * src/api.cpp: define DottedPair::Proxy::operator=( named_object ) + 2013-03-27 Romain Francois * include/Rcpp/vector/MatrixRow.h : removed unintended printed messaged Modified: pkg/Rcpp/inst/include/Rcpp/DottedPair.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/DottedPair.h 2013-03-27 09:36:18 UTC (rev 4294) +++ pkg/Rcpp/inst/include/Rcpp/DottedPair.h 2013-03-29 07:33:00 UTC (rev 4295) @@ -2,7 +2,7 @@ // // DottedPair.h: Rcpp R/C++ interface class library -- dotted pair list template // -// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -110,8 +110,7 @@ template Proxy& operator=(const T& rhs) ; - template - Proxy& operator=(const traits::named_object& rhs) ; + Proxy& operator=(const traits::named_object& rhs) ; template operator T() const ; Modified: pkg/Rcpp/inst/include/Rcpp/Named.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/Named.h 2013-03-27 09:36:18 UTC (rev 4294) +++ pkg/Rcpp/inst/include/Rcpp/Named.h 2013-03-29 07:33:00 UTC (rev 4295) @@ -2,7 +2,7 @@ // // Named.h: Rcpp R/C++ interface class library -- named object // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -30,8 +30,8 @@ Argument( const std::string& name_) : name(name_){} template - inline traits::named_object operator=( const T& t){ - return traits::named_object( name, t ) ; + inline traits::named_object operator=( const T& t){ + return traits::named_object( name, wrap(t) ) ; } std::string name ; @@ -41,8 +41,8 @@ return Argument( name ); } template -inline traits::named_object Named( const std::string& name, const T& o){ - return traits::named_object( name, o ); +inline traits::named_object Named( const std::string& name, const T& o){ + return traits::named_object( name, wrap(o) ); } namespace internal{ Modified: pkg/Rcpp/inst/include/Rcpp/api/meat/DottedPair.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/api/meat/DottedPair.h 2013-03-27 09:36:18 UTC (rev 4294) +++ pkg/Rcpp/inst/include/Rcpp/api/meat/DottedPair.h 2013-03-29 07:33:00 UTC (rev 4295) @@ -2,7 +2,7 @@ // // DottedPair.h: Rcpp R/C++ interface class library -- DottedPair meat // -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -32,11 +32,6 @@ template DottedPair::Proxy::operator T() const{ return as(get()); } - template - DottedPair::Proxy& DottedPair::Proxy::operator=(const traits::named_object& rhs){ - return set( rhs.object, rhs.name.c_str() ) ; - } - template void DottedPair::push_front( const T& object){ setSEXP( grow(object, m_sexp) ) ; Modified: pkg/Rcpp/inst/include/Rcpp/traits/named_object.h =================================================================== --- pkg/Rcpp/inst/include/Rcpp/traits/named_object.h 2013-03-27 09:36:18 UTC (rev 4294) +++ pkg/Rcpp/inst/include/Rcpp/traits/named_object.h 2013-03-29 07:33:00 UTC (rev 4295) @@ -1,9 +1,9 @@ // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- /* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */ // -// has_iterator.h: Rcpp R/C++ interface class library -- identify if a class has a nested iterator typedef +// named_object.h: Rcpp R/C++ interface class library -- named SEXP // -// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -31,20 +31,28 @@ template struct needs_protection : false_type{} ; template <> struct needs_protection : true_type{} ; -template class named_object { - public: - named_object( const std::string& name_, const T& o_) : - name(name_), object(o_){} - const std::string& name ; - const T& object ; - -} ; +template class named_object ; +// { +// public: +// named_object( const std::string& name_, const T& o_) : +// name(name_), object(o_){} +// const std::string& name ; +// const T& object ; +// +// } ; template <> class named_object { public: named_object( const std::string& name_, const SEXP& o_): - name(name_), object(o_){ + name(name_), object(o_) + { R_PreserveObject(object) ; } + + named_object( const named_object& other ) : + name(other.name), object(other.object) + { + R_PreserveObject(object) ; + } ~named_object(){ R_ReleaseObject(object) ; } Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-03-27 09:36:18 UTC (rev 4294) +++ pkg/Rcpp/src/api.cpp 2013-03-29 07:33:00 UTC (rev 4295) @@ -453,7 +453,11 @@ } node = x ; } - + + DottedPair::Proxy& DottedPair::Proxy::operator=(const traits::named_object& rhs){ + return set( rhs.object, rhs.name.c_str() ) ; + } + DottedPair::Proxy& DottedPair::Proxy::operator=(const Proxy& rhs){ return set(rhs) ; } From noreply at r-forge.r-project.org Fri Mar 29 14:37:51 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 29 Mar 2013 14:37:51 +0100 (CET) Subject: [Rcpp-commits] r4296 - in pkg/RcppArmadillo: . inst/include/RcppArmadilloExtensions inst/unitTests Message-ID: <20130329133751.2901D18094B@r-forge.r-project.org> Author: edd Date: 2013-03-29 14:37:50 +0100 (Fri, 29 Mar 2013) New Revision: 4296 Modified: pkg/RcppArmadillo/ChangeLog pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/sample.h pkg/RcppArmadillo/inst/unitTests/runit.sample.R Log: applied another patch by Christian Gunning [mailed to rcpp-devel] for sample() Modified: pkg/RcppArmadillo/ChangeLog =================================================================== --- pkg/RcppArmadillo/ChangeLog 2013-03-29 07:33:00 UTC (rev 4295) +++ pkg/RcppArmadillo/ChangeLog 2013-03-29 13:37:50 UTC (rev 4296) @@ -1,3 +1,9 @@ +2013-03-29 Dirk Eddelbuettel + + * inst/include/RcppArmadilloExtensions/sample.h: Applied another + patch by Christian Gunning + * inst/unitTests/runit.sample.R (test.sample): Idem + 2013-03-12 Dirk Eddelbuettel * DESCRIPTION: Release 0.3.800.1 @@ -5,8 +11,8 @@ * inst/include/*: Upgraded to new release 3.800.1 of Armadillo * inst/unitTests/cpp/armadillo.cpp: Factored out of - runit.RcppArmadillo.R to accelerate unit test run - * inst/unitTests/runit.RcppArmadillo.R: Deploy refactored cpp code + runit.RcppArmadillo.R to accelerate unit test run + * inst/unitTests/runit.RcppArmadillo.R: Deploy refactored cpp code 2013-03-11 Dirk Eddelbuettel Modified: pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/sample.h =================================================================== --- pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/sample.h 2013-03-29 07:33:00 UTC (rev 4295) +++ pkg/RcppArmadillo/inst/include/RcppArmadilloExtensions/sample.h 2013-03-29 13:37:50 UTC (rev 4296) @@ -63,8 +63,14 @@ // Copy the given probabilities into an arma vector arma::vec prob(fixprob.begin(), fixprob.size()); if (replace) { - // check for walker alias conditions here?? - ProbSampleReplace(index, nOrig, size, prob); + // check for walker alias conditions + int walker_test = sum( (probsize * prob) > 0.1); + if (walker_test < 200) { + ProbSampleReplace(index, nOrig, size, prob); + } else { + throw std::range_error( "Walker Alias method not implemented. R-core sample() is likely faster for this problem."); + // WalkerProbSampleReplace(index, nOrig, size, prob); + } } else { ProbSampleNoReplace(index, nOrig, size, prob); } Modified: pkg/RcppArmadillo/inst/unitTests/runit.sample.R =================================================================== --- pkg/RcppArmadillo/inst/unitTests/runit.sample.R 2013-03-29 07:33:00 UTC (rev 4295) +++ pkg/RcppArmadillo/inst/unitTests/runit.sample.R 2013-03-29 13:37:50 UTC (rev 4296) @@ -23,16 +23,6 @@ } test.sample <- function() { - ## Seed needs to be reset to compare R to C++ - seed <- 441 - - ## Input vectors to sample - N <- 100 - - ## Number of samples - ## works for size == N?! - size <- N%/%2 - ## set up S3 dispatching, ## simplifies lapply(tests, ...) below csample <- function(x, ...) UseMethod("csample") @@ -42,6 +32,14 @@ csample.character <- csample_character csample.logical <- csample_logical + ## Seed needs to be reset to compare R to C++ + seed <- 441 + ## Input vectors to sample + N <- 100 + ## Number of samples + ## works for size == N?! + size <- N%/%2 + ## all atomic vector classes except raw ## for each list element, check that sampling works ## with and without replacement, with and without prob @@ -70,18 +68,18 @@ set.seed(seed) r.yes.no <- sample(dat, size, replace=T) set.seed(seed) - r.no.yes <- sample(dat, size, replace=F, prob=1:N) + r.no.yes <- sample(dat, size, replace=F, prob=probs) set.seed(seed) - r.yes.yes <- sample(dat, size, replace=T, prob=1:N) + r.yes.yes <- sample(dat, size, replace=T, prob=probs) ## C set.seed(seed) c.no.no <- csample(dat, size, replace=F) set.seed(seed) c.yes.no <- csample(dat, size, replace=T) set.seed(seed) - c.no.yes <- csample(dat, size, replace=F, prob=1:N) + c.no.yes <- csample(dat, size, replace=F, prob=probs) set.seed(seed) - c.yes.yes <- csample(dat, size, replace=T, prob=1:N) + c.yes.yes <- csample(dat, size, replace=T, prob=probs) ## comparisons checkEquals(r.no.no, c.no.no, msg=sprintf("sample.%s.no_replace.no_prob",.class)) checkEquals(r.yes.no, c.yes.no, msg=sprintf("sample.%s.replace.no_prob",.class)) @@ -89,4 +87,21 @@ checkEquals(r.no.yes, c.no.yes, msg=sprintf("sample.%s.no_replace.prob",.class)) checkEquals(r.yes.yes, c.yes.yes, msg=sprintf("sample.%s.replace.prob",.class)) }) + ## Walker Alias method test + ## With replacement, >200 "nonzero" probabilities + ## Not implemented, see below + walker.N <- 1e3 + walker.sample <- (1:walker.N)/10 + walker.probs <- rep(0.1, walker.N) + ## uncomment following 5 lines if/when walker alias method is implemented + #set.seed(seed) + #r.walker <- sample( walker.sample, walker.N, replace=T, prob=walker.probs) + #set.seed(seed) + #c.walker <- csample( walker.sample, walker.N, replace=T, prob=walker.probs) + #checkEquals(r.walker, c.walker, msg=sprintf("Walker Alias method test")) + ## Walker Alias method is not implemented. + ## For this problem (replace, >200 non-zero probs) R is much faster + ## So throw an error and refuse to proceed + walker.error <- try( csample( walker.sample, walker.N, replace=T, prob=walker.probs), TRUE) + checkEquals(inherits(walker.error, "try-error"), TRUE, msg=sprintf("Walker Alias method test")) } From noreply at r-forge.r-project.org Fri Mar 29 17:19:30 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 29 Mar 2013 17:19:30 +0100 (CET) Subject: [Rcpp-commits] r4297 - in pkg/Rcpp: . src Message-ID: <20130329161930.8C317184A3C@r-forge.r-project.org> Author: edd Date: 2013-03-29 17:19:30 +0100 (Fri, 29 Mar 2013) New Revision: 4297 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/DESCRIPTION pkg/Rcpp/src/api.cpp Log: api.cpp: Re-enable coerce_to_string<>() for real and complex types with Poor Man's Versions (TM) of Rf_EncodeReal and Rf_EncodeComplex which the Powers That Be disallow from being used DESCRIPTION: Call it 0.10.3.1 Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-29 13:37:50 UTC (rev 4296) +++ pkg/Rcpp/ChangeLog 2013-03-29 16:19:30 UTC (rev 4297) @@ -1,3 +1,9 @@ +2013-03-29 Dirk Eddelbuettel + + * src/api.cpp (Rcpp): Re-enable coerce_to_string<>() for real and + complex types with Poor Man's Versions (TM) of Rf_EncodeReal and + Rf_EncodeComplex which the Powers That Be disallow from being used + 2013-03-29 Romain Francois * include/Rcpp/traits/named_object.h: only keep named_object @@ -4,13 +10,14 @@ * include/Rcpp/Named.h: Named generates named_object * include/Rcpp/api/meat/DottedPair.h: adapt to changes above * include/Rcpp/DottedPair.h: idem - * src/api.cpp: define DottedPair::Proxy::operator=( named_object ) + * src/api.cpp: define DottedPair::Proxy::operator=( + named_object ) 2013-03-27 Romain Francois - * include/Rcpp/vector/MatrixRow.h : removed unintended printed messaged - (reported on Rcpp-devel by Michaeal Love) - + * include/Rcpp/vector/MatrixRow.h : removed unintended printed + messaged (reported on Rcpp-devel by Michaeal Love) + 2013-03-23 Dirk Eddelbuettel * DESCRIPTION: Release 0.10.3 Modified: pkg/Rcpp/DESCRIPTION =================================================================== --- pkg/Rcpp/DESCRIPTION 2013-03-29 13:37:50 UTC (rev 4296) +++ pkg/Rcpp/DESCRIPTION 2013-03-29 16:19:30 UTC (rev 4297) @@ -1,6 +1,6 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.10.3 +Version: 0.10.3.1 Date: $Date$ Author: Dirk Eddelbuettel and Romain Francois, with contributions by Douglas Bates, John Chambers and JJ Allaire Modified: pkg/Rcpp/src/api.cpp =================================================================== --- pkg/Rcpp/src/api.cpp 2013-03-29 13:37:50 UTC (rev 4296) +++ pkg/Rcpp/src/api.cpp 2013-03-29 16:19:30 UTC (rev 4297) @@ -3,7 +3,7 @@ // // api.cpp: Rcpp R/C++ interface class library -- Rcpp api // -// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -1706,37 +1706,53 @@ return buffer ; } -// 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 ; -// Rf_formatReal( &x, 1, &w, &d, &e, 0 ) ; -// char* tmp = const_cast( Rf_EncodeReal(x, w, d, e, '.') ); -// return dropTrailing0(tmp, '.'); - -// } -// template <> const char* coerce_to_string(Rcomplex x){ -// int wr, dr, er, wi, di, ei; -// Rf_formatComplex(&x, 1, &wr, &dr, &er, &wi, &di, &ei, 0); -// return Rf_EncodeComplex(x, wr, dr, er, wi, di, ei, '.' ); -// } +template <> const char* coerce_to_string(double x){ + int w,d,e ; + // cf src/main/format.c in R's sources: + // The return values are + // w : the required field width + // d : use %w.df in fixed format, %#w.de in scientific format + // e : use scientific format if != 0, value is number of exp digits - 1 + // + // nsmall specifies the minimum number of decimal digits in fixed format: + // it is 0 except when called from do_format. + Rf_formatReal( &x, 1, &w, &d, &e, 0 ) ; + // we are no longer allowed to use this: + // 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); + return dropTrailing0(tmp, '.'); +} +template <> const char* coerce_to_string(Rcomplex x){ + int wr, dr, er, wi, di, ei; + Rf_formatComplex(&x, 1, &wr, &dr, &er, &wi, &di, &ei, 0); + // 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]; + snprintf(tmp, 127, "%*.*f+%*.*fi", wr, dr, x.r, wi, di, x.i); + return tmp; +} } // internal } // Rcpp From noreply at r-forge.r-project.org Sun Mar 31 17:53:18 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 31 Mar 2013 17:53:18 +0200 (CEST) Subject: [Rcpp-commits] r4298 - in pkg/Rcpp: . debian Message-ID: <20130331155318.880771848BC@r-forge.r-project.org> Author: edd Date: 2013-03-31 17:53:18 +0200 (Sun, 31 Mar 2013) New Revision: 4298 Modified: pkg/Rcpp/ChangeLog pkg/Rcpp/debian/changelog pkg/Rcpp/debian/control Log: Debian build 0.10.3-2 Modified: pkg/Rcpp/ChangeLog =================================================================== --- pkg/Rcpp/ChangeLog 2013-03-29 16:19:30 UTC (rev 4297) +++ pkg/Rcpp/ChangeLog 2013-03-31 15:53:18 UTC (rev 4298) @@ -1,3 +1,9 @@ +2013-03-31 Dirk Eddelbuettel + + * debian/control (Build-Depends): Modified for Debian-only rebuilds + under (rc version of upcoming) R 3.0.0 release + * debian/changelog: Entry for Debian build 0.10.3-2 + 2013-03-29 Dirk Eddelbuettel * src/api.cpp (Rcpp): Re-enable coerce_to_string<>() for real and Modified: pkg/Rcpp/debian/changelog =================================================================== --- pkg/Rcpp/debian/changelog 2013-03-29 16:19:30 UTC (rev 4297) +++ pkg/Rcpp/debian/changelog 2013-03-31 15:53:18 UTC (rev 4298) @@ -1,3 +1,11 @@ +rcpp (0.10.3-2) unstable; urgency=low + + * debian/control: Set Build-Depends: to current R version + + * (Re-)building with R 3.0.0 (beta) + + -- Dirk Eddelbuettel Sat, 30 Mar 2013 18:04:44 -0500 + rcpp (0.10.3-1) unstable; urgency=low * New release Modified: pkg/Rcpp/debian/control =================================================================== --- pkg/Rcpp/debian/control 2013-03-29 16:19:30 UTC (rev 4297) +++ pkg/Rcpp/debian/control 2013-03-31 15:53:18 UTC (rev 4298) @@ -2,7 +2,7 @@ Section: gnu-r Priority: optional Maintainer: Dirk Eddelbuettel -Build-Depends: debhelper (>= 7.0.0), r-base-dev (>= 2.15.2), cdbs +Build-Depends: debhelper (>= 7.0.0), r-base-dev (>= 3.0.0~20130327), cdbs Standards-Version: 3.9.4 Homepage: http://dirk.eddelbuettel.com/code/rcpp.html