[Rcpp-commits] r495 - in pkg/inst: . unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 28 00:27:58 CET 2010
Author: edd
Date: 2010-01-28 00:27:52 +0100 (Thu, 28 Jan 2010)
New Revision: 495
Added:
pkg/inst/unitTests/runit.RcppMatrix.R
pkg/inst/unitTests/runit.RcppMatrixView.R
Modified:
pkg/inst/ChangeLog
Log:
two more unit tests
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2010-01-27 22:24:43 UTC (rev 494)
+++ pkg/inst/ChangeLog 2010-01-27 23:27:52 UTC (rev 495)
@@ -1,3 +1,8 @@
+2010-01-27 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/unitTests/runit.RcppMatrix.R: added
+ * inst/unitTests/runit.RcppMatrixView.R: added
+
2010-01-27 Romain Francois <francoisromain at free.fr>
* src/Rcpp/CharacterVector.h: CharacterVector gains a default
@@ -2,7 +7,7 @@
constructor
-
+
* src/Rcpp/CharacterVector.h: CharacterVector gains range
- constructors and range based assign methods facilitating
+ constructors and range based assign methods facilitating
construction from iterators
-
+
* inst/unitTests/runit.CharacterVector.R: unit tests for assign
@@ -13,8 +18,8 @@
* src/Rcpp/CharacterVector.h: CharacterVector::StringProxy
gets a printing operator <<(std::ostream& )
- * src/Rcpp/Environment.h: removed the static
- Environment::RCPP_NAMESPACE which caused problems when
+ * src/Rcpp/Environment.h: removed the static
+ Environment::RCPP_NAMESPACE which caused problems when
embedding R
* src/Rcpp/RObject.h: RObject::AttributeProxy::operator RObject
Added: pkg/inst/unitTests/runit.RcppMatrix.R
===================================================================
--- pkg/inst/unitTests/runit.RcppMatrix.R (rev 0)
+++ pkg/inst/unitTests/runit.RcppMatrix.R 2010-01-27 23:27:52 UTC (rev 495)
@@ -0,0 +1,67 @@
+#!/usr/bin/r -t
+#
+# 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/>.
+
+.setUp <- function(){
+ suppressMessages( require( inline ) )
+}
+
+test.RcppMatrix.int <- function() {
+ src <- 'RcppMatrix<int> m(x);
+ RcppResultSet rs;
+ rs.add("dim1", m.getDim1());
+ rs.add("dim2", m.getDim2());
+ rs.add("rows", m.rows());
+ rs.add("cols", m.cols());
+ rs.add("p22", m(1,1));
+ return rs.getReturnList();';
+ funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
+ checkEquals(funx(x=matrix(1:6,2,3,byrow=TRUE)),
+ list(dim1=2, dim2=3, rows=2, cols=3, p22=5),
+ msg = "RcppMatrix.int")
+}
+
+test.RcppMatrix.double <- function() {
+ src <- 'RcppMatrix<double> m(x);
+ RcppResultSet rs;
+ rs.add("dim1", m.getDim1());
+ rs.add("dim2", m.getDim2());
+ rs.add("rows", m.rows());
+ rs.add("cols", m.cols());
+ rs.add("p22", m(1,1));
+ return rs.getReturnList();';
+ funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
+ checkEquals(funx(x=matrix(1:6,2,3,byrow=TRUE)),
+ list(dim1=2, dim2=3, rows=2, cols=3, p22=5),
+ msg = "RcppMatrix.double")
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Added: pkg/inst/unitTests/runit.RcppMatrixView.R
===================================================================
--- pkg/inst/unitTests/runit.RcppMatrixView.R (rev 0)
+++ pkg/inst/unitTests/runit.RcppMatrixView.R 2010-01-27 23:27:52 UTC (rev 495)
@@ -0,0 +1,67 @@
+#!/usr/bin/r -t
+#
+# 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/>.
+
+.setUp <- function(){
+ suppressMessages( require( inline ) )
+}
+
+test.RcppMatrixView.int <- function() {
+ src <- 'RcppMatrixView<int> m(x);
+ RcppResultSet rs;
+ rs.add("dim1", m.dim1());
+ rs.add("dim2", m.dim2());
+ rs.add("rows", m.rows());
+ rs.add("cols", m.cols());
+ rs.add("p22", m(1,1));
+ return rs.getReturnList();';
+ funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
+ checkEquals(funx(x=matrix(1:6,2,3,byrow=TRUE)),
+ list(dim1=2, dim2=3, rows=2, cols=3, p22=5),
+ msg = "RcppViewMatrix.int")
+}
+
+test.RcppMatrixView.double <- function() {
+ src <- 'RcppMatrixView<double> m(x);
+ RcppResultSet rs;
+ rs.add("dim1", m.dim1());
+ rs.add("dim2", m.dim2());
+ rs.add("rows", m.rows());
+ rs.add("cols", m.cols());
+ rs.add("p22", m(1,1));
+ return rs.getReturnList();';
+ funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
+ checkEquals(funx(x=matrix(1.0*(1:6),2,3,byrow=TRUE)),
+ list(dim1=2, dim2=3, rows=2, cols=3, p22=5),
+ msg = "RcppMatrixView.double")
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
More information about the Rcpp-commits
mailing list