[Rcpp-commits] r3153 - pkg/RcppEigen/inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 28 01:44:08 CEST 2011


Author: dmbates
Date: 2011-07-28 01:44:07 +0200 (Thu, 28 Jul 2011)
New Revision: 3153

Added:
   pkg/RcppEigen/inst/unitTests/runit.sparse.R
Log:
Separate the tests for sparse matrices.


Added: pkg/RcppEigen/inst/unitTests/runit.sparse.R
===================================================================
--- pkg/RcppEigen/inst/unitTests/runit.sparse.R	                        (rev 0)
+++ pkg/RcppEigen/inst/unitTests/runit.sparse.R	2011-07-27 23:44:07 UTC (rev 3153)
@@ -0,0 +1,43 @@
+#!/usr/bin/r -t
+#
+# Copyright (C)      2011 Douglas Bates, Dirk Eddelbuettel and Romain Francois
+#
+# This file is part of RcppEigen
+#
+# RcppEigen 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.
+#
+# RcppEigen 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 RcppEigen.  If not, see <http://www.gnu.org/licenses/>.
+
+.setUp <- function(){
+    suppressMessages(require(inline))
+}
+
+test.wrapSparse.R <- function(){
+
+    fx <- cxxfunction( , '
+
+    Eigen::SparseMatrix<double>  mm(9,3);
+    mm.reserve(9);
+    for (int j = 0; j < 3; ++j) {
+        mm.startVec(j);
+        for (int i = 3 * j; i < 3 * (j + 1); ++i)
+            mm.insertBack(i, j) = 1.;
+    }
+    mm.finalize();
+    return wrap(mm);
+' , plugin = "RcppEigen" )
+
+    res <- fx()
+    rr <- Matrix::t(as(gl(3,3), "sparseMatrix"))
+    colnames(rr) <- NULL
+    checkEquals( res, rr, msg = "Sparsematrix wrap")
+}



More information about the Rcpp-commits mailing list