Commit dd8ff195 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

wow - so many new files - so much code added

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1494
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent ebdaa2fb
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sigfit.cc,v 1.10 2004-02-24 16:02:47 tforb Exp $
* $Id: sigfit.cc,v 1.11 2004-02-24 20:06:56 tforb Exp $
* \author Thomas Forbriger
* \date 28/01/2004
*
......@@ -15,13 +15,14 @@
* - 28/01/2004 V1.0 Thomas Forbriger
* - 24/02/2004 V1.1 introduced search range stabilization
* more output values
* V1.2 correction: searchfac is a factor!
*
* ============================================================================
*/
#define SIGFIT_VERSION \
"SIGFIT V1.1 fit signal by trial-signals"
"SIGFIT V1.2 fit signal by trial-signals"
#define SIGFIT_CVSID \
"$Id: sigfit.cc,v 1.10 2004-02-24 16:02:47 tforb Exp $"
"$Id: sigfit.cc,v 1.11 2004-02-24 20:06:56 tforb Exp $"
#include <fstream>
#include <iostream>
......@@ -57,6 +58,7 @@ struct Options {
bool writeresidual;
double searchrange;
bool usesearchrange;
bool equalsearch;
}; // struct Options
// formatted number output
......@@ -97,6 +99,7 @@ int main(int iargc, char* argv[])
" contribute to the signal" "\n"
" the search range r is given in units of" "\n"
" rms(signal)/rms(trial signals)" "\n"
"-equalsearch use same search range for each trial signal" "\n"
"\n"
"signal signal to by explained by a linear combination" "\n"
" of trial signals" "\n"
......@@ -119,6 +122,8 @@ int main(int iargc, char* argv[])
{"residual",arg_yes,"-"},
// 5: search range
{"searchrange",arg_opt,"100."},
// 6: equal search ranges
{"equalsearch",arg_no,"-"},
{NULL}
};
......@@ -173,6 +178,7 @@ int main(int iargc, char* argv[])
opt.residualname=cmdline.string_arg(4);
opt.usesearchrange=cmdline.optset(5);
opt.searchrange=cmdline.double_arg(5);
opt.equalsearch=cmdline.optset(6);
/*----------------------------------------------------------------------*/
......@@ -295,6 +301,7 @@ int main(int iargc, char* argv[])
int N=bundlevec.size();
if (opt.verbose) { cout << "system is of size " << N << "x" << N << endl; }
Tmatrix Matrix(N,N), rhs(N), coeff(N), normproduct(N), trialrms(N);
double fulltrialrms=0.;
for (int i=1; i<=N; ++i)
{
for (int k=i; k<=N; ++k)
......@@ -304,8 +311,10 @@ int main(int iargc, char* argv[])
}
rhs(i)=ts::innerproduct(bundlevec[i-1], signal);
trialrms(i)=ts::rms(bundlevec[i-1]);
fulltrialrms+=(trialrms(i)*trialrms(i));
normproduct(i)=rhs(i)/(signalrms*trialrms(i)*signal.size());
}
fulltrialrms=sqrt(fulltrialrms/double(N));
// add stabilization
if (opt.usesearchrange)
......@@ -315,16 +324,20 @@ int main(int iargc, char* argv[])
cout << "stabilize fit:" << endl;
cout << " relative search range: " << opt.searchrange << endl;
}
double sreachfac=signal.size()*signalrms;
double searchfac=signal.size()*signalrms;
for (int i=1; i<=N; ++i)
{
double range=opt.searchrange*signalrms/trialrms(i);
double range;
if (opt.equalsearch)
{ range=opt.searchrange*signalrms/fulltrialrms; }
else
{ range=opt.searchrange*signalrms/trialrms(i); }
if (opt.verbose)
{
cout << " search range for trial series " << i
<< " is " << range << endl;
}
Matrix(i,i)+=pow((range/sreachfac),2);
Matrix(i,i)+=pow((searchfac/range),2);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment