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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 3 10:43:55 CET 2010


Author: romain
Date: 2010-03-03 10:43:55 +0100 (Wed, 03 Mar 2010)
New Revision: 826

Modified:
   pkg/RcppArmadillo/inst/ChangeLog
   pkg/RcppArmadillo/inst/include/RcppArmadilloDefines.h.in
   pkg/RcppArmadillo/src/RcppArmadillo.cpp
Log:
fix for 'run-time error: matrix multiply: incompatible matrix dimensions: (1,1) and (2,2)' in fastLm

Modified: pkg/RcppArmadillo/inst/ChangeLog
===================================================================
--- pkg/RcppArmadillo/inst/ChangeLog	2010-03-03 09:36:43 UTC (rev 825)
+++ pkg/RcppArmadillo/inst/ChangeLog	2010-03-03 09:43:55 UTC (rev 826)
@@ -3,6 +3,11 @@
 	* inst/include/RcppArmadillo.h: avoid an extra memory copy when 
 	possible (i.e. in wrap( eGlue) and wrap( eOp ) when the elem_type
 	is int or double).
+
+	* inst/include/RcppArmadilloDefines.in.h added the SCALAR macro 
+	to take care of the 0.9.0 api change
+
+	* src/RcppArmadillo.cpp : fix a runtime error uisng the SCALAR macro
 	
 2010-03-02  Dirk Eddelbuettel  <edd at dexter>
 

Modified: pkg/RcppArmadillo/inst/include/RcppArmadilloDefines.h.in
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadilloDefines.h.in	2010-03-03 09:36:43 UTC (rev 825)
+++ pkg/RcppArmadillo/inst/include/RcppArmadilloDefines.h.in	2010-03-03 09:43:55 UTC (rev 826)
@@ -20,5 +20,16 @@
 // 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_090 @ARMA_VERSION_GE_090@
+
+#ifdef ARMA_VERSION_GE_090
+#define SCALAR(X) ::arma::as_scalar(X)
+#else
+#define SCALAR(X) X
+#endif
+
+#endif

Modified: pkg/RcppArmadillo/src/RcppArmadillo.cpp
===================================================================
--- pkg/RcppArmadillo/src/RcppArmadillo.cpp	2010-03-03 09:36:43 UTC (rev 825)
+++ pkg/RcppArmadillo/src/RcppArmadillo.cpp	2010-03-03 09:43:55 UTC (rev 826)
@@ -198,7 +198,8 @@
 
     arma::colvec resid = y - X*coef; 
 
-    arma::mat covmat = trans(resid) * resid / (n-k) * arma::inv(arma::trans(X)*X);
+    double sig2 = SCALAR( trans(resid)*resid/(n-k) );
+    arma::mat covmat = sig2 * arma::inv(arma::trans(X)*X);
     arma::colvec stderrest = sqrt(covmat.diag());
 
     Rcpp::Pairlist res(Rcpp::Named( "coef", coef),



More information about the Rcpp-commits mailing list