[mlpack-svn] r15504 - in mlpack/trunk/src/mlpack/methods: emst gmm hmm lars linear_regression lsh naive_bayes neighbor_search range_search rann

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Jul 18 15:47:38 EDT 2013


Author: rcurtin
Date: Thu Jul 18 15:47:37 2013
New Revision: 15504

Log:
Remove c_str() where possible.


Modified:
   mlpack/trunk/src/mlpack/methods/emst/emst_main.cpp
   mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp
   mlpack/trunk/src/mlpack/methods/hmm/hmm_train_main.cpp
   mlpack/trunk/src/mlpack/methods/lars/lars_main.cpp
   mlpack/trunk/src/mlpack/methods/linear_regression/linear_regression_main.cpp
   mlpack/trunk/src/mlpack/methods/lsh/lsh_main.cpp
   mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_main.cpp
   mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_main.cpp
   mlpack/trunk/src/mlpack/methods/range_search/range_search_main.cpp
   mlpack/trunk/src/mlpack/methods/rann/allkrann_main.cpp

Modified: mlpack/trunk/src/mlpack/methods/emst/emst_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/emst/emst_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/emst/emst_main.cpp	Thu Jul 18 15:47:37 2013
@@ -55,7 +55,7 @@
   Log::Info << "Reading in data.\n";
 
   arma::mat dataPoints;
-  data::Load(dataFilename.c_str(), dataPoints, true);
+  data::Load(dataFilename, dataPoints, true);
 
   // Do naive.
   if (CLI::GetParam<bool>("naive"))
@@ -69,7 +69,7 @@
 
     std::string outputFilename = CLI::GetParam<std::string>("output_file");
 
-    data::Save(outputFilename.c_str(), naiveResults, true);
+    data::Save(outputFilename, naiveResults, true);
   }
   else
   {
@@ -96,7 +96,7 @@
     //////////////// Output the Results ////////////////
     std::string outputFilename = CLI::GetParam<std::string>("output_file");
 
-    data::Save(outputFilename.c_str(), results, true);
+    data::Save(outputFilename, results, true);
   }
 
   return 0;

Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp	Thu Jul 18 15:47:37 2013
@@ -73,7 +73,7 @@
     math::RandomSeed((size_t) std::time(NULL));
 
   arma::mat dataPoints;
