[Rcpp-commits] r1987 - pkg/Rcpp/inst/include/Rcpp/sugar/functions
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Aug 12 07:30:31 CEST 2010
Author: romain
Date: 2010-08-12 07:30:31 +0200 (Thu, 12 Aug 2010)
New Revision: 1987
Removed:
pkg/Rcpp/inst/include/Rcpp/sugar/functions/abs.h
pkg/Rcpp/inst/include/Rcpp/sugar/functions/ceil.h
pkg/Rcpp/inst/include/Rcpp/sugar/functions/exp.h
pkg/Rcpp/inst/include/Rcpp/sugar/functions/floor.h
Modified:
pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h
pkg/Rcpp/inst/include/Rcpp/sugar/functions/math.h
Log:
generate abs,exp,floor,ceil automatically rather than copy and paste
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/functions/abs.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/abs.h 2010-08-12 05:25:11 UTC (rev 1986)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/abs.h 2010-08-12 05:30:31 UTC (rev 1987)
@@ -1,79 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// abs.h: Rcpp R/C++ interface class library -- abs
-//
-// Copyright (C) 2010 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/>.
-
-#ifndef Rcpp__sugar__abs_h
-#define Rcpp__sugar__abs_h
-
-namespace Rcpp{
-namespace sugar{
-
-template <bool NA, int RTYPE>
-class abs__impl{
-public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- static inline STORAGE get( STORAGE x){
- return Rcpp::traits::is_na<RTYPE>(x) ? NA_INTEGER : ( x > 0 ? x : -x ) ;
- }
-} ;
-
-template <int RTYPE>
-class abs__impl<false,RTYPE>{
-public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- static inline STORAGE get( STORAGE x){
- return ( x > 0 ? x : -x ) ;
- }
-} ;
-
-
-template <int RTYPE, bool NA, typename T>
-class Abs : public Rcpp::VectorBase< RTYPE,NA, Abs<RTYPE,NA,T> > {
-public:
- typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
-
- Abs( const VEC_TYPE& object_ ) : object(object_){}
-
- inline STORAGE operator[]( int i ) const {
- return abs__impl<NA,RTYPE>::get( object[i] );
- }
- inline int size() const { return object.size() ; }
-
-private:
- const VEC_TYPE& object ;
-} ;
-
-} // sugar
-
-template <bool NA, typename T>
-inline sugar::Abs<INTSXP,NA,T> abs( const VectorBase<INTSXP,NA,T>& t){
- return sugar::Abs<INTSXP,NA,T>( t ) ;
-}
-
-template <bool NA, typename T>
-inline sugar::Abs<REALSXP,NA,T> abs( const VectorBase<REALSXP,NA,T>& t){
- return sugar::Abs<REALSXP,NA,T>( t ) ;
-}
-
-
-} // Rcpp
-#endif
-
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/functions/ceil.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/ceil.h 2010-08-12 05:25:11 UTC (rev 1986)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/ceil.h 2010-08-12 05:30:31 UTC (rev 1987)
@@ -1,88 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// ceil.h: Rcpp R/C++ interface class library -- ceil
-//
-// Copyright (C) 2010 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/>.
-
-#ifndef Rcpp__sugar__ceil_h
-#define Rcpp__sugar__ceil_h
-
-namespace Rcpp{
-namespace sugar{
-
-template <bool NA, int RTYPE>
-class ceil__impl{
-public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- static inline double get( STORAGE x){
- return Rcpp::traits::is_na<RTYPE>(x) ? NA_INTEGER : ceil(x) ;
- }
-} ;
-
-template <int RTYPE>
-class ceil__impl<false,RTYPE>{
-public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- static inline double get( STORAGE x){
- return ceil(x) ;
- }
-} ;
-
-
-template <int RTYPE, bool NA, typename T>
-class Ceil : public Rcpp::VectorBase< REALSXP ,NA, Ceil<RTYPE,NA,T> > {
-public:
- typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
-
- Ceil( const VEC_TYPE& object_ ) : object(object_){}
-
- inline double operator[]( int i ) const {
- return ceil__impl<NA,RTYPE>::get( object[i] );
- }
- inline int size() const { return object.size() ; }
-
-private:
- const VEC_TYPE& object ;
-} ;
-
-} // sugar
-
-template <bool NA, typename T>
-inline sugar::Ceil<INTSXP,NA,T> ceil( const VectorBase<INTSXP,NA,T>& t){
- return sugar::Ceil<INTSXP,NA,T>( t ) ;
-}
-
-template <bool NA, typename T>
-inline sugar::Ceil<REALSXP,NA,T> ceil( const VectorBase<REALSXP,NA,T>& t){
- return sugar::Ceil<REALSXP,NA,T>( t ) ;
-}
-
-template <bool NA, typename T>
-inline sugar::Ceil<INTSXP,NA,T> ceiling( const VectorBase<INTSXP,NA,T>& t){
- return sugar::Ceil<INTSXP,NA,T>( t ) ;
-}
-
-template <bool NA, typename T>
-inline sugar::Ceil<REALSXP,NA,T> ceiling( const VectorBase<REALSXP,NA,T>& t){
- return sugar::Ceil<REALSXP,NA,T>( t ) ;
-}
-
-} // Rcpp
-#endif
-
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/functions/exp.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/exp.h 2010-08-12 05:25:11 UTC (rev 1986)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/exp.h 2010-08-12 05:30:31 UTC (rev 1987)
@@ -1,95 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// exp.h: Rcpp R/C++ interface class library -- exp
-//
-// Copyright (C) 2010 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/>.
-
-#ifndef Rcpp__sugar__exp_h
-#define Rcpp__sugar__exp_h
-
-namespace Rcpp{
-namespace sugar{
-
-template <bool NA, int RTYPE>
-class exp__impl{
-public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- static inline double get( STORAGE x){
- return Rcpp::traits::is_na<RTYPE>(x) ? NA_REAL : ::exp(x) ;
- }
-} ;
-
-template <int RTYPE>
-class exp__impl<false,RTYPE>{
-public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- static inline double get( STORAGE x){
- return ::exp(x) ;
- }
-} ;
-
-template <>
-class exp__impl<false,INTSXP>{
-public:
- static inline double get( int x){
- return ::exp( static_cast<double>(x) ) ;
- }
-} ;
-
-template <>
-class exp__impl<true,INTSXP>{
-public:
- static inline double get( int x){
- return Rcpp::traits::is_na<INTSXP>(x) ? NA_REAL : ::exp( static_cast<double>(x) ) ;
- }
-} ;
-
-
-template <int RTYPE, bool NA, typename T>
-class Exp : public Rcpp::VectorBase< REALSXP ,NA, Exp<RTYPE,NA,T> > {
-public:
- typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
-
- Exp( const VEC_TYPE& object_ ) : object(object_){}
-
- inline double operator[]( int i ) const {
- return exp__impl<NA,RTYPE>::get( object[i] );
- }
- inline int size() const { return object.size() ; }
-
-private:
- const VEC_TYPE& object ;
-} ;
-
-} // sugar
-
-template <bool NA, typename T>
-inline sugar::Exp<INTSXP,NA,T> exp( const VectorBase<INTSXP,NA,T>& t){
- return sugar::Exp<INTSXP,NA,T>( t ) ;
-}
-
-template <bool NA, typename T>
-inline sugar::Exp<REALSXP,NA,T> exp( const VectorBase<REALSXP,NA,T>& t){
- return sugar::Exp<REALSXP,NA,T>( t ) ;
-}
-
-
-} // Rcpp
-#endif
-
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/functions/floor.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/floor.h 2010-08-12 05:25:11 UTC (rev 1986)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/floor.h 2010-08-12 05:30:31 UTC (rev 1987)
@@ -1,79 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// floor.h: Rcpp R/C++ interface class library -- floor
-//
-// Copyright (C) 2010 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/>.
-
-#ifndef Rcpp__sugar__floor_h
-#define Rcpp__sugar__floor_h
-
-namespace Rcpp{
-namespace sugar{
-
-template <bool NA, int RTYPE>
-class floor__impl{
-public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- static inline double get( STORAGE x){
- return Rcpp::traits::is_na<RTYPE>(x) ? NA_INTEGER : floor(x) ;
- }
-} ;
-
-template <int RTYPE>
-class floor__impl<false,RTYPE>{
-public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- static inline double get( STORAGE x){
- return floor(x) ;
- }
-} ;
-
-
-template <int RTYPE, bool NA, typename T>
-class Floor : public Rcpp::VectorBase< REALSXP ,NA, Floor<RTYPE,NA,T> > {
-public:
- typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
-
- Floor( const VEC_TYPE& object_ ) : object(object_){}
-
- inline double operator[]( int i ) const {
- return floor__impl<NA,RTYPE>::get( object[i] );
- }
- inline int size() const { return object.size() ; }
-
-private:
- const VEC_TYPE& object ;
-} ;
-
-} // sugar
-
-template <bool NA, typename T>
-inline sugar::Floor<INTSXP,NA,T> floor( const VectorBase<INTSXP,NA,T>& t){
- return sugar::Floor<INTSXP,NA,T>( t ) ;
-}
-
-template <bool NA, typename T>
-inline sugar::Floor<REALSXP,NA,T> floor( const VectorBase<REALSXP,NA,T>& t){
- return sugar::Floor<REALSXP,NA,T>( t ) ;
-}
-
-
-} // Rcpp
-#endif
-
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h 2010-08-12 05:25:11 UTC (rev 1986)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/functions.h 2010-08-12 05:30:31 UTC (rev 1987)
@@ -40,10 +40,6 @@
#include <Rcpp/sugar/functions/pmax.h>
#include <Rcpp/sugar/functions/sign.h>
#include <Rcpp/sugar/functions/diff.h>
-#include <Rcpp/sugar/functions/abs.h>
-#include <Rcpp/sugar/functions/exp.h>
-#include <Rcpp/sugar/functions/floor.h>
-#include <Rcpp/sugar/functions/ceil.h>
#include <Rcpp/sugar/functions/pow.h>
#include <Rcpp/sugar/functions/rep.h>
#include <Rcpp/sugar/functions/rep_len.h>
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/math.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/math.h 2010-08-12 05:25:11 UTC (rev 1986)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/math.h 2010-08-12 05:30:31 UTC (rev 1987)
@@ -25,8 +25,12 @@
SUGAR_MATH_1(acos,::acos)
SUGAR_MATH_1(asin,::asin)
SUGAR_MATH_1(atan,::atan)
+SUGAR_MATH_1(ceil,::ceil)
+SUGAR_MATH_1(ceiling,::ceil)
SUGAR_MATH_1(cos,::cos)
SUGAR_MATH_1(cosh,::cosh)
+SUGAR_MATH_1(exp,::exp)
+SUGAR_MATH_1(floor,::floor)
SUGAR_MATH_1(log,::log)
SUGAR_MATH_1(log10,::log10)
SUGAR_MATH_1(sqrt,::sqrt)
@@ -35,6 +39,8 @@
SUGAR_MATH_1(tan,::tan)
SUGAR_MATH_1(tanh,::tanh)
+SUGAR_MATH_1(abs,::fabs)
+
SUGAR_MATH_1(gamma , ::Rf_gammafn )
SUGAR_MATH_1(lgamma , ::Rf_lgammafn )
SUGAR_MATH_1(digamma , ::Rf_digamma )
More information about the Rcpp-commits
mailing list