[Rcpp-commits] r4601 - in pkg/RcppBDT: . demo inst/include src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 16 02:03:19 CET 2013


Author: edd
Date: 2013-12-16 02:03:19 +0100 (Mon, 16 Dec 2013)
New Revision: 4601

Modified:
   pkg/RcppBDT/DESCRIPTION
   pkg/RcppBDT/demo/RcppBDTpt.R
   pkg/RcppBDT/inst/include/RcppBDTpt.h
   pkg/RcppBDT/src/RcppBDTpt.cpp
Log:
committing a few pending changes, increasing version nb to 0.2.1.5


Modified: pkg/RcppBDT/DESCRIPTION
===================================================================
--- pkg/RcppBDT/DESCRIPTION	2013-11-24 15:34:12 UTC (rev 4600)
+++ pkg/RcppBDT/DESCRIPTION	2013-12-16 01:03:19 UTC (rev 4601)
@@ -1,7 +1,7 @@
 Package: RcppBDT
 Type: Package
 Title: Rcpp bindings for the Boost Date_Time library 
-Version: 0.2.1.4
+Version: 0.2.1.5
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois
 Maintainer: Dirk Eddelbuettel <edd at debian.org>
@@ -14,7 +14,6 @@
  provide supplementary date to/from strings conversion functions. 
 License: GPL (>= 2)
 LazyLoad: yes
-Depends: Rcpp (>= 0.9.15.3), methods
-Imports: methods, Rcpp
+Imports: Rcpp, methods
 LinkingTo: Rcpp
 SystemRequirements: Boost (or the BoostHeaders package)

Modified: pkg/RcppBDT/demo/RcppBDTpt.R
===================================================================
--- pkg/RcppBDT/demo/RcppBDTpt.R	2013-11-24 15:34:12 UTC (rev 4600)
+++ pkg/RcppBDT/demo/RcppBDTpt.R	2013-12-16 01:03:19 UTC (rev 4601)
@@ -22,6 +22,7 @@
 print(pt + 5.005005005)
 print(5.5 + pt)
 
+## Need to make this work too -- second argument is ignored right now
 print(pt + c(5.5, 5.5005))
 
 options(op)

Modified: pkg/RcppBDT/inst/include/RcppBDTpt.h
===================================================================
--- pkg/RcppBDT/inst/include/RcppBDTpt.h	2013-11-24 15:34:12 UTC (rev 4600)
+++ pkg/RcppBDT/inst/include/RcppBDTpt.h	2013-12-16 01:03:19 UTC (rev 4601)
@@ -69,7 +69,8 @@
     friend bdtPt* arith_bdtPt_bdtDu(const bdtPt&,   const bdtDu&,  std::string);
     friend bdtPt* arith_bdtDu_bdtPt(const bdtDu&,   const bdtPt&,  std::string);
     friend bool   compare_bdtPt_bdtPt(const bdtPt&, const bdtPt&,  std::string);
-    friend bdtPt* arith_bdtPt_double(const bdtPt&,  const double&, std::string);
+    //friend bdtPt* arith_bdtPt_double(const bdtPt&,  const double&, std::string);
+    friend bdtPt* arith_bdtPt_double(const bdtPt&,  const std::vector<double>& d, std::string);
     friend bdtPt* arith_double_bdtPt(const double&, const bdtPt&,  std::string);
 };
 

Modified: pkg/RcppBDT/src/RcppBDTpt.cpp
===================================================================
--- pkg/RcppBDT/src/RcppBDTpt.cpp	2013-11-24 15:34:12 UTC (rev 4600)
+++ pkg/RcppBDT/src/RcppBDTpt.cpp	2013-12-16 01:03:19 UTC (rev 4601)
@@ -77,6 +77,8 @@
     return R_NilValue ;
 }
 
+#if 0
+// scalar case
 bdtPt* arith_bdtPt_double(const bdtPt& e1, const double& d, std::string op){
     int secs = static_cast<int>(d);
     int fracs = (d - secs) *  boost::posix_time::time_duration::ticks_per_second();
@@ -91,6 +93,25 @@
     // not reached
     return new bdtPt();
 }
+#endif
+// vector case: e1 could be vector, d could be vector, need to check
+// a) both are vector: same length?
+// b) either one is vector, other is scalar
+// c) both are scalar
+bdtPt* arith_bdtPt_double(const bdtPt& e1, const std::vector<double>& d, std::string op){
+    int secs = static_cast<int>(d[0]);
+    int fracs = (d[0] - secs) *  boost::posix_time::time_duration::ticks_per_second();
+    //REprintf("%f -> %d %d\n", d, secs, fracs);
+    boost::posix_time::time_duration td(0, 0, secs, fracs);
+    if( ! op.compare("+") ){
+        return new bdtPt(e1.m_pt + td);   
+    } else if( ! op.compare("-") ) {
+        return new bdtPt(e1.m_pt - td);
+    }
+    Rf_error("operator not implemented");
+    // not reached
+    return new bdtPt();
+}
 
 bdtPt* arith_double_bdtPt(const double& d, const bdtPt& e1, std::string op){
     int secs = static_cast<int>(d);



More information about the Rcpp-commits mailing list