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

proceeding, slowly... :-(

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: 1281
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 891c3145
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: srcires.cc,v 1.2 2003-01-05 20:37:19 forbrig Exp $
* $Id: srcires.cc,v 1.3 2003-01-05 22:38:22 forbrig Exp $
* \author Thomas Forbriger
* \date 04/01/2003
*
......@@ -19,7 +19,7 @@
#define TF_SRCIRES_CC_VERSION \
"TF_SRCIRES_CC V1.0 "
#define TF_SRCIRES_CC_CVSID \
"$Id: srcires.cc,v 1.2 2003-01-05 20:37:19 forbrig Exp $"
"$Id: srcires.cc,v 1.3 2003-01-05 22:38:22 forbrig Exp $"
#include <cmath>
#include <stdio.h>
......@@ -41,6 +41,7 @@ namespace gremlin1 {
is.ignore(maxskip,'\n');
double df;
is >> df;
df /= pi2;
is.ignore(maxskip,'\n');
int nf;
is >> nf;
......@@ -87,18 +88,18 @@ namespace gremlin1 {
os << " 1: angular frequency (1/s)" << std::endl;
os << " 2: real part" << std::endl;
os << " 3: imaginary part" << std::endl;
os << ires.df() << " angular frequency step width" << std::endl;
os << pi2*ires.df() << " angular frequency step width" << std::endl;
os << outires.size() << " number of frequency samples" << std::endl;
const int bufsize=20;
const int bufsize=60;
char buffer[bufsize];
for (int i=outires.f(0); i<=outires.l(0); ++i)
{
double angfreq=pi2*ires.f(i);
double realpart=real(outires(i));
double imagpart=imag(outires(i));
std::snprintf(buffer, bufsize, "%15.10f %15.10f %15.10f",
double angfreq=static_cast<double>(pi2*ires.f(i));
double realpart=static_cast<double>(real(outires(i)));
double imagpart=static_cast<double>(imag(outires(i)));
std::snprintf(buffer, bufsize, "%15.5f %15.7e %15.7e",
angfreq, realpart, imagpart);
os << buffer << std::endl;
}
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: srcires.h,v 1.2 2003-01-05 20:37:19 forbrig Exp $
* $Id: srcires.h,v 1.3 2003-01-05 22:38:22 forbrig Exp $
* \author Thomas Forbriger
* \date 04/01/2003
*
......@@ -23,7 +23,7 @@
#define TF_SRCIRES_H_VERSION \
"TF_SRCIRES_H V1.0 "
#define TF_SRCIRES_H_CVSID \
"$Id: srcires.h,v 1.2 2003-01-05 20:37:19 forbrig Exp $"
"$Id: srcires.h,v 1.3 2003-01-05 22:38:22 forbrig Exp $"
#include<complex>
#include<iostream>
......@@ -47,7 +47,7 @@ namespace gremlin1 {
int n2() const { return(Mires.l(0)); }
const double& df() const { return(Mdf); }
double f(const int& i) const { return((i-1)*Mdf); }
int findex(const double& fr) const { return(static_cast<int>(fr/Mdf)+1); }
int findex(const double& fr) const { return(static_cast<int>(fr/Mdf+1)); }
Tcarray ires() { return(Mires); }
Tcarray::Tcoc ires() const { return(Mires); }
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: grestf.cc,v 1.2 2003-01-05 20:37:19 forbrig Exp $
* $Id: grestf.cc,v 1.3 2003-01-05 22:38:22 forbrig Exp $
* \author Thomas Forbriger
* \date 04/01/2003
*
......@@ -19,7 +19,7 @@
#define GRESTF_VERSION \
"GRESTF V1.0 source time function from Green"
#define GRESTF_CVSID \
"$Id: grestf.cc,v 1.2 2003-01-05 20:37:19 forbrig Exp $"
"$Id: grestf.cc,v 1.3 2003-01-05 22:38:22 forbrig Exp $"
#include <iostream>
#include <fstream>
......@@ -64,7 +64,9 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
GRESTF_VERSION "\n"
"usage: grestf ires data [-v]" "\n"
"usage: grestf ires data [-v] [-damp v]" "\n"
" [-datafil f] [-filter f] [-restifi]" "\n"
" [-slraw f -slfil f] [-skipzero]" "\n"
" or: grestf --help|-h" "\n"
};
......@@ -79,6 +81,7 @@ int main(int iargc, char* argv[])
"-damp v set damping factor to v" "\n"
"-slraw f write raw stf from linear regression to f" "\n"
"-slfil f write filtered stf from linear regression to f" "\n"
"-skipzero skip frequency zero" "\n"
"\n"
"ires impulse response Green" "\n"
"data Green from data" "\n"
......@@ -109,11 +112,13 @@ int main(int iargc, char* argv[])
// 4: use datafil for restitution
{"restifi",arg_no,"-"},
// 5: damping factor
{"damp",arg_yes,"-"},
{"damp",arg_yes,"1.e-8"},
// 6: output of raw stf from linear regresseion
{"slraw",arg_yes,"-"},
// 7: output of filtered stf from linear regresseion
{"slfil",arg_yes,"-"},
// 8: skip zero frequency
{"skipzero",arg_no,"-"},
{NULL}
};
......@@ -147,6 +152,7 @@ int main(int iargc, char* argv[])
std::string arg_slraw =cmdline.string_arg(6);
bool opt_slfil =cmdline.optset(7);
std::string arg_slfil =cmdline.string_arg(7);
bool opt_skipzero =cmdline.optset(8);
bool act_stflinreg= opt_slfil || opt_slraw;
......@@ -235,14 +241,14 @@ int main(int iargc, char* argv[])
if (opt_datafil)
{
if (opt_verbose) cout << "reading filter from " << arg_datafil << endl;
fil_dataresp.read(arg_datafil.c_str());
fil_dataresp.read(arg_datafil.c_str(), opt_verbose);
fil_dataresp.setfreqmod();
}
if (opt_filter)
{
if (opt_verbose) cout << "reading filter from " << arg_filter << endl;
fil_filter.read(arg_filter.c_str());
fil_filter.read(arg_filter.c_str(), opt_verbose);
fil_filter.setfreqmod();
}
......@@ -289,27 +295,33 @@ int main(int iargc, char* argv[])
<< " and apply filter" << endl;
if (opt_restifi) cout << " and apply inverse data response" << endl;
}
int iires=lr_iresraw.n1();
for (int i=lr_synt.f(1); i<=lr_synt.l(1); ++i)
{
Tzvalue stfraw(0.,0.);
Tzvalue stffil(0.,0.);
double f=datagreen.f(i);
int iires=lr_iresraw.findex(f);
Tzvalue numerator(0.,0.);
Tzvalue denominator(0.,0.);
for (int j=lr_synt.f(0); j<=lr_synt.l(0); ++j)
if ((!opt_skipzero) || ((2.*f)>df))
{
numerator += std::conj(lr_synt(j,i))*lr_data(j,i);
denominator += std::norm(lr_synt(j,i));
}
denominator += arg_damp*arg_damp;
Tzvalue numerator=Tzvalue(0.,0.);
Tzvalue denominator=Tzvalue(0.,0.);
for (int j=lr_synt.f(0); j<=lr_synt.l(0); ++j)
{
numerator += std::conj(lr_synt(j,i))*lr_data(j,i);
denominator += std::norm(lr_synt(j,i));
}
denominator += (arg_damp*arg_damp);
Tcvalue stf= static_cast<Tcvalue>(numerator/denominator);
lr_iresraw.ires()(iires)=stf;
stfraw= numerator/denominator;
stffil = stfraw * fil_filter.eval(f);
if (opt_restifi) stffil /= fil_dataresp.eval(f);
}
stf *= fil_filter.eval(f);
if (opt_restifi) stf /= fil_dataresp.eval(f);
lr_iresfil.ires()(iires)=stf;
lr_iresraw.ires()(iires)=static_cast<Tcvalue>(stfraw);
lr_iresfil.ires()(iires)=static_cast<Tcvalue>(stffil);
++iires;
}
if (opt_slraw)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fcommand.cc,v 1.2 2003-01-05 20:37:19 forbrig Exp $
* $Id: fcommand.cc,v 1.3 2003-01-05 22:38:22 forbrig Exp $
* \author Thomas Forbriger
* \date 05/01/2003
*
......@@ -19,7 +19,7 @@
#define TF_FCOMMAND_CC_VERSION \
"TF_FCOMMAND_CC V1.0 "
#define TF_FCOMMAND_CC_CVSID \
"$Id: fcommand.cc,v 1.2 2003-01-05 20:37:19 forbrig Exp $"
"$Id: fcommand.cc,v 1.3 2003-01-05 22:38:22 forbrig Exp $"
#include <fourier/fcommand.h>
#include <fstream>
......@@ -32,19 +32,20 @@ using std::endl;
namespace fourier {
void FilterCommands::FilterCommands::help(std::ostream& os)
void FilterCommands::FilterCommands::help(std::ostream& os,
const bool& verbose)
{
os << "filter library commands:" << endl;
os << "rem any comment (ignored)" << endl;
os << "# any comment (ignored)" << endl;
os << "dif differentiate" << endl;
os << "int integrate" << endl;
os << "lp2 in,h second order low-pass (see foufil_lp2)" << endl;
os << "hp2 in,h second order high-pass (see foufil_hp2)" << endl;
os << "lpb in,ord "
<< "Butterworth low-pass of order ord (see foufil_lpb)" << endl;
os << "hpb in,ord "
<< "Butterworth high-pass of order ord (see foufil_hpb)" << endl;
os << "lp2 in h second order low-pass" << endl;
os << "hp2 in h second order high-pass" << endl;
os << "lpb in ord "
<< "Butterworth low-pass of order ord" << endl;
os << "hpb in ord "
<< "Butterworth high-pass of order ord" << endl;
os << "fac factor mutiply by factor" << endl;
os << "mod normal "
<< "switch back to normal filters (default)" << endl;
......@@ -54,39 +55,47 @@ namespace fourier {
os << "mod frequency switch to specification by frequency " << endl;
os << "end terminate file reading" << endl;
os << endl;
os << TF_FCOMMAND_H_VERSION << endl;
os << TF_FCOMMAND_H_CVSID << endl;
os << TF_FILTERS_H_VERSION << endl;
os << TF_FILTERS_H_CVSID << endl;
os << TF_POLESNZEROES_H_VERSION << endl;
os << TF_POLESNZEROES_H_CVSID << endl;
os << "\"in\" specifies the filter freqeuncy. It is either given" << endl;
os << "as a frequency (Hz) or as a period (s) depending on the" << endl;
os << "selected mode." << endl;
if (verbose)
{
os << endl;
os << TF_FCOMMAND_H_VERSION << endl;
os << TF_FCOMMAND_H_CVSID << endl;
os << TF_FILTERS_H_VERSION << endl;
os << TF_FILTERS_H_CVSID << endl;
os << TF_POLESNZEROES_H_VERSION << endl;
os << TF_POLESNZEROES_H_CVSID << endl;
}
}
/*----------------------------------------------------------------------*/
void FilterCommands::read(const char* filename)
void FilterCommands::read(const char* filename, const bool& verbose)
{
std::ifstream ifs(filename);
read(ifs);
read(ifs, verbose);
}
/*----------------------------------------------------------------------*/
void FilterCommands::read(std::istream& is)
void FilterCommands::read(std::istream& is, const bool& verbose)
{
bool hot=is.good();
std::string line;
while(hot)
{
std::getline(is, line);
hot=command(line.c_str()) && is.good();
hot=command(line.c_str(), verbose) && is.good();
}
}
/*----------------------------------------------------------------------*/
bool FilterCommands::command(const char* command)
bool FilterCommands::command(const char* command, const bool& verbose)
{
if (verbose) cout << " set filter: " << command << endl;
bool result=true;
std::string cmd(command);
std::istringstream cmdline(cmd);
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fcommand.h,v 1.2 2003-01-05 20:37:19 forbrig Exp $
* $Id: fcommand.h,v 1.3 2003-01-05 22:38:22 forbrig Exp $
* \author Thomas Forbriger
* \date 05/01/2003
*
......@@ -23,7 +23,7 @@
#define TF_FCOMMAND_H_VERSION \
"TF_FCOMMAND_H V1.0 "
#define TF_FCOMMAND_H_CVSID \
"$Id: fcommand.h,v 1.2 2003-01-05 20:37:19 forbrig Exp $"
"$Id: fcommand.h,v 1.3 2003-01-05 22:38:22 forbrig Exp $"
#include<iostream>
#include<fourier/filters.h>
......@@ -36,13 +36,15 @@ namespace fourier {
typedef Tbase::Tcvalue Tcvalue;
FilterCommands(): Tbase() { }
FilterCommands(const char* filename): Tbase() { read(filename); }
FilterCommands(std::istream& is): Tbase() { read(is); }
static void help(std::ostream& os);
void read(std::istream& is);
void read(const char* filename);
bool command(const char* command);
FilterCommands(const char* filename, const bool& verbose=false):
Tbase() { read(filename, verbose); }
FilterCommands(std::istream& is, const bool& verbose=false):
Tbase() { read(is, verbose); }
static void help(std::ostream& os, const bool& verbose=false);
void read(std::istream& is, const bool& verbose=false);
void read(const char* filename, const bool& verbose=false);
bool command(const char* command, const bool& verbose=false);
}; // class FilterCommands
} // namespace fourier
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: filters.h,v 1.1 2003-01-05 17:36:51 forbrig Exp $
* $Id: filters.h,v 1.2 2003-01-05 22:38:22 forbrig Exp $
* \author Thomas Forbriger
* \date 05/01/2003
*
......@@ -23,7 +23,7 @@
#define TF_FILTERS_H_VERSION \
"TF_FILTERS_H V1.0 "
#define TF_FILTERS_H_CVSID \
"$Id: filters.h,v 1.1 2003-01-05 17:36:51 forbrig Exp $"
"$Id: filters.h,v 1.2 2003-01-05 22:38:22 forbrig Exp $"
#include<fourier/polesnzeroes.h>
......@@ -46,8 +46,8 @@ namespace fourier {
bool isfreqmod() const { return(Mfrequency); }
bool ispermod() const { return(!Mfrequency); }
Tcvalue eval(const double& omega) const
{ return(this->eval(Tcvalue(omega))); }
Tcvalue eval(const double& par) const
{ return(this->eval(Tcvalue(par))); }
Tcvalue eval(const Tcvalue& par) const
{ return(this->Tbase::operator()(omega(par))); }
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: polesnzeroes.cc,v 1.1 2003-01-05 17:36:51 forbrig Exp $
* $Id: polesnzeroes.cc,v 1.2 2003-01-05 22:38:22 forbrig Exp $
* \author Thomas Forbriger
* \date 05/01/2003
*
......@@ -19,7 +19,7 @@
#define TF_POLESNZEROES_CC_VERSION \
"TF_POLESNZEROES_CC V1.0 "
#define TF_POLESNZEROES_CC_CVSID \
"$Id: polesnzeroes.cc,v 1.1 2003-01-05 17:36:51 forbrig Exp $"
"$Id: polesnzeroes.cc,v 1.2 2003-01-05 22:38:22 forbrig Exp $"
#include <fourier/polesnzeroes.h>
......@@ -88,7 +88,7 @@ namespace fourier {
Tlist::const_iterator id=Mpoles.begin();
while (id != Mpoles.end())
{ denominator *= (om - *id); ++id; }
return(Mnumerator/Mdenominator);
return(numerator/denominator);
}
} // namespace fourier
......
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