From fa2476eddadb196b4eb7adb580bfafc71b0e54d5 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (laptop)" <j.wuttke@fz-juelich.de>
Date: Tue, 20 Jan 2009 14:20:57 +0100
Subject: [PATCH] cv-auxiliary-parameters are per-file

---
 src/curve.cpp  | 59 ++++++++++++++++++++++++++++++++------------------
 src/curve.h    |  2 +-
 src/frida2.cpp | 27 +++++++++++------------
 src/olm.h      |  3 +++
 4 files changed, 55 insertions(+), 36 deletions(-)

diff --git a/src/curve.cpp b/src/curve.cpp
index eda48f54..7b4f368e 100644
--- a/src/curve.cpp
+++ b/src/curve.cpp
@@ -18,6 +18,24 @@ using namespace std;
 #include "../../code/lmfit/lmmin.h"
 #include "xax.h"
 
+//! local functions (wouldn't suffice "static" ??)
+
+namespace NCurveFile
+{
+    void IntegrateFile(
+        const COlc *fin, const int k, const string& mode,
+        const int ip, const string& name, const CCoord& ico );
+    double NumericIntegral(
+        const COlc *fc, const CCurve *c, const int k, const int j,
+        const double low, const double hig );
+    // parameters for numeric integration:
+    double numint_bound_low=-INFINITY, numint_bound_hig=INFINITY;
+    // tuning parameters:
+    int numint_mode=4;
+    int numint_cvmode=-1;
+    double numint_epsabs=1e-10, numint_epsrel=1e-10;
+};
+
 
 //***************************************************************************//
 //* generic operations on curves                                            *//
@@ -63,7 +81,7 @@ int CCurve::Load(FILE *fd, uint nz)
 
 //! Create curve files.
 
-void NCurveFile::Create( bool refers_to_data, bool with_convolution )
+void NCurveFile::Create( bool refers_to_data )
 {
     static int default_no=0;
 
@@ -87,6 +105,9 @@ void NCurveFile::Create( bool refers_to_data, bool with_convolution )
     f.weight_y_log = false;
     f.expr = expr;
     f.T = T;
+    f.cv_intmod = NCurveFile::numint_cvmode;
+    f.cv_epsabs = NCurveFile::numint_epsabs;
+    f.cv_epsrel = NCurveFile::numint_epsrel;
     vector<double> P( np, 1.0 );
 
     // use f to create output file(s)
@@ -249,7 +270,7 @@ void NCurveFile::SetFixed(string how)
 }
 
 
-//! Set convolution
+//! Set convolution.
 
 void NCurveFile::SetConvolution( bool onoff )
 {
@@ -266,6 +287,21 @@ void NCurveFile::SetConvolution( bool onoff )
         fc->kconv = k;
 }
 
+//! Set auxiliary parameters for numeric convolution.
+
+void NCurveFile::SetConvEps()
+{
+    static double epsabs = 1e-10, epsrel = 1e-10;
+    epsrel = dask( "Eps rel for convolution", epsrel );
+    epsabs = dask( "Eps abs for convolution", epsabs );
+    COlc *fc;
+    NOlm::IterateC fiter;
+    while ( (fc=fiter()) ) {
+        fc->cv_epsabs = epsabs;
+        fc->cv_epsrel = epsrel;
+    }
+}
+
 //! Set auxiliary parameters (weighing, ..).
 
 void NCurveFile::SetProperties(string which)
@@ -524,25 +560,6 @@ double myeval( double x, void* data )
 }
 
 
-//! local functions (wouldn't suffice "static" ??)
-
-namespace NCurveFile
-{
-    void IntegrateFile(
-        const COlc *fin, const int k, const string& mode,
-        const int ip, const string& name, const CCoord& ico );
-    double NumericIntegral(
-        const COlc *fc, const CCurve *c, const int k, const int j,
-        const double low, const double hig );
-    // parameters for numeric integration:
-    double numint_bound_low=-INFINITY, numint_bound_hig=INFINITY;
-    // tuning parameters:
-    int numint_mode=4;
-    int numint_cvmode=-1;
-    double numint_epsabs=1e-10, numint_epsrel=1e-10;
-};
-
-
 //! display or change tuning parameters for numeric integration
 
 void NCurveFile::SetIntTuningPars( string which )
