75 const std::vector<RealD> &omega_in,
const int Ls_in,
76 const RealD lambda_bound){
77 assert(omega_in.size() == Ls_in);
78 omega_out.resize(Ls_out);
101 std::vector<RealD> coeffs(Ls_out+1);
102 for(
int i=0;i<Ls_out+1;i+=2) coeffs[i] = coeffs[i] = remez.
getCoeffDen(i);
103 for(
int i=1;i<Ls_out+1;i+=2) coeffs[i] = coeffs[i] = remez.
getCoeffNum(i);
105 std::vector<std::complex<RealD> > roots(Ls_out);
108 Eigen::MatrixXd compn(Ls_out,Ls_out);
109 for(
int i=0;i<Ls_out-1;i++) compn(i,0) = 0.;
110 compn(Ls_out - 1, 0) = -coeffs[0];
112 for(
int j=1;j<Ls_out;j++){
113 for(
int i=0;i<Ls_out-1;i++) compn(i,j) = i == j-1 ? 1. : 0.;
114 compn(Ls_out - 1, j) = -coeffs[j];
118 Eigen::EigenSolver<Eigen::MatrixXd> slv(compn,
false);
120 const auto & ev = slv.eigenvalues();
121 for(
int i=0;i<Ls_out;i++)
122 omega_out[i] = -ev(i);
125 std::sort(omega_out.begin(), omega_out.end(),
126 [&](
const ComplexD &a,
const ComplexD &b){ return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag()); });
129 std::vector<ComplexD> omega_tmp = omega_out;
130 int s_low=0, s_high=Ls_out-1, ss=0;
131 for(
int s_from = Ls_out-1; s_from >= 0; s_from--){
138 omega_out[s_to] = omega_tmp[s_from];
142 std::cout <<
"Resulting omega_i:" << std::endl;
143 for(
int i=0;i<Ls_out;i++)
144 std::cout << omega_out[i] << std::endl;
146 std::cout <<
"Test result matches the approximate polynomial found by the Remez" << std::endl;
147 std::cout <<
"<x> <remez approx> <poly approx> <diff poly approx remez approx> <exact> <diff poly approx exact>\n";
150 double dlt = lambda_bound/double(npt-1);
152 for (
int i =0; i<npt; i++){
158 std::cout << x<<
" " << r <<
" " << p <<
" " <<r-p <<
" " << e <<
" " << e-p << std::endl;
void computeZmobiusGamma(std::vector< ComplexD > &gamma_out, const RealD mobius_param_out, const int Ls_out, const RealD mobius_param_in, const int Ls_in, const RealD lambda_bound)
void computeZmobiusOmega(std::vector< ComplexD > &omega_out, const int Ls_out, const std::vector< RealD > &omega_in, const int Ls_in, const RealD lambda_bound)
double generateApprox(int num_degree, int den_degree, PolyType num_type, PolyType den_type, const double tolerance=1e-15, const int report_freq=1000)