[Rinside-commits] r210 - in pkg: . inst inst/examples/mpi

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 20 17:14:35 CEST 2011


Author: edd
Date: 2011-04-20 17:14:35 +0200 (Wed, 20 Apr 2011)
New Revision: 210

Modified:
   pkg/ChangeLog
   pkg/inst/NEWS
   pkg/inst/examples/mpi/rinside_mpi_sample0.cpp
   pkg/inst/examples/mpi/rinside_mpi_sample1.cpp
   pkg/inst/examples/mpi/rinside_mpi_sample2.cpp
   pkg/inst/examples/mpi/rinside_mpi_sample3.cpp
Log:
updates to MPI examples too


Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2011-04-20 03:11:29 UTC (rev 209)
+++ pkg/ChangeLog	2011-04-20 15:14:35 UTC (rev 210)
@@ -1,3 +1,7 @@
+2011-04-20  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/examples/mpi/*cpp: Minor updates and simplifications
+
 2011-04-19  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION: Updated Description, also state current Windows

Modified: pkg/inst/NEWS
===================================================================
--- pkg/inst/NEWS	2011-04-20 03:11:29 UTC (rev 209)
+++ pkg/inst/NEWS	2011-04-20 15:14:35 UTC (rev 210)
@@ -9,6 +9,7 @@
         r-help and r-devel mailing list
 
    o    Some improvements and simplifications throughout examples/standard 
+        as well as examples/mpi/
 
    o    Added this NEWS files -- with entries below summarised from ChangeLog
         and the corresponding blog posts

Modified: pkg/inst/examples/mpi/rinside_mpi_sample0.cpp
===================================================================
--- pkg/inst/examples/mpi/rinside_mpi_sample0.cpp	2011-04-20 03:11:29 UTC (rev 209)
+++ pkg/inst/examples/mpi/rinside_mpi_sample0.cpp	2011-04-20 15:14:35 UTC (rev 210)
@@ -4,7 +4,7 @@
 //
 // This file was contributed by Jianping Hua 
 //
-// Copyright (C) 2010 Jianping Hua, Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2011  Jianping Hua, Dirk Eddelbuettel and Romain Francois
 //
 // GPL'ed 
 
@@ -23,12 +23,12 @@
 
     std::stringstream txt;
     txt << "Hello from node " << myrank         // node information
-        << " of " << nodesize << " nodes!" << std::endl;
-    R.assign( txt.str(), "txt");                // assign string var to R variable 'txt'
+	<< " of " << nodesize << " nodes!" << std::endl;
 
-    std::string evalstr = "cat(txt)";           // show node information
-    R.parseEvalQ(evalstr);                      // eval the init string, ignoring any returns
+    R["txt"] = txt.str();	                // assign string var to R variable 'txt'
 
+    R.parseEvalQ("cat(txt)");                   // eval init string, ignoring any returns
+
     MPI_Finalize();                             // mpi finalization
 
     exit(0);

Modified: pkg/inst/examples/mpi/rinside_mpi_sample1.cpp
===================================================================
--- pkg/inst/examples/mpi/rinside_mpi_sample1.cpp	2011-04-20 03:11:29 UTC (rev 209)
+++ pkg/inst/examples/mpi/rinside_mpi_sample1.cpp	2011-04-20 15:14:35 UTC (rev 210)
@@ -4,7 +4,7 @@
 //
 // This file was contributed by Jianping Hua 
 //
-// Copyright (C) 2010 Jianping Hua, Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2011  Jianping Hua, Dirk Eddelbuettel and Romain Francois
 //
 // GPL'ed 
 
@@ -29,10 +29,9 @@
 
     try {
         RInside R(argc, argv);              // create an embedded R instance
-        SEXP ans;                           // return value
 
         std::stringstream txt;
-        txt << "x <- " << rangeMin << std::endl;
+	txt << "x <- " << rangeMin << std::endl;
         R.parseEvalQ( txt.str() );      // assign x with lower range of uniform distribution
 
         txt << "y <- " << rangeMax << std::endl;
@@ -41,10 +40,8 @@
         txt << "n <- " << sampleSize << std::endl;
         R.parseEvalQ( txt.str() );      // assign n with the size of sample
 
-        std::string evalstr = " mean(runif(n,x,y))";  // sampling, compute the mean
-        ans = R.parseEval(evalstr);     // eval the evalstr string, return results
-        Rcpp::NumericVector m(ans);     // convert SEXP variable to an Rcpp::NumericVector
-
+        std::string evalstr = "mean(runif(n,x,y))";	// sampling, compute the mean
+        Rcpp::NumericVector m = R.parseEval(evalstr);	// eval str, convert result to NumericVector
         sendValue = m( 0 );             // assign the return value to the variable to be gathered
 
         //gather together values from all processes to allvalues

Modified: pkg/inst/examples/mpi/rinside_mpi_sample2.cpp
===================================================================
--- pkg/inst/examples/mpi/rinside_mpi_sample2.cpp	2011-04-20 03:11:29 UTC (rev 209)
+++ pkg/inst/examples/mpi/rinside_mpi_sample2.cpp	2011-04-20 15:14:35 UTC (rev 210)
@@ -4,7 +4,7 @@
 //
 // MPI C++ API version of file contributed by Jianping Hua 
 //
-// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2011  Dirk Eddelbuettel and Romain Francois
 //
 // GPL'ed 
 
@@ -21,12 +21,12 @@
 
     std::stringstream txt;
     txt << "Hello from node " << myrank         // node information
-        << " of " << nodesize << " nodes!" << std::endl;
-    R.assign( txt.str(), "txt");                // assign string var to R variable 'txt'
+	<< " of " << nodesize << " nodes!" << std::endl;
 
-    std::string evalstr = "cat(txt)";           // show node information
-    R.parseEvalQ(evalstr);                      // eval the init string, ignoring any returns
+    R["txt"] = txt.str();	                // assign string var to R variable 'txt'
 
+    R.parseEvalQ("cat(txt)");                   // eval init string, ignoring any returns
+
     MPI::Finalize();                            // mpi finalization
 
     exit(0);

Modified: pkg/inst/examples/mpi/rinside_mpi_sample3.cpp
===================================================================
--- pkg/inst/examples/mpi/rinside_mpi_sample3.cpp	2011-04-20 03:11:29 UTC (rev 209)
+++ pkg/inst/examples/mpi/rinside_mpi_sample3.cpp	2011-04-20 15:14:35 UTC (rev 210)
@@ -4,7 +4,7 @@
 //
 // MPI C++ API version of file contributed by Jianping Hua 
 //
-// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2011  Dirk Eddelbuettel and Romain Francois
 //
 // GPL'ed 
 
@@ -28,7 +28,6 @@
 
     try {
         RInside R(argc, argv);              // create an embedded R instance
-        SEXP ans;                           // return value
 
         std::stringstream txt;
         txt << "x <- " << rangeMin << std::endl;
@@ -40,10 +39,8 @@
         txt << "n <- " << sampleSize << std::endl;
         R.parseEvalQ( txt.str() );      // assign n with the size of sample
 
-        std::string evalstr = " mean(runif(n,x,y))";  // sampling, compute the mean
-        ans = R.parseEval(evalstr);     // eval the evalstr string, return results
-        Rcpp::NumericVector m(ans);     // convert SEXP variable to an Rcpp::NumericVector
-
+        std::string evalstr = "mean(runif(n,x,y))";	// sampling, compute the mean
+        Rcpp::NumericVector m = R.parseEval(evalstr);	// eval str, convert result to NumericVector
         sendValue = m( 0 );             // assign the return value to the variable to be gathered
 
         //gather together values from all processes to allvalues



More information about the Rinside-commits mailing list