mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-15 02:05:37 +00:00
54aec05989
but non-identity matrix l1 0 0 0 .... 0 l2 0 0 .... 0 0 l3 0 ... . . . . . . . . . And apply the multishift CG to it. Sum the poles and residues. Insist that this be the same as the exactly taken square root where l1,l2,l3 >= 0.
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;
|
|
}
|
|
}
|