mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
a8b9109cc8
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;
|
|
}
|
|
}
|