diff --git a/src/curve.h b/src/curve.h
index 30e2e6ad..1154a137 100644
--- a/src/curve.h
+++ b/src/curve.h
@@ -19,7 +19,7 @@ class CCurve {
 //! NCurFil holds operations on curve files
 
 namespace NCurveFile {
-    void Create( bool refers_to_data, bool with_convolution );
+    void Create( bool refers_to_data );
 
     void SetConvolution( bool onoff );
 
diff --git a/src/frida2.cpp b/src/frida2.cpp
index b313dc58..c1b502c1 100644
--- a/src/frida2.cpp
+++ b/src/frida2.cpp
@@ -98,7 +98,6 @@ int main()
             } else if (cmd == "c") {
                 cout << "Curves:\n"
                     "  cc   create\n"
-                    "  ccv  create (with convolution)\n"
                     "  cca  create artificial curve (no data reference)\n"
                     "Basic operations:\n"
                     "  cv   set file to convolute with (cv-: no convolution)\n"
@@ -112,24 +111,26 @@ int main()
                     "Special operations:\n"
                     "  c_cd calculate cumulative probability distribution\n"
                     "Fit tuning parameters:\n"
-                    "  cs   show parameters\n"
+                    "  cs?  show parameters\n"
                     "  csf  set gradient step factor\n"
                     "  cse  set sqrt of differentiation step\n"
                     "  csc  set number of calls\n"
                     "  csp  set print frequency\n"
                     "  csm  set fit metric\n"
-                    "Numeric integration tuning parameters:\n"
-                    "  cn   show parameters\n"
+                    "Tuning parameters for integration:\n"
+                    "  cn?  show parameters\n"
                     "  cnm  set integration mode\n"
-                    "  cnv  set convolution mode\n"
                     "  cna  set eps abs\n"
-                    "  cnr  set eps rel\n";
+                    "  cnr  set eps rel\n"
+                    "Tuning parameters for convolution:\n"
+                    "  cv?  show parameters\n"
+                    "  cvm  set integration mode\n"
+                    "  cva  set eps abs\n"
+                    "  cvr  set eps rel\n";
             } else if (cmd == "cc") {
-                NCurveFile::Create( true, false );
-            } else if (cmd == "ccv") {
-                NCurveFile::Create( true, true );
+                NCurveFile::Create( true );
             } else if (cmd == "cca") {
-                NCurveFile::Create( false, false );
+                NCurveFile::Create( false );
 
             } else if (cmd == "cv") {
                 NCurveFile::SetConvolution( true );
@@ -153,16 +154,14 @@ int main()
             } else if (cmd == "c_cd") {
                 NCurveFile::CumulativeDistribution();
 
-            } else if (cmd == "cs") {
-                NCurveFile::SetFitTuningPars("?");
             } else if (cmd.substr(0,2) == "cs") {
                 NCurveFile::SetFitTuningPars(cmd.substr(2));
 
-            } else if (cmd == "cn") {
-                NCurveFile::SetIntTuningPars("?");
             } else if (cmd.substr(0,2) == "cn") {
                 NCurveFile::SetIntTuningPars(cmd.substr(2));
 
+            } else if (cmd.substr(0,2) == "cv") {
+                NCurveFile::SetConvTuningPars(cmd.substr(2));
 
             } else if ( cmd == "d" ) {
                 cout << "Show directory:\n"
diff --git a/src/olm.h b/src/olm.h
index fbc4d07b..c3e6e817 100644
--- a/src/olm.h
+++ b/src/olm.h
@@ -49,6 +49,9 @@ class COlc : public COlo { // on-line curves
     vector<CCurve> VC;
     bool           weight_y_log;
     uint           kconv;
+    uint           cv_intmod;
+    double         cv_epsabs;
+    double         cv_epsrel;
 
     inline COlc() : weight_y_log(false), kconv(-1) { ; };
     inline uint nScan(void) const { return VC.size(); };
-- 
GitLab