2016-01-02 14:51:32 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: ./lib/algorithms/approx/MultiShiftFunction.h
|
|
|
|
|
|
|
|
Copyright (C) 2015
|
|
|
|
|
|
|
|
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
|
|
|
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
See the full license in the file "LICENSE" in the top level distribution directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
2015-06-08 11:52:44 +01:00
|
|
|
#ifndef MULTI_SHIFT_FUNCTION
|
|
|
|
#define MULTI_SHIFT_FUNCTION
|
2015-07-27 10:32:28 +01:00
|
|
|
|
2015-06-08 11:52:44 +01:00
|
|
|
namespace Grid {
|
2015-07-27 10:32:28 +01:00
|
|
|
|
2015-06-08 11:52:44 +01:00
|
|
|
class MultiShiftFunction {
|
|
|
|
public:
|
|
|
|
int order;
|
|
|
|
std::vector<RealD> poles;
|
|
|
|
std::vector<RealD> residues;
|
|
|
|
std::vector<RealD> tolerances;
|
|
|
|
RealD norm;
|
|
|
|
RealD lo,hi;
|
2015-08-18 14:40:08 +01:00
|
|
|
|
2015-06-08 11:52:44 +01:00
|
|
|
MultiShiftFunction(int n,RealD _lo,RealD _hi): poles(n), residues(n), lo(_lo), hi(_hi) {;};
|
|
|
|
RealD approx(RealD x);
|
|
|
|
void csv(std::ostream &out);
|
|
|
|
void gnuplot(std::ostream &out);
|
2015-08-18 14:40:08 +01:00
|
|
|
|
|
|
|
void Init(AlgRemez & remez,double tol,bool inverse)
|
2015-06-08 11:52:44 +01:00
|
|
|
{
|
2015-08-18 14:40:08 +01:00
|
|
|
order=remez.getDegree();
|
|
|
|
tolerances.resize(remez.getDegree(),tol);
|
|
|
|
poles.resize(remez.getDegree());
|
|
|
|
residues.resize(remez.getDegree());
|
2015-06-08 11:52:44 +01:00
|
|
|
remez.getBounds(lo,hi);
|
|
|
|
if ( inverse ) remez.getIPFE (&residues[0],&poles[0],&norm);
|
2015-08-18 14:40:08 +01:00
|
|
|
else remez.getPFE (&residues[0],&poles[0],&norm);
|
2015-06-08 11:52:44 +01:00
|
|
|
}
|
2015-08-19 04:58:40 +01:00
|
|
|
// Allow deferred initialisation
|
|
|
|
MultiShiftFunction(void){};
|
2015-08-18 14:40:08 +01:00
|
|
|
MultiShiftFunction(AlgRemez & remez,double tol,bool inverse)
|
|
|
|
{
|
|
|
|
Init(remez,tol,inverse);
|
|
|
|
}
|
|
|
|
|
2015-06-08 11:52:44 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|