[Rcpp-commits] r1397 - in pkg/RcppArmadillo: . inst/include inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 2 13:30:52 CEST 2010
Author: romain
Date: 2010-06-02 13:30:52 +0200 (Wed, 02 Jun 2010)
New Revision: 1397
Modified:
pkg/RcppArmadillo/DESCRIPTION
pkg/RcppArmadillo/NEWS
pkg/RcppArmadillo/inst/include/RcppArmadillo.h
pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h
pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R
Log:
support for wrap( mtOp )
Modified: pkg/RcppArmadillo/DESCRIPTION
===================================================================
--- pkg/RcppArmadillo/DESCRIPTION 2010-06-02 11:20:41 UTC (rev 1396)
+++ pkg/RcppArmadillo/DESCRIPTION 2010-06-02 11:30:52 UTC (rev 1397)
@@ -27,7 +27,7 @@
capabilities of the Rcpp package for seamless R and C++ integration/
License: GPL (>= 2)
LazyLoad: yes
-Depends: R (>= 2.10.0), Rcpp (>= 0.8.0.1)
+Depends: R (>= 2.10.0), Rcpp (>= 0.8.0.2)
LinkingTo: Rcpp
Suggests: inline, RUnit
SystemRequirements: GNU make
Modified: pkg/RcppArmadillo/NEWS
===================================================================
--- pkg/RcppArmadillo/NEWS 2010-06-02 11:20:41 UTC (rev 1396)
+++ pkg/RcppArmadillo/NEWS 2010-06-02 11:30:52 UTC (rev 1397)
@@ -3,6 +3,15 @@
o added RcppArmadillo:::CxxFlags for cases where RcppArmadillo is
not used via a package
+ o upgraded to armadillo 0.9.10 'Chilli Espresso'
+
+ o wrap support for mtOp, i.e. operations involving mixed types such
+ as a complex and an arma::mat, which have been introduced in
+ armadillo 0.9.10
+
+ o Included an inline plugin to support the plugin system introduced
+ in inline 0.3.5
+
0.2.1 2010-05-19
o Bug-fix release permitting compilation on Windows
Modified: pkg/RcppArmadillo/inst/include/RcppArmadillo.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadillo.h 2010-06-02 11:20:41 UTC (rev 1396)
+++ pkg/RcppArmadillo/inst/include/RcppArmadillo.h 2010-06-02 11:30:52 UTC (rev 1397)
@@ -137,6 +137,26 @@
return ::Rcpp::wrap( arma::Mat<typename T1::elem_type>(X) ) ;
}
+ template<typename out_eT, typename T1, typename op_type>
+ SEXP wrap_mtop( const arma::mtOp<out_eT,T1,op_type>& X, ::Rcpp::traits::false_type ){
+ // int n_rows = X.P.n_rows ;
+ // int n_cols = X.P.n_cols ;
+ // typedef typename ::Rcpp::Vector< ::Rcpp::traits::r_sexptype_traits< typename T1::elem_type>::rtype > VECTOR ;
+ // VECTOR res(::Rcpp::Dimension( n_rows , n_cols )) ;
+ // ::arma::Mat<typename T1::elem_type> result( res.begin(), n_rows, n_cols, false ) ;
+ // result = X ;
+ // return res ;
+ return ::Rcpp::wrap( arma::Mat<out_eT>(X) ) ;
+ }
+
+ template<typename out_eT, typename T1, typename op_type>
+ SEXP wrap_mtop( const arma::mtOp<out_eT,T1,op_type>& X, ::Rcpp::traits::true_type ){
+ return ::Rcpp::wrap( arma::Mat<out_eT>(X) ) ;
+ }
+
+
+
+
} // namespace RcppArmadillo
template <typename T1, typename T2, typename glue_type>
@@ -159,6 +179,11 @@
return wrap( arma::Cube<typename T1::elem_type>(X) ) ;
}
+ template<typename out_eT, typename T1, typename op_type>
+ SEXP wrap( const arma::mtOp<out_eT,T1,op_type>& X ){
+ return RcppArmadillo::wrap_mtop( X, typename traits::r_sexptype_needscast<out_eT>::type() ) ;
+ }
+
/* support for Rcpp::as */
namespace traits {
Modified: pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h
===================================================================
--- pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h 2010-06-02 11:20:41 UTC (rev 1396)
+++ pkg/RcppArmadillo/inst/include/RcppArmadilloForward.h 2010-06-02 11:30:52 UTC (rev 1397)
@@ -57,7 +57,10 @@
template <typename T1, typename T2, typename glue_type>
SEXP wrap(const arma::eGlueCube<T1,T2,glue_type>& X ) ;
-
+
+ template<typename out_eT, typename T1, typename op_type>
+ SEXP wrap( const arma::mtOp<out_eT,T1,op_type>& X ) ;
+
namespace traits {
/* support for as */
Modified: pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R
===================================================================
--- pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R 2010-06-02 11:20:41 UTC (rev 1396)
+++ pkg/RcppArmadillo/inst/unitTests/runit.RcppArmadillo.R 2010-06-02 11:30:52 UTC (rev 1397)
@@ -191,3 +191,34 @@
checkEquals( unlist( res ), rep(55.0, 4 ), msg = "as<Row>" )
}
+test.cxmat <- function(){
+
+ fx <- cxxfunction( signature() , '
+
+ arma::cx_mat m1 = arma::eye<arma::cx_mat> ( 3, 3 ) ;
+ arma::cx_fmat m2 = arma::eye<arma::cx_fmat>( 3, 3 ) ;
+ return List::create( _["double"] = m1, _["float"] = m2 ) ;
+
+ ', plugin = "RcppArmadillo" )
+ checkEquals( fx(),
+ list( double = (1+0i)*diag(3), float = (1+0i)*diag(3) ),
+ msg = "support for complex matrices" )
+
+}
+
+test.mtOp <- function(){
+
+ fx <- cxxfunction( signature() , '
+
+ std::complex<double> x( 1.0, 2.0 ) ;
+ arma::mat m1 = arma::eye<arma::mat> ( 3, 3 ) ;
+
+ return wrap( x * m1 ) ;
+
+ ', plugin = "RcppArmadillo" )
+ checkEquals( fx(),
+ (1+2i)*diag(3),
+ msg = "support for mtOp" )
+
+}
+
More information about the Rcpp-commits
mailing list