[Rcpp-commits] r4045 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/sugar/logical inst/include/Rcpp/vector inst/unitTests inst/unitTests/cpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 26 17:40:40 CET 2012


Author: romain
Date: 2012-11-26 17:40:40 +0100 (Mon, 26 Nov 2012)
New Revision: 4045

Added:
   pkg/Rcpp/inst/unitTests/cpp/sugar.cpp
Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/Vector.h
   pkg/Rcpp/inst/include/Rcpp/sugar/logical/SingleLogicalResult.h
   pkg/Rcpp/inst/include/Rcpp/vector/Matrix.h
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
   pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R
   pkg/Rcpp/inst/unitTests/runit.sugar.R
Log:
fix attempts

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-11-26 13:13:51 UTC (rev 4044)
+++ pkg/Rcpp/ChangeLog	2012-11-26 16:40:40 UTC (rev 4045)
@@ -6,6 +6,10 @@
         pmin_op helper struct is defined (always a struct).
         * include/Rcpp/sugar/functions/pmax.h: same for pmax
         * include/Rcpp/stats/random/rbeta.h: fixed constructor issue
+        * unitTests/runit.sugar.R: rework to use sourceCpp instead of inline
+        * include/Rcpp/vector/Vector.h: added ctor to deal with
+        SingleLogicalResult
+        * include/Rcpp/vector/Matrix.h: another const correctness fix
         
 2012-11-25  JJ Allaire <jj at rstudio.org>
 
@@ -65,7 +69,7 @@
         * include/Rcpp/sugar/functions/mapply/mapply_3.h: more flexible
         * include/Rcpp/vector/Vector.h: More efficient assign_object, which
 	is used in the assignment operator
-        * include/Rcpp/sugar/functions/clip.h: added clip function
+        * include/Rcpp/sugar/functions/clamp.h: added clamp function
 
 2012-11-20  JJ Allaire <jj at rstudio.org>
 

Modified: pkg/Rcpp/inst/include/Rcpp/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Vector.h	2012-11-26 13:13:51 UTC (rev 4044)
+++ pkg/Rcpp/inst/include/Rcpp/Vector.h	2012-11-26 16:40:40 UTC (rev 4045)
@@ -61,7 +61,6 @@
 #include <Rcpp/vector/MatrixColumn.h>
 
 #include <Rcpp/vector/instantiation.h>
-
 #include <Rcpp/vector/string_proxy.h>
 
 #include <Rcpp/vector/LazyVector.h>

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/logical/SingleLogicalResult.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/logical/SingleLogicalResult.h	2012-11-26 13:13:51 UTC (rev 4044)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/logical/SingleLogicalResult.h	2012-11-26 16:40:40 UTC (rev 4045)
@@ -66,12 +66,11 @@
 		return Rcpp::traits::is_na<LGLSXP>( result ) ;
 	}
 	
-	operator SEXP(){
-		apply() ;
-		return Rf_ScalarLogical( result ) ;
+	inline operator SEXP(){
+		return get_sexp() ;
 	}
 	
-	operator bool(){
+	inline operator bool(){
 		conversion_to_bool_is_forbidden<!NA> x ;
 		x.touch() ;
 		return is_true() ;
@@ -84,6 +83,11 @@
 		return result;
 	}
 	
+	inline SEXP get_sexp(){
+	    apply() ;
+	    return Rf_ScalarLogical( result ) ;
+	}
+	
 protected:
 	int result ;
 	inline void set(int x){ result = x ;}

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Matrix.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Matrix.h	2012-11-26 13:13:51 UTC (rev 4044)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Matrix.h	2012-11-26 16:40:40 UTC (rev 4045)
@@ -131,7 +131,7 @@
                                                                   ) ;
     }
         
