[Rcpp-commits] r989 - in pkg/RcppArmadillo: inst/include src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 5 18:32:38 CEST 2010


Author: romain
Date: 2010-04-05 18:32:37 +0200 (Mon, 05 Apr 2010)
New Revision: 989

Removed:
   pkg/RcppArmadillo/inst/include/RcppArmadilloDefines.h
Modified:
   pkg/RcppArmadillo/inst/include/RcppArmadillo.h
   pkg/RcppArmadillo/src/fastLm.cpp
Log:
remove conditional compiling since we now include armadillo

Modified: pkg/RcppArmadillo/inst/include/RcppArmadillo.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadillo.h	2010-04-05 13:22:58 UTC (rev 988)
+++ pkg/RcppArmadillo/inst/include/RcppArmadillo.h	2010-04-05 16:32:37 UTC (rev 989)
@@ -24,7 +24,6 @@
 
 #include <RcppCommon.h>
 #include <armadillo>
-#include <RcppArmadilloDefines.h>
 
 /* forward declarations */
 namespace Rcpp {
@@ -33,17 +32,14 @@
     template <typename T> SEXP wrap ( const arma::Row<T>& ) ;
     template <typename T> SEXP wrap ( const arma::Col<T>& ) ;
     template <typename T> SEXP wrap ( const arma::field<T>& ) ;
-    #if ARMA_VERSION_GE_070
     template <typename T> SEXP wrap ( const arma::Cube<T>& ) ;
-    #endif
-
+    
     template <typename T1, typename T2, typename glue_type> 
     SEXP wrap(const arma::Glue<T1, T2, glue_type>& X ) ;
     
     template <typename T1, typename op_type>
     SEXP wrap(const arma::Op<T1, op_type>& X ) ;
     
-    #if ARMA_VERSION_GE_090
     template <typename T1, typename T2, typename glue_type> 
     SEXP wrap(const arma::eGlue<T1, T2, glue_type>& X ) ;
     
@@ -62,7 +58,6 @@
     
     template <typename T1, typename T2, typename glue_type>
     SEXP wrap(const arma::eGlueCube<T1,T2,glue_type>& X ) ;
-    #endif 
     
     namespace traits {
 
@@ -71,9 +66,7 @@
 	template <typename T> class Exporter< arma::Row<T> > ;
 	template <typename T> class Exporter< arma::Col<T> > ;
 // template <typename T> class Exporter< arma::field<T> > ;
-// #ifdef ARMA_VERSION_GE_070
-// 	template <typename T> class Exporter< arma::Cube<T> > ;
-// #endif
+// template <typename T> class Exporter< arma::Cube<T> > ;
 
     } // namespace traits 
 
@@ -113,12 +106,10 @@
 	return RcppArmadillo::arma_wrap(data, Dimension( 1, data.n_elem ) ) ;
     }
 
-    #if ARMA_VERSION_GE_070
     template <typename T> SEXP wrap( const arma::Cube<T>& data ){
 	return RcppArmadillo::arma_wrap(data, Dimension(  data.n_rows, data.n_cols, data.n_slices ) ) ;
     }
-    #endif
-
+    
     namespace RcppArmadillo {
 	
 	/* Importer class for field<T> */
@@ -154,9 +145,6 @@
     	    return wrap( arma::Mat<typename T1::elem_type>(X) ) ;
     }
     
-    /* TODO: will do better when I can use 0.9.0 */
-    #if ARMA_VERSION_GE_090
-    
     template <typename T1, typename op_type>
     SEXP wrap(const arma::OpCube<T1,op_type>& X ){
     	return wrap( arma::Cube<typename T1::elem_type>(X) ) ;
@@ -224,8 +212,7 @@
     SEXP wrap(const arma::eGlueCube<T1,T2,glue_type>& X ){
     	return wrap( arma::Cube<typename T1::elem_type>(X) ) ;
     }
-    #endif
-
+    
     /* support for Rcpp::as */
 
     namespace traits {

Deleted: pkg/RcppArmadillo/inst/include/RcppArmadilloDefines.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadilloDefines.h	2010-04-05 13:22:58 UTC (rev 988)
+++ pkg/RcppArmadillo/inst/include/RcppArmadilloDefines.h	2010-04-05 16:32:37 UTC (rev 989)
@@ -1,36 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RcppArmadilloDefines.h: Configure-generated defines for Rcpp/Armadillo glue
-//
-// Copyright (C)  2010 Dirk Eddelbuettel and Romain Francois
-//
-// 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 <http://www.gnu.org/licenses/>.
-
-#ifndef RcppArmadillo__RcppArmadilloDefines__H
-#define RcppArmadillo__RcppArmadilloDefines__H
-
-//#define ARMA_VERSION_GE_070 @ARMA_VERSION_GE_070@
-#define ARMA_VERSION_GE_070 1
-//#define ARMA_VERSION_GE_090 @ARMA_VERSION_GE_090@
-#define ARMA_VERSION_GE_090 1
-
-#if ARMA_VERSION_GE_090
-#define SCALAR(X) ::arma::as_scalar(X)
-#else
-#define SCALAR(X) X
-#endif
-
-#endif

Modified: pkg/RcppArmadillo/src/fastLm.cpp
===================================================================
--- pkg/RcppArmadillo/src/fastLm.cpp	2010-04-05 13:22:58 UTC (rev 988)
+++ pkg/RcppArmadillo/src/fastLm.cpp	2010-04-05 16:32:37 UTC (rev 989)
@@ -27,29 +27,15 @@
     Rcpp::NumericMatrix Xr(Xs);			// creates Rcpp matrix from SEXP
     int n = Xr.nrow(), k = Xr.ncol();
 
-#if ARMA_VERSION_GE_090
     arma::mat X(Xr.begin(), n, k, false);   	// reuses memory and avoids extra copy
     arma::colvec y(yr.begin(), yr.size(), false);
-#else
-    arma::mat X(Xr.begin(), n, k);
-    arma::colvec y(yr.begin(), yr.size());
-#endif
 
 	arma::colvec coef = arma::solve(X, y);            // fit model y ~ X
 	arma::colvec resid = y - X*coef; 		// residuals
 
-#if ARMA_VERSION_GE_090
 	double sig2 = arma::as_scalar( arma::trans(resid)*resid/(n-k) );
-#else
-	double sig2 = ( arma::trans(resid)*resid/(n-k) );
-#endif
     						// std.error of estimate 
-#if ARMA_VERSION_GE_090
     arma::colvec stderrest = arma::sqrt( sig2 * arma::diagvec( arma::inv(arma::trans(X)*X)) );
-#else
-    arma::mat xtxinv = arma::inv(arma::trans(X)*X);
-    arma::colvec stderrest = arma::sqrt( sig2 * xtxinv.diag() );
-#endif
 
     return Rcpp::List::create( 
     	Rcpp::Named("coefficients") = coef,



More information about the Rcpp-commits mailing list