changeset 2:5fa249d59d58

Allow to set the trace level
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 13 Jan 2015 16:54:01 -0500
parents 135f5ebf0726
children bb3a5c43fc65
files medcouple.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/medcouple.c
+++ b/medcouple.c
@@ -43,14 +43,14 @@
  *      eps2: used to check for over- and underflow, respectively
  *      therefore I suggest eps1 = DBL_EPS and eps2 = DBL_MIN
  */
-double mc_C(double *z, int n, double *eps)
+double mc_C(double *z, int n, double *eps, int trace_lev)
 {
   /* NOTE:
      eps	  = c(eps1, eps2)
      iter := c(maxit, trace.lev)  as input
      = c(it, converged)     as output
   */
-  int trace_lev = 0, it = 0;
+  int it = 0;
   bool converged = true;
   double medc; // "the" result
 
@@ -311,6 +311,7 @@
 #include <string>
 #include <fstream>
 #include <iomanip>
+#include <sstream>
 
 int main(int argc, char** argv) {
   using namespace std;
@@ -327,6 +328,13 @@
     return 1;
   }
 
+  double trace_lev = 0;
+  if(argc > 2) {
+    stringstream ss;
+    ss << argv[2];
+    ss >> trace_lev;
+  }
+
   ifstream ifs(fname);
   if (not ifs) {
     cerr << "File " << fname << " not found." << endl;
@@ -339,7 +347,7 @@
     data.push_back(datum);
   }
   
-  cout << setprecision(16) << mc_C(&data[0], data.size(), &eps[0]) << endl;
+  cout << setprecision(16) << mc_C(&data[0], data.size(), &eps[0], trace_lev) << endl;
 
   return 0;
 }