-  data::Load(CLI::GetParam<std::string>("input_file").c_str(), dataPoints,
+  data::Load(CLI::GetParam<std::string>("input_file"), dataPoints,
       true);
 
   const int gaussians = CLI::GetParam<int>("gaussians");

Modified: mlpack/trunk/src/mlpack/methods/hmm/hmm_train_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/hmm/hmm_train_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/hmm/hmm_train_main.cpp	Thu Jul 18 15:47:37 2013
@@ -177,7 +177,7 @@
   {
     // Only one input file.
     trainSeq.resize(1);
-    data::Load(inputFile.c_str(), trainSeq[0], true);
+    data::Load(inputFile, trainSeq[0], true);
 
     // Do we need to load labels?
     if (labelsFile != "")

Modified: mlpack/trunk/src/mlpack/methods/lars/lars_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/lars/lars_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/lars/lars_main.cpp	Thu Jul 18 15:47:37 2013
@@ -61,14 +61,14 @@
   // transpose this data.
   const string matXFilename = CLI::GetParam<string>("input_file");
   mat matX;
-  data::Load(matXFilename.c_str(), matX, true, false);
+  data::Load(matXFilename, matX, true, false);
 
   // Load responses.  The responses should be a one-dimensional vector, and it
   // seems more likely that these will be stored with one response per line (one
   // per row).  So we should not transpose upon loading.
   const string yFilename = CLI::GetParam<string>("responses_file");
   mat matY; // Will be a vector.
-  data::Load(yFilename.c_str(), matY, true, false);
+  data::Load(yFilename, matY, true, false);
 
   // Make sure y is oriented the right way.
   if (matY.n_rows == 1)

Modified: mlpack/trunk/src/mlpack/methods/linear_regression/linear_regression_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/linear_regression/linear_regression_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/linear_regression/linear_regression_main.cpp	Thu Jul 18 15:47:37 2013
@@ -99,7 +99,7 @@
   if (computeModel)
   {
     Timer::Start("load_regressors");
-    data::Load(trainName.c_str(), regressors, true);
+    data::Load(trainName, regressors, true);
     Timer::Stop("load_regressors");
 
     // Are the responses in a separate file?
@@ -113,7 +113,7 @@
     {
       // The initial predictors for y, Nx1
       Timer::Start("load_responses");
-      data::Load(responseName.c_str(), responses, true);
+      data::Load(responseName, responses, true);
       Timer::Stop("load_responses");
 
       if (responses.n_rows == 1)
@@ -132,7 +132,7 @@
     Timer::Stop("regression");
 
     // Save the parameters.
-    data::Save(outputFile.c_str(), lr.Parameters(), true);
+    data::Save(outputFile, lr.Parameters(), true);
   }
 
   // Did we want to predict, too?
@@ -150,7 +150,7 @@
     // Load the test file data
     arma::mat points;
     Timer::Stop("load_test_points");
-    data::Load(testName.c_str(), points, true);
+    data::Load(testName, points, true);
     Timer::Stop("load_test_points");
 
     // Perform the predictions using our model
@@ -161,6 +161,6 @@
 
     // Save predictions.
     predictions = arma::trans(predictions);
-    data::Save(outputPredictions.c_str(), predictions, true);
+    data::Save(outputPredictions, predictions, true);
   }
 }

Modified: mlpack/trunk/src/mlpack/methods/lsh/lsh_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/lsh/lsh_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/lsh/lsh_main.cpp	Thu Jul 18 15:47:37 2013
@@ -86,7 +86,7 @@
 
   arma::mat referenceData;
   arma::mat queryData; // So it doesn't go out of scope.
-  data::Load(referenceFile.c_str(), referenceData, true);
+  data::Load(referenceFile, referenceData, true);
 
   Log::Info << "Loaded reference data from '" << referenceFile << "' ("
       << referenceData.n_rows << " x " << referenceData.n_cols << ")." << endl;
@@ -112,7 +112,7 @@
   {
     string queryFile = CLI::GetParam<string>("query_file");
 
-    data::Load(queryFile.c_str(), queryData, true);
+    data::Load(queryFile, queryData, true);
     Log::Info << "Loaded query data from '" << queryFile << "' ("
               << queryData.n_rows << " x " << queryData.n_cols << ")." << endl;
   }

Modified: mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/naive_bayes/nbc_main.cpp	Thu Jul 18 15:47:37 2013
@@ -40,7 +40,7 @@
   // Check input parameters.
   const string trainingDataFilename = CLI::GetParam<string>("train_file");
   mat trainingData;
-  data::Load(trainingDataFilename.c_str(), trainingData, true);
+  data::Load(trainingDataFilename, trainingData, true);
 
   // Normalize labels.
   Col<size_t> labels;
@@ -69,7 +69,7 @@
 
   const string testingDataFilename = CLI::GetParam<std::string>("test_file");
   mat testingData;
-  data::Load(testingDataFilename.c_str(), testingData, true);
+  data::Load(testingDataFilename, testingData, true);
 
   if (testingData.n_rows != trainingData.n_rows)
     Log::Fatal << "Test data dimensionality (" << testingData.n_rows << ") "

Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/allkfn_main.cpp	Thu Jul 18 15:47:37 2013
@@ -73,7 +73,7 @@
 
   arma::mat referenceData;
   arma::mat queryData; // So it doesn't go out of scope.
-  data::Load(referenceFile.c_str(), referenceData, true);
+  data::Load(referenceFile, referenceData, true);
 
   Log::Info << "Loaded reference data from '" << referenceFile << "' ("
       << referenceData.n_rows << " x " << referenceData.n_cols << ")." << endl;
@@ -129,7 +129,7 @@
   {
     string queryFile = CLI::GetParam<string>("query_file");
 
-    data::Load(queryFile.c_str(), queryData, true);
+    data::Load(queryFile, queryData, true);
 
     Log::Info << "Loaded query data from '" << queryFile << "' ("
         << queryData.n_rows << " x " << queryData.n_cols << ")." << endl;

Modified: mlpack/trunk/src/mlpack/methods/range_search/range_search_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/range_search/range_search_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/range_search/range_search_main.cpp	Thu Jul 18 15:47:37 2013
@@ -86,7 +86,7 @@
 
   arma::mat referenceData;
   arma::mat queryData; // So it doesn't go out of scope.
-  if (!data::Load(referenceFile.c_str(), referenceData))
+  if (!data::Load(referenceFile, referenceData))
     Log::Fatal << "Reference file " << referenceFile << "not found." << endl;
 
   Log::Info << "Loaded reference data from '" << referenceFile << "'." << endl;
@@ -142,7 +142,7 @@
   {
     string queryFile = CLI::GetParam<string>("query_file");
 
-    if (!data::Load(queryFile.c_str(), queryData))
+    if (!data::Load(queryFile, queryData))
       Log::Fatal << "Query file " << queryFile << " not found" << endl;
 
     if (naive && leafSize < queryData.n_cols)

Modified: mlpack/trunk/src/mlpack/methods/rann/allkrann_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/rann/allkrann_main.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/rann/allkrann_main.cpp	Thu Jul 18 15:47:37 2013
@@ -97,7 +97,7 @@
 
   arma::mat referenceData;
   arma::mat queryData; // So it doesn't go out of scope.
-  data::Load(referenceFile.c_str(), referenceData, true);
+  data::Load(referenceFile, referenceData, true);
 
   Log::Info << "Loaded reference data from '" << referenceFile << "' ("
       << referenceData.n_rows << " x " << referenceData.n_cols << ")." << endl;
@@ -141,7 +141,7 @@
     {
       string queryFile = CLI::GetParam<string>("query_file");
 
-      data::Load(queryFile.c_str(), queryData, true);
+      data::Load(queryFile, queryData, true);
 
       Log::Info << "Loaded query data from '" << queryFile << "' (" <<
         queryData.n_rows << " x " << queryData.n_cols << ")." << endl;
@@ -195,7 +195,7 @@
       {
         string queryFile = CLI::GetParam<string>("query_file");
 
-        data::Load(queryFile.c_str(), queryData, true);
+        data::Load(queryFile, queryData, true);
 
         if (naive && leafSize < queryData.n_cols)
           leafSize = queryData.n_cols;



More information about the mlpack-svn mailing list