mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 15:55:37 +00:00
30 lines
595 B
C++
30 lines
595 B
C++
|
#include <Grid.h>
|
||
|
|
||
|
namespace Grid {
|
||
|
double MultiShiftFunction::approx(double x)
|
||
|
{
|
||
|
double a = norm;
|
||
|
for(int n=0;n<poles.size();n++){
|
||
|
a = a + residues[n]/(x+poles[n]);
|
||
|
}
|
||
|
return a;
|
||
|
}
|
||
|
void MultiShiftFunction::gnuplot(std::ostream &out)
|
||
|
{
|
||
|
out<<"f(x) = "<<norm<<"";
|
||
|
for(int n=0;n<poles.size();n++){
|
||
|
out<<"+("<<residues[n]<<"/(x+"<<poles[n]<<"))";
|
||
|
}
|
||
|
out<<";"<<std::endl;
|
||
|
}
|
||
|
void MultiShiftFunction::csv(std::ostream &out)
|
||
|
{
|
||
|
for (double x=lo; x<hi; x*=1.05) {
|
||
|
double f = approx(x);
|
||
|
double r = sqrt(x);
|
||
|
out<< x<<","<<r<<","<<f<<","<<r-f<<std::endl;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
}
|