[Rcpp-commits] r1604 - in pkg/Rcpp/inst/include/Rcpp/sugar: . operators
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jun 18 16:01:33 CEST 2010
Author: romain
Date: 2010-06-18 16:01:33 +0200 (Fri, 18 Jun 2010)
New Revision: 1604
Added:
pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/divides.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__Vector.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/logical_operators__Vector__primitive.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/not.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/plus.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/r_binary_op.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/times.h
pkg/Rcpp/inst/include/Rcpp/sugar/operators/unary_minus.h
Removed:
pkg/Rcpp/inst/include/Rcpp/sugar/Comparator.h
pkg/Rcpp/inst/include/Rcpp/sugar/Comparator_With_One_Value.h
pkg/Rcpp/inst/include/Rcpp/sugar/divides.h
pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators.h
pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators__Vector__Vector.h
pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators__Vector__primitive.h
pkg/Rcpp/inst/include/Rcpp/sugar/minus.h
pkg/Rcpp/inst/include/Rcpp/sugar/not.h
pkg/Rcpp/inst/include/Rcpp/sugar/plus.h
pkg/Rcpp/inst/include/Rcpp/sugar/r_binary_op.h
pkg/Rcpp/inst/include/Rcpp/sugar/times.h
pkg/Rcpp/inst/include/Rcpp/sugar/unary_minus.h
Modified:
pkg/Rcpp/inst/include/Rcpp/sugar/sugar.h
pkg/Rcpp/inst/include/Rcpp/sugar/sugar_forward.h
Log:
move operators code into the sugar/operators directory
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/Comparator.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/Comparator.h 2010-06-18 13:57:42 UTC (rev 1603)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/Comparator.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -1,54 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// LessThan.h: Rcpp R/C++ interface class library -- vector operators
-//
-// 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__Comparator_h
-#define Rcpp__sugar__Comparator_h
-
-namespace Rcpp{
-namespace sugar{
-
-template <int RTYPE, typename Operator, typename LHS_TYPE, typename RHS_TYPE>
-class Comparator : public ::Rcpp::VectorBase< LGLSXP, true, Comparator<RTYPE,Operator,LHS_TYPE,RHS_TYPE> > {
-public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef r_binary_op<RTYPE,Operator> R_OPERATOR ;
-
- Comparator( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_) :
- op(), lhs(lhs_), rhs(rhs_){}
-
- inline int operator[]( int i ) const {
- return op.compare( lhs[i], rhs[i] ) ;
- }
-
- inline int size() const { return lhs.size() ; }
-
-private:
- R_OPERATOR op ;
- const LHS_TYPE& lhs ;
- const RHS_TYPE& rhs ;
-
-} ;
-
-}
-}
-
-
-#endif
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/Comparator_With_One_Value.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/Comparator_With_One_Value.h 2010-06-18 13:57:42 UTC (rev 1603)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/Comparator_With_One_Value.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -1,56 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// LessThan.h: Rcpp R/C++ interface class library -- vector operators
-//
-// 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__Comparator_With_One_Value_h
-#define Rcpp__sugar__Comparator_With_One_Value_h
-
-namespace Rcpp{
-namespace sugar{
-
-template <int RTYPE, typename Operator, bool na, typename VEC_TYPE>
-class Comparator_With_One_Value : public ::Rcpp::VectorBase< RTYPE, true, Comparator_With_One_Value<RTYPE,Operator,na,VEC_TYPE> > {
-public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef r_binary_op<RTYPE,Operator> R_OPERATOR ;
-
- Comparator_With_One_Value( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
- op(), lhs(lhs_), rhs(rhs_){}
-
- inline int operator[]( int i ) const {
- return op.compare( lhs[i], rhs ) ;
- }
-
- inline int size() const { return lhs.size() ; }
-
-private:
- R_OPERATOR op ;
- const VEC_TYPE& lhs ;
- STORAGE rhs ;
-} ;
-
-} // sugar
-} // Rcpp
-
-
-
-
-
-#endif
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/divides.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/divides.h 2010-06-18 13:57:42 UTC (rev 1603)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/divides.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -1,167 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// .h: Rcpp R/C++ interface class library -- operator/
-//
-// 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__divides_h
-#define Rcpp__sugar__divides_h
-
-namespace Rcpp{
-namespace sugar{
-
- // TODO: what happens in the limits, see what R does
- template <int RTYPE,bool LHS_NA, bool RHS_NA>
- class divides{
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline STORAGE apply( STORAGE lhs, STORAGE rhs) const {
- return traits::is_na<RTYPE>(lhs) ? lhs : ( traits::is_na<RTYPE>(rhs) ? rhs : (lhs / rhs) ) ;
- }
- } ;
- template <int RTYPE,bool RHS_NA>
- class divides<RTYPE,false,RHS_NA>{
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline STORAGE apply( STORAGE lhs, STORAGE rhs) const {
- return traits::is_na<RTYPE>(rhs) ? rhs : (lhs / rhs);
- }
- } ;
- template <int RTYPE,bool LHS_NA>
- class divides<RTYPE,LHS_NA,false>{
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline STORAGE apply( STORAGE lhs, STORAGE rhs) const {
- return traits::is_na<RTYPE>(lhs) ? lhs : (lhs / rhs);
- }
- } ;
- template <int RTYPE>
- class divides<RTYPE,false,false>{
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline STORAGE apply( STORAGE lhs, STORAGE rhs) const {
- return lhs / rhs;
- }
- } ;
-
-
- template <int RTYPE, bool _NA_, typename VEC_TYPE>
- class Divides_Vector_Primitive : public Rcpp::VectorBase<RTYPE,true, Divides_Vector_Primitive<RTYPE,_NA_,VEC_TYPE> > {
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef divides<RTYPE,_NA_,true> OPERATOR ;
-
- Divides_Vector_Primitive( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
- lhs(lhs_), rhs(rhs_), op() {}
-
- inline STORAGE operator[]( int i ) const {
- return op.apply( lhs[i], rhs ) ;
- }
-
- inline int size() const { return lhs.size() ; }
-
-
- private:
- const VEC_TYPE& lhs ;
- STORAGE rhs ;
- OPERATOR op ;
- } ;
-
- template <int RTYPE, bool _NA_, typename VEC_TYPE>
- class Divides_Primitive_Vector : public Rcpp::VectorBase<RTYPE,true, Divides_Primitive_Vector<RTYPE,_NA_,VEC_TYPE> > {
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef divides<RTYPE,_NA_,true> OPERATOR ;
-
- Divides_Primitive_Vector( STORAGE lhs_, const VEC_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_), op() {}
-
- inline STORAGE operator[]( int i ) const {
- return op.apply( lhs, rhs[i] ) ;
- }
-
- inline int size() const { return rhs.size() ; }
-
-
- private:
- STORAGE lhs ;
- const VEC_TYPE& rhs ;
- OPERATOR op ;
- } ;
-
-
- template <int RTYPE, bool LHS_NA, typename LHS_VEC_TYPE, bool RHS_NA, typename RHS_VEC_TYPE >
- class Divides_Vector_Vector : public Rcpp::VectorBase<RTYPE,true, Divides_Vector_Vector<RTYPE,LHS_NA,LHS_VEC_TYPE,RHS_NA,RHS_VEC_TYPE> > {
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef divides<RTYPE,LHS_NA,RHS_NA> OPERATOR ;
-
- Divides_Vector_Vector( const LHS_VEC_TYPE& lhs_, const RHS_VEC_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_), op() {}
-
- inline STORAGE operator[]( int i ) const {
- return op.apply( lhs[i], rhs[i] ) ;
- }
-
- inline int size() const { return lhs.size() ; }
-
- private:
- const LHS_VEC_TYPE& lhs ;
- const RHS_VEC_TYPE& rhs ;
- OPERATOR op ;
- } ;
-}
-}
-
-template <int RTYPE,bool _NA_, typename T>
-inline Rcpp::sugar::Divides_Vector_Primitive< RTYPE , _NA_ , Rcpp::VectorBase<RTYPE,_NA_,T> >
-operator/(
- const Rcpp::VectorBase<RTYPE,_NA_,T>& lhs,
- typename Rcpp::traits::storage_type<RTYPE>::type rhs
-) {
- return Rcpp::sugar::Divides_Vector_Primitive<RTYPE,_NA_, Rcpp::VectorBase<RTYPE,_NA_,T> >( lhs, rhs ) ;
-}
-
-
-template <int RTYPE,bool _NA_, typename T>
-inline Rcpp::sugar::Divides_Primitive_Vector< RTYPE , _NA_ , Rcpp::VectorBase<RTYPE,_NA_,T> >
-operator/(
- typename Rcpp::traits::storage_type<RTYPE>::type lhs,
- const Rcpp::VectorBase<RTYPE,_NA_,T>& rhs
-) {
- return Rcpp::sugar::Divides_Primitive_Vector<RTYPE,_NA_, Rcpp::VectorBase<RTYPE,_NA_,T> >( lhs, rhs ) ;
-}
-
-template <int RTYPE,bool LHS_NA, typename LHS_T, bool RHS_NA, typename RHS_T>
-inline Rcpp::sugar::Divides_Vector_Vector<
- RTYPE ,
- LHS_NA, Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- RHS_NA, Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >
-operator/(
- const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs,
- const Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>& rhs
-) {
- return Rcpp::sugar::Divides_Vector_Vector<
- RTYPE,
- LHS_NA, Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- RHS_NA, Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >( lhs, rhs ) ;
-}
-
-#endif
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators.h 2010-06-18 13:57:42 UTC (rev 1603)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -1,28 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// logical_operators.h: Rcpp R/C++ interface class library -- vector operators
-//
-// 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__logical_operators_h
-#define Rcpp__sugar__logical_operators_h
-
-#include <Rcpp/sugar/logical_operators__Vector__Vector.h>
-#include <Rcpp/sugar/logical_operators__Vector__primitive.h>
-
-#endif
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators__Vector__Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators__Vector__Vector.h 2010-06-18 13:57:42 UTC (rev 1603)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators__Vector__Vector.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -1,153 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// logical_operators__Vector__Vector.h: Rcpp R/C++ interface class library --
-// logical operators for Vector to Vector comparisons
-//
-// 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__logical_operators__Vector__Vector_h
-#define Rcpp__sugar__logical_operators__Vector__Vector_h
-
-/* Vector < Vector */
-template <int RTYPE,bool LHS_NA,typename LHS_T,bool RHS_NA, typename RHS_T>
-inline Rcpp::sugar::Comparator<
- RTYPE ,
- Rcpp::sugar::less<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >
-operator<(
- const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
- const Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>& rhs
- ){
- return Rcpp::sugar::Comparator<
- RTYPE,
- Rcpp::sugar::less<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >(
- lhs, rhs
- ) ;
-}
-/* Vector > Vector */
-template <int RTYPE,bool LHS_NA,typename LHS_T,bool RHS_NA, typename RHS_T>
-inline Rcpp::sugar::Comparator<
- RTYPE ,
- Rcpp::sugar::greater<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >
-operator>(
- const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
- const Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>& rhs
- ){
- return Rcpp::sugar::Comparator<
- RTYPE,
- Rcpp::sugar::greater<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >(
- lhs, rhs
- ) ;
-}
-/* Vector <= Vector */
-template <int RTYPE,bool LHS_NA,typename LHS_T,bool RHS_NA, typename RHS_T>
-inline Rcpp::sugar::Comparator<
- RTYPE ,
- Rcpp::sugar::less_or_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >
-operator<=(
- const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
- const Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>& rhs
- ){
- return Rcpp::sugar::Comparator<
- RTYPE,
- Rcpp::sugar::less_or_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >(
- lhs, rhs
- ) ;
-}
-/* Vector >= Vector */
-template <int RTYPE,bool LHS_NA,typename LHS_T,bool RHS_NA, typename RHS_T>
-inline Rcpp::sugar::Comparator<
- RTYPE ,
- Rcpp::sugar::greater_or_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >
-operator>=(
- const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
- const Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>& rhs
- ){
- return Rcpp::sugar::Comparator<
- RTYPE,
- Rcpp::sugar::greater_or_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >(
- lhs, rhs
- ) ;
-}
-/* Vector == Vector */
-template <int RTYPE,bool LHS_NA,typename LHS_T,bool RHS_NA, typename RHS_T>
-inline Rcpp::sugar::Comparator<
- RTYPE ,
- Rcpp::sugar::equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >
-operator==(
- const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
- const Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>& rhs
- ){
- return Rcpp::sugar::Comparator<
- RTYPE,
- Rcpp::sugar::equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >(
- lhs, rhs
- ) ;
-}
-/* Vector != Vector */
-template <int RTYPE,bool LHS_NA,typename LHS_T,bool RHS_NA, typename RHS_T>
-inline Rcpp::sugar::Comparator<
- RTYPE ,
- Rcpp::sugar::not_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >
-operator!=(
- const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs ,
- const Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>& rhs
- ){
- return Rcpp::sugar::Comparator<
- RTYPE,
- Rcpp::sugar::not_equal<RTYPE>,
- Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >(
- lhs, rhs
- ) ;
-}
-
-#endif
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators__Vector__primitive.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators__Vector__primitive.h 2010-06-18 13:57:42 UTC (rev 1603)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/logical_operators__Vector__primitive.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -1,290 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// logical_operators__Vector__primitive.h: Rcpp R/C++ interface class library --
-// logical operators for Vector to primitive comparisons
-//
-// 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__logical_operators__Vector__primitive_h
-#define Rcpp__sugar__logical_operators__Vector__primitive_h
-
-/* Vector < primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::less<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator<(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
- typename Rcpp::traits::storage_type<RTYPE>::type rhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::less<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::less<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator>(
- typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::less<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-
-
-
-/* Vector > primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::greater<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator>(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
- typename Rcpp::traits::storage_type<RTYPE>::type rhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::greater<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::greater<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator<(
- typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::greater<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-
-
-
-/* Vector <= primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::less_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator<=(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
- typename Rcpp::traits::storage_type<RTYPE>::type rhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::less_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::less_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator>=(
- typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::less_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-
-
-
-
-/* Vector >= primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::greater_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator>=(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
- typename Rcpp::traits::storage_type<RTYPE>::type rhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::greater_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::greater_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator<=(
- typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::greater_or_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-
-
-
-/* Vector == primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator==(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
- typename Rcpp::traits::storage_type<RTYPE>::type rhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator==(
- typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-
-
-
-/* Vector != primitive */
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::not_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator!=(
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs ,
- typename Rcpp::traits::storage_type<RTYPE>::type rhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::not_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-template <int RTYPE, bool na, typename VEC_TYPE>
-inline Rcpp::sugar::Comparator_With_One_Value<
- RTYPE ,
- Rcpp::sugar::not_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >
-operator!=(
- typename Rcpp::traits::storage_type<RTYPE>::type rhs,
- const Rcpp::VectorBase<RTYPE,na,VEC_TYPE>& lhs
- ){
- return Rcpp::sugar::Comparator_With_One_Value<
- RTYPE,
- Rcpp::sugar::not_equal<RTYPE>,
- na,
- Rcpp::VectorBase<RTYPE,na,VEC_TYPE>
- >(
- lhs, rhs
- ) ;
-}
-
-
-#endif
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/minus.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/minus.h 2010-06-18 13:57:42 UTC (rev 1603)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/minus.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -1,167 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// minus.h: Rcpp R/C++ interface class library -- operator-
-//
-// 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__minus_h
-#define Rcpp__sugar__minus_h
-
-namespace Rcpp{
-namespace sugar{
-
- // TODO: what happens in the limits, see what R does
- template <int RTYPE,bool LHS_NA, bool RHS_NA>
- class minus{
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline STORAGE apply( STORAGE lhs, STORAGE rhs) const {
- return traits::is_na<RTYPE>(lhs) ? lhs : ( traits::is_na<RTYPE>(rhs) ? rhs : (lhs - rhs) ) ;
- }
- } ;
- template <int RTYPE,bool RHS_NA>
- class minus<RTYPE,false,RHS_NA>{
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline STORAGE apply( STORAGE lhs, STORAGE rhs) const {
- return traits::is_na<RTYPE>(rhs) ? rhs : (lhs - rhs);
- }
- } ;
- template <int RTYPE,bool LHS_NA>
- class minus<RTYPE,LHS_NA,false>{
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline STORAGE apply( STORAGE lhs, STORAGE rhs) const {
- return traits::is_na<RTYPE>(lhs) ? lhs : (lhs - rhs);
- }
- } ;
- template <int RTYPE>
- class minus<RTYPE,false,false>{
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline STORAGE apply( STORAGE lhs, STORAGE rhs) const {
- return lhs - rhs;
- }
- } ;
-
-
- template <int RTYPE, bool _NA_, typename VEC_TYPE>
- class Minus_Vector_Primitive : public Rcpp::VectorBase<RTYPE,true, Minus_Vector_Primitive<RTYPE,_NA_,VEC_TYPE> > {
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef minus<RTYPE,_NA_,true> OPERATOR ;
-
- Minus_Vector_Primitive( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
- lhs(lhs_), rhs(rhs_), op() {}
-
- inline STORAGE operator[]( int i ) const {
- return op.apply( lhs[i], rhs ) ;
- }
-
- inline int size() const { return lhs.size() ; }
-
-
- private:
- const VEC_TYPE& lhs ;
- STORAGE rhs ;
- OPERATOR op ;
- } ;
-
- template <int RTYPE, bool _NA_, typename VEC_TYPE>
- class Minus_Primitive_Vector : public Rcpp::VectorBase<RTYPE,true, Minus_Primitive_Vector<RTYPE,_NA_,VEC_TYPE> > {
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef minus<RTYPE,_NA_,true> OPERATOR ;
-
- Minus_Primitive_Vector( STORAGE lhs_, const VEC_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_), op() {}
-
- inline STORAGE operator[]( int i ) const {
- return op.apply( lhs, rhs[i] ) ;
- }
-
- inline int size() const { return rhs.size() ; }
-
-
- private:
- STORAGE lhs ;
- const VEC_TYPE& rhs ;
- OPERATOR op ;
- } ;
-
-
- template <int RTYPE, bool LHS_NA, typename LHS_VEC_TYPE, bool RHS_NA, typename RHS_VEC_TYPE >
- class Minus_Vector_Vector : public Rcpp::VectorBase<RTYPE,true, Minus_Vector_Vector<RTYPE,LHS_NA,LHS_VEC_TYPE,RHS_NA,RHS_VEC_TYPE> > {
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef minus<RTYPE,LHS_NA,RHS_NA> OPERATOR ;
-
- Minus_Vector_Vector( const LHS_VEC_TYPE& lhs_, const RHS_VEC_TYPE& rhs_ ) :
- lhs(lhs_), rhs(rhs_), op() {}
-
- inline STORAGE operator[]( int i ) const {
- return op.apply( lhs[i], rhs[i] ) ;
- }
-
- inline int size() const { return lhs.size() ; }
-
- private:
- const LHS_VEC_TYPE& lhs ;
- const RHS_VEC_TYPE& rhs ;
- OPERATOR op ;
- } ;
-}
-}
-
-template <int RTYPE,bool _NA_, typename T>
-inline Rcpp::sugar::Minus_Vector_Primitive< RTYPE , _NA_ , Rcpp::VectorBase<RTYPE,_NA_,T> >
-operator-(
- const Rcpp::VectorBase<RTYPE,_NA_,T>& lhs,
- typename Rcpp::traits::storage_type<RTYPE>::type rhs
-) {
- return Rcpp::sugar::Minus_Vector_Primitive<RTYPE,_NA_, Rcpp::VectorBase<RTYPE,_NA_,T> >( lhs, rhs ) ;
-}
-
-
-template <int RTYPE,bool _NA_, typename T>
-inline Rcpp::sugar::Minus_Primitive_Vector< RTYPE , _NA_ , Rcpp::VectorBase<RTYPE,_NA_,T> >
-operator-(
- typename Rcpp::traits::storage_type<RTYPE>::type lhs,
- const Rcpp::VectorBase<RTYPE,_NA_,T>& rhs
-) {
- return Rcpp::sugar::Minus_Primitive_Vector<RTYPE,_NA_, Rcpp::VectorBase<RTYPE,_NA_,T> >( lhs, rhs ) ;
-}
-
-template <int RTYPE,bool LHS_NA, typename LHS_T, bool RHS_NA, typename RHS_T>
-inline Rcpp::sugar::Minus_Vector_Vector<
- RTYPE ,
- LHS_NA, Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- RHS_NA, Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >
-operator-(
- const Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>& lhs,
- const Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>& rhs
-) {
- return Rcpp::sugar::Minus_Vector_Vector<
- RTYPE,
- LHS_NA, Rcpp::VectorBase<RTYPE,LHS_NA,LHS_T>,
- RHS_NA, Rcpp::VectorBase<RTYPE,RHS_NA,RHS_T>
- >( lhs, rhs ) ;
-}
-
-#endif
Deleted: pkg/Rcpp/inst/include/Rcpp/sugar/not.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/not.h 2010-06-18 13:57:42 UTC (rev 1603)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/not.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -1,108 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// not.h: Rcpp R/C++ interface class library -- unary operator!
-//
-// 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__not_h
-#define Rcpp__sugar__not_h
-
-namespace Rcpp{
-namespace sugar{
-
- template <int RTYPE,bool NA>
- class not_ {
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- inline int apply( STORAGE x ) const {
- return Rcpp::traits::is_na<RTYPE>(x) ? NA_LOGICAL : (x ? FALSE : TRUE) ;
- }
- } ;
- template <int RTYPE>
- class not_<RTYPE,false> {
- public:
- typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
- inline int apply( STORAGE x ) const {
- return x ? FALSE : TRUE ;
- }
- } ;
- template <bool NA>
- class not_<REALSXP,NA>{
- public:
- inline int apply( double x ) const {
- return Rcpp::traits::is_na<REALSXP>( x ) ? NA_LOGICAL : ( (x == 0) ? FALSE : TRUE ) ;
- }
- } ;
- template <>
- class not_<REALSXP,false>{
- public:
- inline int apply( double x ) const {
- return ( x == 0.0 ? FALSE : TRUE ) ;
- }
- } ;
- template <bool NA>
- class not_<CPLXSXP,NA>{
- public:
- inline int apply( Rcomplex x ) const {
- return Rcpp::traits::is_na<CPLXSXP>( x ) ? NA_LOGICAL : ( (x.r == 0.0 & x.i == 0.0 ) ? FALSE : TRUE ) ;
- }
- } ;
- template <>
- class not_<CPLXSXP,false>{
- public:
- inline int apply( Rcomplex x ) const {
- return (x.r == 0.0 & x.i == 0.0 ) ? FALSE : TRUE ;
- }
- } ;
-
-
-
- template <int RTYPE, bool _NA_, typename VEC_TYPE>
- class Not_Vector : public Rcpp::VectorBase<LGLSXP,_NA_, Not_Vector<RTYPE,_NA_,VEC_TYPE> > {
- public:
- typedef typename traits::storage_type<RTYPE>::type STORAGE ;
- typedef not_<RTYPE,_NA_> OPERATOR ;
-
- Not_Vector( const VEC_TYPE& lhs_ ) :
- lhs(lhs_), op() {}
-
- inline STORAGE operator[]( int i ) const {
- return op.apply( lhs[i] ) ;
- }
-
- inline int size() const { return lhs.size() ; }
-
-
- private:
- const VEC_TYPE& lhs ;
- OPERATOR op ;
- } ;
-
-}
-}
-
-template <int RTYPE,bool _NA_, typename T>
-inline Rcpp::sugar::Not_Vector< RTYPE , _NA_ , Rcpp::VectorBase<RTYPE,_NA_,T> >
-operator!(
- const Rcpp::VectorBase<RTYPE,_NA_,T>& x
-) {
- return Rcpp::sugar::Not_Vector<RTYPE,_NA_, Rcpp::VectorBase<RTYPE,_NA_,T> >( x ) ;
-}
-
-
-#endif
Copied: pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator.h (from rev 1602, pkg/Rcpp/inst/include/Rcpp/sugar/Comparator.h)
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/Comparator.h 2010-06-18 14:01:33 UTC (rev 1604)
@@ -0,0 +1,54 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// LessThan.h: Rcpp R/C++ interface class library -- vector operators
+//
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/rcpp -r 1604
More information about the Rcpp-commits
mailing list