-    inline Proxy operator()( const size_t& i, const size_t& j) const {
+    inline const_Proxy operator()( const size_t& i, const size_t& j) const {
         return static_cast< const Vector<RTYPE>* >( this )->operator[]( 
                                                                        offset( i, j )
                                                                         ) ;

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-11-26 13:13:51 UTC (rev 4044)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-11-26 16:40:40 UTC (rev 4045)
@@ -139,8 +139,14 @@
     	import_expression<VEC>( other.get_ref() , n ) ;
     }
     
+    // should eally onlu be used for LogicalVector. 
+    template <bool NA, typename T>
+    Vector( const sugar::SingleLogicalResult<NA,T>& obj ) : RObject() {
+    	RObject::setSEXP( r_cast<RTYPE>( const_cast<sugar::SingleLogicalResult<NA,T>&>( obj ) .get_sexp() ) ) ;
+    }
     
     
+    
 private:
 	  
     // TODO: do some dispatch when VEC == Vector so that we use std::copy

Added: pkg/Rcpp/inst/unitTests/cpp/sugar.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/cpp/sugar.cpp	                        (rev 0)
+++ pkg/Rcpp/inst/unitTests/cpp/sugar.cpp	2012-11-26 16:40:40 UTC (rev 4045)
@@ -0,0 +1,543 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// sugar.cpp: Rcpp R/C++ interface class library -- sugar unit tests
+//
+// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+#include <Rcpp.h>
+using namespace Rcpp ;
+
+template <typename T>
+class square : public std::unary_function<T,T> {
+public:
+	T operator()( T t) const { return t*t ; }
+} ;
+
+double raw_square( double x){ return x*x; }
+			
+// [[Rcpp::export]]
+List runit_abs( NumericVector xx, IntegerVector yy ){
+    return List::create( abs(xx), abs(yy) ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_one_less( NumericVector xx ){
+    return all( xx < 5.0 ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_one_greater( NumericVector xx ){
+    return all( xx > 5.0 ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_one_less_or_equal( NumericVector xx ){
+    return all( xx <= 5.0 ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_one_greater_or_equal( NumericVector xx ){
+    return all( xx >= 5.0 ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_one_equal( NumericVector xx ){
+    return all( xx == 5.0 ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_not_equal_one( NumericVector xx ){
+    return all( xx != 5.0 ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_less( NumericVector xx, NumericVector yy){
+    return all( xx < yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_greater( NumericVector xx, NumericVector yy ){
+    return all( xx > yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_less_or_equal( NumericVector xx, NumericVector yy){
+    return all( xx <= yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_greater_or_equal( NumericVector xx, NumericVector yy){
+    return all( xx >= yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_equal( NumericVector xx, NumericVector yy){
+    return all( xx == yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_all_not_equal( NumericVector xx, NumericVector yy){
+    return all( xx != yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_any_less( NumericVector xx, NumericVector yy){
+    return any( xx < yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_any_greater( NumericVector xx, NumericVector yy ){
+    return any( xx > yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_any_less_or_equal( NumericVector xx, NumericVector yy ){
+    return any( xx <= yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_any_greater_or_equal( NumericVector xx, NumericVector yy){
+    return any( xx >= yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_any_equal( NumericVector xx, NumericVector yy){
+    return any( xx == yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_any_not_equal( NumericVector xx, NumericVector yy){
+    return any( xx != yy ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_constructor( NumericVector xx, NumericVector yy ){
+    LogicalVector res( xx < yy ) ;
+    return res ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_assignment( NumericVector xx, NumericVector yy ){
+    LogicalVector res;
+    res = xx < yy ;
+    return res ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_diff( NumericVector xx){
+    NumericVector res = diff( xx );
+    return res ;
+}
+
+// [[Rcpp::export]]
+List runit_exp( NumericVector xx, IntegerVector yy ){
+    return List::create( exp(xx), exp(yy) ) ;
+}
+
+// [[Rcpp::export]]
+List runit_floor( NumericVector xx, IntegerVector yy ){
+    return List::create( floor(xx), floor(yy) ) ;
+}
+
+// [[Rcpp::export]]
+List runit_ceil( NumericVector xx, IntegerVector yy){
+    return List::create( ceil(xx), ceil(yy) ) ;
+}
+
+// [[Rcpp::export]]
+List runit_pow( NumericVector xx, IntegerVector yy){
+    return List::create( pow(xx, 3), pow(yy, 2.3) ) ;
+}
+
+// [[Rcpp::export]]
+List runit_ifelse( NumericVector xx, NumericVector yy){
+    return List::create(
+    	 _["vec_vec" ]  = ifelse( xx < yy, xx*xx, -(yy*yy) ),
+    	 _["vec_prim"]  = ifelse( xx < yy, 1.0  , -(yy*yy) ),
+    	 _["prim_vec"]  = ifelse( xx < yy, xx*xx, 1.0      ),
+    	 _["prim_prim"] = ifelse( xx < yy, 1.0, 2.0        )
+    	) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_isna( NumericVector xx){
+    return wrap( is_na( xx ) ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_isna_isna( NumericVector xx ){
+    return wrap( is_na( is_na( xx ) ) ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_any_isna( NumericVector xx){
+    return any( is_na( xx ) ) ;
+}
+
+// [[Rcpp::export]]
+List runit_lapply( IntegerVector xx){
+    List res = lapply( xx, seq_len );
+    return res ;
+}
+
+// [[Rcpp::export]]
+List runit_minus( IntegerVector xx ){
+    return List::create(
+    	xx - 10,
+    	10 - xx,
+    	xx - xx,
+    	noNA( xx ) - 10,
+    	10 - noNA( xx )
+    	) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_any_equal_not( NumericVector xx, NumericVector yy){
+    return any( !( xx == yy) ) ;
+}
+
+// [[Rcpp::export]]
+List runit_plus( IntegerVector xx ){
+    return List::create(
+    	xx + 10,
+    	10 + xx,
+    	xx + xx,
+    	xx + xx + xx
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_plus_seqlen(){
+    return List::create(
+	    seq_len(10) + 10,
+	    10 + seq_len(10),
+	    seq_len(10) + seq_len(10)
+	    ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_plus_all( IntegerVector xx ){
+    return all( (xx+xx) < 10 ) ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_pmin( NumericVector xx, NumericVector yy ){
+    NumericVector res = pmin( xx, yy );
+	return res ;
+}
+
+// [[Rcpp::export]]
+List runit_pmin_one( NumericVector xx ){
+    return List::create(
+    	pmin( xx, 5),
+    	pmin( 5, xx)
+    	) ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_pmax( NumericVector xx, NumericVector yy ){
+    NumericVector res = pmax( xx, yy );
+    return res ;
+}
+
+// [[Rcpp::export]]
+List runit_pmax_one( NumericVector xx ){
+    return List::create(
+    	pmax( xx, 5),
+    	pmax( 5, xx)
+    	) ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_Range(){
+    NumericVector xx(8) ;
+    xx[ Range(0,3) ] = exp( seq_len(4) ) ;
+    xx[ Range(4,7) ] = exp( - seq_len(4) ) ;
+    return xx ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_sapply( NumericVector xx ){
+    NumericVector res = sapply( xx, square<double>() );
+    return res ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_sapply_rawfun( NumericVector xx){
+    NumericVector res = sapply( xx, raw_square );
+    return res ;
+}
+
+// [[Rcpp::export]]
+LogicalVector runit_sapply_square( NumericVector xx){
+    return all( sapply( xx * xx , square<double>() ) < 10.0 );
+}
+
+// [[Rcpp::export]]
+List runit_sapply_list( IntegerVector xx){
+    List res = sapply( xx, seq_len );
+    return res ;
+}
+
+// [[Rcpp::export]]
+IntegerVector runit_seqalong( NumericVector xx ){
+    IntegerVector res = seq_along( xx );
+    return res ;
+}
+
+// [[Rcpp::export]]
+IntegerVector runit_seqlen(){
+    IntegerVector res = seq_len( 10 );
+	return res ;
+}
+
+// [[Rcpp::export]]
+List runit_sign( NumericVector xx, IntegerVector yy ){
+    return List::create(
+	    sign( xx ),
+	    sign( yy )
+	    ) ;
+}
+
+// [[Rcpp::export]]
+List runit_times( IntegerVector xx ){
+    IntegerVector yy = clone<IntegerVector>( xx ) ;
+    yy[0] = NA_INTEGER ;
+    
+    return List::create(
+        xx * 10,
+        10 * xx,
+        xx * xx,
+        xx * xx * xx,
+        xx * yy,
+        yy * 10,
+        10 * yy,
+        NA_INTEGER * xx
+    ) ;
+}
+
+// [[Rcpp::export]]
+List runit_divides( NumericVector xx ){
+    return List::create(
+    	xx / 10,
+    	10 / xx,
+    	xx / xx
+    	) ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_unary_minus( NumericVector xx){
+    NumericVector yy = - xx ;
+    return yy ;
+}
+
+// [[Rcpp::export]]
+void runit_wrap( NumericVector xx, NumericVector yy, Environment e ){
+    e["foo"] = xx < yy  ;
+}
+
+// [[Rcpp::export]]
+List runit_complex( ComplexVector cx ){
+    return List::create(
+    	_["Re"]    = Re( cx ),
+    	_["Im"]    = Im( cx ),
+    	_["Conj"]  = Conj( cx ),
+    	_["Mod"]   = Mod( cx ),
+    	_["exp"]   = exp( cx ),
+    	_["log"]   = log( cx ),
+    	_["sqrt"]  = sqrt( cx ),
+    	_["cos"]   = cos( cx ),
+    	_["sin"]   = sin( cx ),
+    	_["tan"]   = tan( cx ),
+    	_["acos"]  = acos( cx ),
+    	_["asin"]  = asin( cx ),
+    	_["atan"]  = atan( cx ),
+    	// _["acosh"] = acosh( cx ),
+    	_["asinh"] = asinh( cx ),
+    	_["atanh"] = atanh( cx ),
+    	_["cosh"]  = cosh( cx ),
+    	_["sinh"]  = sinh( cx ),
+    	_["tanh"]  = tanh( cx )
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_rep( IntegerVector xx ){
+    List res = List::create(
+    	_["rep"]      = rep( xx, 3 ),
+    	_["rep_each"] = rep_each( xx, 3 ),
+    	_["rep_len"]  = rep_len( xx, 12 ),
+    	_["rep_prim_double"] = rep( 0.0, 10 )
+    	) ;
+    return res ;
+}
+
+// [[Rcpp::export]]
+IntegerVector runit_rev( IntegerVector xx ){
+    IntegerVector yy = rev( xx * xx );
+    return yy ;
+}
+
+// [[Rcpp::export]]
+NumericMatrix runit_outer( NumericVector xx, NumericVector yy){
+    NumericMatrix m = outer( xx, yy, std::plus<double>() ) ;
+    return m ;
+}
+
+// [[Rcpp::export]]
+List runit_row( NumericMatrix xx ){
+    return List::create(
+    	_["row"] = row( xx ),
+    	_["col"] = col( xx )
+    	 ) ;
+}
+
+// [[Rcpp::export]]
+List runit_head( NumericVector xx ){
+    return List::create(
+    	_["pos"] = head( xx, 5 ),
+    	_["neg"] = head( xx, -5 )
+    ) ;
+}
+
+// [[Rcpp::export]]
+List runit_tail( NumericVector xx ){
+    return List::create(
+    	_["pos"] = tail( xx, 5 ),
+    	_["neg"] = tail( xx, -5 )
+    ) ;
+}
+
+// [[Rcpp::export]]
+List runit_diag( NumericVector xx, NumericMatrix mm ){
+    return List::create(
+    	diag( xx ) ,
+    	diag( mm ),
+    	diag( outer( xx, xx, std::plus<double>() ) )
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_gamma( NumericVector xx ){
+    return List::create(
+    	_["gamma"]      = gamma(xx),
+    	_["lgamma"]     = lgamma(xx),
+    	_["digamma"]    = digamma(xx),
+    	_["trigamma"]   = trigamma(xx),
+    	_["tetragamma"] = tetragamma(xx),
+    	_["pentagamma"] = pentagamma(xx),
+    	_["factorial"]  = factorial(xx),
+    	_["lfactorial"] = lfactorial(xx)
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_choose( NumericVector nn, NumericVector kk ){
+    return List::create(
+    	_["VV"] = choose(nn,kk),
+    	_["PV"] = choose(10.0, kk ),
+    	_["VP"] = choose(nn, 5.0 )
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_lchoose( NumericVector nn, NumericVector kk){
+    return List::create(
+    	_["VV"] = lchoose(nn,kk),
+    	_["PV"] = lchoose(10.0, kk ),
+    	_["VP"] = lchoose(nn, 5.0 )
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_beta( NumericVector nn, NumericVector kk){
+    return List::create(
+    	_["VV"] = beta(nn,kk),
+    	_["PV"] = beta(10.0, kk ),
+    	_["VP"] = beta(nn, 5.0 )
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_psigamma( NumericVector nn, NumericVector kk){
+    return List::create(
+    	_["VV"] = psigamma(nn,kk),
+    	_["PV"] = psigamma(10.0, kk ),
+    	_["VP"] = psigamma(nn, 5.0 )
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_lbeta( NumericVector nn, NumericVector kk){
+    return List::create(
+    	_["VV"] = lbeta(nn,kk),
+    	_["PV"] = lbeta(10.0, kk ),
+    	_["VP"] = lbeta(nn, 5.0 )
+    	) ;
+}
+
+// [[Rcpp::export]]
+List runit_log1p( NumericVector xx){
+    return List::create(
+    	_["log1p"] = log1p(xx),
+    	_["expm1"] = expm1(xx)
+    	) ;
+}
+
+// [[Rcpp::export]]
+double runit_sum( NumericVector xx){
+    return sum( xx ) ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_cumsum( NumericVector xx ){
+    NumericVector res = cumsum( xx ) ;
+    return res ;
+}
+
+// [[Rcpp::export]]
+List runit_asvector( NumericMatrix z, NumericVector x, NumericVector y){
+    return List::create(
+        as_vector( z ),
+        as_vector( outer( x , y , std::plus<double>() ) )
+    ) ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_diff_REALSXP_NA( NumericVector x ){
+    NumericVector res= diff(x) ;
+    return res ;
+}
+
+// [[Rcpp::export]]
+List runit_trunc( NumericVector xx, IntegerVector yy){
+    return List::create(trunc(xx), trunc(yy)) ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_round( NumericVector xx, int d ){
+    NumericVector res = round(xx, d);
+    return res ;
+}
+
+// [[Rcpp::export]]
+NumericVector runit_signif( NumericVector xx, int d ){
+    NumericVector res = signif(xx, d);
+    return res ;
+}
+

Modified: pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R	2012-11-26 13:13:51 UTC (rev 4044)
+++ pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R	2012-11-26 16:40:40 UTC (rev 4045)
@@ -27,7 +27,7 @@
 
 test.RangeIndexer <- function(){
     x <- rnorm(10)
-    checkEquals( RangeIndexer(x), max(x[1:5]) )    
+    checkEquals( RangeIndexer_sugar(x), max(x[1:5]) )    
 }
 
 test.self_match <- function(){

Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.sugar.R	2012-11-26 13:13:51 UTC (rev 4044)
+++ pkg/Rcpp/inst/unitTests/runit.sugar.R	2012-11-26 16:40:40 UTC (rev 4045)
@@ -22,757 +22,44 @@
 
 if (.runThisTest) {
 
-definitions <- function(){
-    list(
-			"runit_abs" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					IntegerVector yy(y) ;
-
-					return List::create( abs(xx), abs(yy) ) ;
-				'
-			),
-			"runit_all_one_less" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return all( xx < 5.0 ) ;
-				'
-			),
-			"runit_all_one_greater" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return all( xx > 5.0 ) ;
-				'
-			),
-			"runit_all_one_less_or_equal" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return all( xx <= 5.0 ) ;
-				'
-			),
-			"runit_all_one_greater_or_equal" = list(
-				signature( x = "numeric" ),
-				'
-				    NumericVector xx(x) ;
-					return all( xx >= 5.0 ) ;
-				'
-			),
-			"runit_all_one_equal" = list(
-				signature( x = "numeric" ),
-				'
-				   	NumericVector xx(x) ;
-					return all( xx == 5.0 ) ;
-				'
-			),
-			"runit_all_not_equal_one" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return all( xx != 5.0 ) ;
-				'
-			),
-			"runit_all_less" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					return all( xx < yy ) ;
-				'
-			),
-			"runit_all_greater" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					return all( xx > yy ) ;
-				'
-			),
-			"runit_all_less_or_equal" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-						NumericVector xx(x) ;
-						NumericVector yy(y) ;
-						return all( xx <= yy ) ;
-				'
-			),
-			"runit_all_greater_or_equal" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					return all( xx >= yy ) ;
-				'
-			),
-			"runit_all_equal" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-						NumericVector xx(x) ;
-						NumericVector yy(y) ;
-						return all( xx == yy ) ;
-				'
-			),
-			"runit_all_not_equal" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-						NumericVector xx(x) ;
-						NumericVector yy(y) ;
-						return all( xx != yy ) ;
-				'
-			),
-			"runit_any_less" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					return any( xx < yy ) ;
-				'
-			),
-			"runit_any_greater" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					return any( xx > yy ) ;
-				'
-			),
-			"runit_any_less_or_equal" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-				NumericVector xx(x) ;
-				NumericVector yy(y) ;
-
-				return any( xx <= yy ) ;
-				'
-			),
-			"runit_any_greater_or_equal" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-				NumericVector xx(x) ;
-				NumericVector yy(y) ;
-
-				return any( xx >= yy ) ;
-				'
-			),
-			"runit_any_equal" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-				NumericVector xx(x) ;
-				NumericVector yy(y) ;
-				return any( xx == yy ) ;
-				'
-			),
-			"runit_any_not_equal" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-				NumericVector xx(x) ;
-				NumericVector yy(y) ;
-				return any( xx != yy ) ;
-				'
-			),
-			"runit_constructor" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					LogicalVector res( xx < yy ) ;
-					return res ;
-				'
-			),
-			"runit_assignment" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					LogicalVector res;
-					res = xx < yy ;
-					return res ;
-				'
-			),
-			"runit_diff" = list(
-				signature( x = "numeric" ) ,
-				'
-					NumericVector xx(x) ;
-					NumericVector res = diff( xx );
-					return res ;
-				'
-			),
-			"runit_exp" = list(
-				signature( x = "numeric", y = "integer" ),
-				'
-					NumericVector xx(x) ;
-					IntegerVector yy(y) ;
-					return List::create( exp(xx), exp(yy) ) ;
-				'
-			),
-			"runit_floor" = list(
-				signature( x = "numeric", y = "integer" ),
-				'
-					NumericVector xx(x) ;
-					IntegerVector yy(y) ;
-					return List::create( floor(xx), floor(yy) ) ;
-				'
-			),
-			"runit_ceil" = list(
-				signature( x = "numeric", y = "integer" ),
-				'
-					NumericVector xx(x) ;
-					IntegerVector yy(y) ;
-					return List::create( ceil(xx), ceil(yy) ) ;
-				'
-			),
-			"runit_pow" = list(
-				signature( x = "numeric", y = "integer" ),
-				'
-					NumericVector xx(x) ;
-					IntegerVector yy(y) ;
-					return List::create( pow(xx, 3), pow(yy, 2.3) ) ;
-				'
-			),
-			"runit_ifelse" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-
-					return List::create(
-						 _["vec_vec" ]  = ifelse( xx < yy, xx*xx, -(yy*yy) ),
-						 _["vec_prim"]  = ifelse( xx < yy, 1.0  , -(yy*yy) ),
-						 _["prim_vec"]  = ifelse( xx < yy, xx*xx, 1.0      ),
-						 _["prim_prim"] = ifelse( xx < yy, 1.0, 2.0        )
-						) ;
-				'
-			),
-			"runit_isna" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return wrap( is_na( xx ) ) ;
-				'
-			),
-			"runit_isna_isna" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return wrap( is_na( is_na( xx ) ) ) ;
-				'
-			) ,
-			"runit_any_isna" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return any( is_na( xx ) ) ;
-				'
-			),
-			"runit_lapply" = list(
-				signature( x = "integer" ),
-				'
-					IntegerVector xx(x) ;
-					List res = lapply( xx, seq_len );
-					return res ;
-				'
-			),
-			"runit_minus" = list(
-				signature( x = "integer" ),
-				'
-					IntegerVector xx(x) ;
-					return List::create(
-						xx - 10,
-						10 - xx,
-						xx - xx,
-						noNA( xx ) - 10,
-						10 - noNA( xx )
-						) ;
-				'
-			),
-			"runit_any_equal_not" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					return any( !( xx == yy) ) ;
-				'
-			),
-			"runit_plus" = list(
-				signature( x = "integer" ),
-				'
-					IntegerVector xx(x) ;
-					return List::create(
-						xx + 10,
-						10 + xx,
-						xx + xx,
-						xx + xx + xx
-						) ;
-				'
-			),
-			"runit_plus_seqlen" = list(
-				signature(),
-				'
-					return List::create(
-						seq_len(10) + 10,
-						10 + seq_len(10),
-						seq_len(10) + seq_len(10)
-						) ;
-				'
-			),
-			"runit_plus_all" = list(
-				signature( x = "integer" ), '
-					IntegerVector xx(x) ;
-					return all( (xx+xx) < 10 ) ;
-				'
-			),
-			"runit_pmin" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					NumericVector res = pmin( xx, yy );
-					return res ;
-				'
-			),
-			"runit_pmin_one" = list(
-				signature( x = "numeric" ), '
-					NumericVector xx(x) ;
-					return List::create(
-						pmin( xx, 5),
-						pmin( 5, xx)
-						) ;
-				'
-			),
-			"runit_pmax" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-						NumericVector xx(x) ;
-						NumericVector yy(y) ;
-						NumericVector res = pmax( xx, yy );
-						return res ;
-				'
-			),
-			"runit_pmax_one" = list(
-				signature( x = "numeric" ),
-				'
-				NumericVector xx(x) ;
-				return List::create(
-					pmax( xx, 5),
-					pmax( 5, xx)
-					) ;
-				'
-			),
-			"runit_Range" = list(
-				signature(  ),
-				'
-					NumericVector xx(8) ;
-					xx[ Range(0,3) ] = exp( seq_len(4) ) ;
-					xx[ Range(4,7) ] = exp( - seq_len(4) ) ;
-					return xx ;
-				'
-			),
-			"runit_sapply" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector res = sapply( xx, square<double>() );
-					return res ;
-				'
-			),
-			"runit_sapply_rawfun" = list(
-				signature( x = "numeric" ), '
-					NumericVector xx(x) ;
-					NumericVector res = sapply( xx, raw_square );
-					return res ;
-				'
-			),
-			"runit_sapply_square" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return all( sapply( xx * xx , square<double>() ) < 10.0 );
-				'
-			),
-			"runit_sapply_list" = list(
-				signature( x = "integer" ), '
-					IntegerVector xx(x) ;
-					List res = sapply( xx, seq_len );
-					return res ;
-				'
-			) ,
-			"runit_seqalong" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					IntegerVector res = seq_along( xx );
-					return res ;
-				'
-			),
-			"runit_seqlen" = list(
-				signature( ),
-				'
-					IntegerVector res = seq_len( 10 );
-					return res ;
-				'
-			) ,
-			"runit_sign" = list(
-				signature( x = "numeric", y = "integer" ), '
-					NumericVector xx(x) ;
-					IntegerVector yy(y) ;
-
-					return List::create(
-						sign( xx ),
-						sign( yy )
-						) ;
-				'
-			),
-			"runit_times" = list(
-				signature( x = "integer" ), '
-					IntegerVector xx(x) ;
-					IntegerVector yy = clone<IntegerVector>( xx ) ;
-					yy[0] = NA_INTEGER ;
-
-					return List::create(
-    			        xx * 10,
-    			        10 * xx,
-    			        xx * xx,
-    			        xx * xx * xx,
-    			        xx * yy,
-    			        yy * 10,
-    			        10 * yy,
-    			        NA_INTEGER * xx
-    			    ) ;
-				'
-			),
-			"runit_divides" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return List::create(
-						xx / 10,
-						10 / xx,
-						xx / xx
-						) ;
-				'
-			),
-			"runit_unary_minus" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy = - xx ;
-					return yy ;
-				'
-			),
-			"runit_wrap" = list(
-				signature( x = "numeric", y = "numeric", env = "environment" ),
-				'
-					NumericVector xx(x) ;
-					NumericVector yy(y) ;
-					Environment e(env) ;
-					e["foo"] = xx < yy  ;
-					return R_NilValue ;
-				'
-			),
-			"runit_complex" = list(
-				signature(x = "complex" ),
-				'
-					ComplexVector cx( x );
-					return List::create(
-						_["Re"]    = Re( cx ),
-						_["Im"]    = Im( cx ),
-						_["Conj"]  = Conj( cx ),
-						_["Mod"]   = Mod( cx ),
-						_["exp"]   = exp( cx ),
-						_["log"]   = log( cx ),
-						_["sqrt"]  = sqrt( cx ),
-						_["cos"]   = cos( cx ),
-						_["sin"]   = sin( cx ),
-						_["tan"]   = tan( cx ),
-						_["acos"]  = acos( cx ),
-						_["asin"]  = asin( cx ),
-						_["atan"]  = atan( cx ),
-						// _["acosh"] = acosh( cx ),
-						_["asinh"] = asinh( cx ),
-						_["atanh"] = atanh( cx ),
-						_["cosh"]  = cosh( cx ),
-						_["sinh"]  = sinh( cx ),
-						_["tanh"]  = tanh( cx )
-						) ;
-				'
-			),
-			"runit_rep" = list(
-				signature( x = "integer" ),
-				'
-				IntegerVector xx(x);
-				List res = List::create(
-					_["rep"]      = rep( xx, 3 ),
-					_["rep_each"] = rep_each( xx, 3 ),
-					_["rep_len"]  = rep_len( xx, 12 ),
-					_["rep_prim_double"] = rep( 0.0, 10 )
-					) ;
-				return res ;
-				'
-				),
-			"runit_rev" = list(
-				signature( x = "integer" ),
-				'
-				IntegerVector xx(x);
-				IntegerVector yy = rev( xx * xx );
-				return yy ;
-				'
-				),
-			"runit_outer" = list(
-				signature( x = "numeric", y = "numeric" ),
-				'
-				NumericVector xx(x) ;
-				NumericVector yy(y);
-				NumericMatrix m = outer( xx, yy, std::plus<double>() ) ;
-				return m ;
-				'		),
-			"runit_row" = list(
-				signature( x = "numeric" ),
-				'
-				NumericMatrix xx(x) ;
-				return List::create(
-					_["row"] = row( xx ),
-					_["col"] = col( xx )
-					) ;
-				'
-			),
-			"runit_head" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return List::create(
-						_["pos"] = head( xx, 5 ),
-						_["neg"] = head( xx, -5 )
-					) ;
-				'
-			),
-			"runit_tail" = list(
-				signature( x = "numeric" ),
-				'
-					NumericVector xx(x) ;
-					return List::create(
-						_["pos"] = tail( xx, 5 ),
-						_["neg"] = tail( xx, -5 )
-					) ;
-				'
-			),
-			"runit_diag" = list(
-				signature( x = "numeric", m = "matrix" ), '
-					NumericVector xx(x) ;
-					NumericMatrix mm(m) ;
-					return List::create(
-						diag( xx ) ,
-						diag( mm ),
-						diag( outer( xx, xx, std::plus<double>() ) )
-						) ;
-				'
-			),
-			"runit_gamma" = list(
-			signature(x = "numeric" ),
-			'
-				NumericVector xx(x) ;
-				return List::create(
-					_["gamma"]      = gamma(xx),
-					_["lgamma"]     = lgamma(xx),
-					_["digamma"]    = digamma(xx),
-					_["trigamma"]   = trigamma(xx),
-					_["tetragamma"] = tetragamma(xx),
-					_["pentagamma"] = pentagamma(xx),
-					_["factorial"]  = factorial(xx),
-					_["lfactorial"] = lfactorial(xx)
-					) ;
-			'),
-			"runit_choose" = list(
-			signature(n = "numeric", k = "numeric" ),
-			'
-				NumericVector nn(n), kk(k) ;
-				return List::create(
-					_["VV"] = choose(nn,kk),
-					_["PV"] = choose(10.0, kk ),
-					_["VP"] = choose(nn, 5.0 )
-					) ;
-			'
-			),
-			"runit_lchoose" = list(
-			signature(n = "numeric", k = "numeric" ),
-			'
-				NumericVector nn(n), kk(k) ;
-				return List::create(
-					_["VV"] = lchoose(nn,kk),
-					_["PV"] = lchoose(10.0, kk ),
-					_["VP"] = lchoose(nn, 5.0 )
-					) ;
-			'
-			),
-			"runit_beta" = list(
-			signature(n = "numeric", k = "numeric" ),
-			'
-				NumericVector nn(n), kk(k) ;
-				return List::create(
-					_["VV"] = beta(nn,kk),
-					_["PV"] = beta(10.0, kk ),
-					_["VP"] = beta(nn, 5.0 )
-					) ;
-			'
-			),
-			"runit_psigamma" = list(
-			signature(n = "numeric", k = "numeric" ),
-			'
-				NumericVector nn(n), kk(k) ;
-				return List::create(
-					_["VV"] = psigamma(nn,kk),
-					_["PV"] = psigamma(10.0, kk ),
-					_["VP"] = psigamma(nn, 5.0 )
-					) ;
-			'
-			),
-			"runit_lbeta" = list(
-			signature(n = "numeric", k = "numeric" ),
-			'
-				NumericVector nn(n), kk(k) ;
-				return List::create(
-					_["VV"] = lbeta(nn,kk),
-					_["PV"] = lbeta(10.0, kk ),
-					_["VP"] = lbeta(nn, 5.0 )
-					) ;
-			'
-			),
-			"runit_log1p" = list(
-			signature(x = "numeric" ),
-			'
-				NumericVector xx(x) ;
-				return List::create(
-					_["log1p"] = log1p(xx),
-					_["expm1"] = expm1(xx)
-					) ;
-			'
-			),
-			"runit_sum" = list(
-			   signature( x = "numeric" ),
-			   '
-			   NumericVector xx(x) ;
-			   double res = sum( xx ) ;
-			   return wrap( res ) ;
-			   '
-			),
-			"runit_cumsum" = list(
-			   signature( x = "numeric" ),
-			   '
-			   NumericVector xx(x) ;
-			   NumericVector res = cumsum( xx ) ;
-			   return res ;
-			   '
-			),
-			"runit_asvector" = list(
-			    signature( x = "numeric", y = "numeric", z = "matrix" ),
-			    '
-			    return List::create(
-			        as_vector( NumericMatrix(z) ),
-			        as_vector( outer( NumericVector(x) , NumericVector(y) , std::plus<double>() ) )
-			    ) ;
-			    '
-			),
-			"runit_diff_REALSXP_NA" = list(
-			    signature( x_= "numeric" ),
-			    '
-			         NumericVector x(x_) ;
-			         NumericVector res= diff(x) ;
-			         return res ;
-			    '
-			),
-			"runit_trunc" = list(
-                        	signature( x = "numeric", y = "integer" ),
-                        	'
-					NumericVector xx(x) ;
-					IntegerVector yy(y) ;
-					return List::create(trunc(xx), trunc(yy)) ;
-				'
-			),
-			"runit_round" = list(
-                        	signature( x = "numeric", ds = "integer" ),
-                        	'
-					NumericVector xx(x);
-					int d = as<int>(ds);
-					return wrap(round(xx, d));
-				'
-			),
-			"runit_signif" = list(
-                        	signature( x = "numeric", ds = "integer" ),
-                        	'
-					NumericVector xx(x);
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rcpp -r 4045


More information about the Rcpp-commits mailing list