Commit 74ae3659 authored by Laurent Belcour's avatar Laurent Belcour

Updating evaluation with respect to output dimension

parent aeadc9ac
......@@ -7,7 +7,8 @@
#include "common.h"
#include "args.h"
#include "data.h"
class data ;
class function
{
......@@ -26,8 +27,6 @@ class function
virtual void setDimX(int nX) { _nX = nX ; } ;
virtual void setDimY(int nY) { _nY = nY ; } ;
virtual void save_gnuplot(const std::string& filename, const data* d, const arguments& args) const ;
protected:
// Dimension of the function
......
......@@ -53,12 +53,12 @@ vec rational_function::value(const vec& x) const
for(unsigned int i=0; i<np; ++i)
{
p += a[i*_nY + k]*this->p(x, i) ;
p += a[k*_nY + i]*this->p(x, i) ;
}
for(unsigned int i=0; i<nq; ++i)
{
q += b[i*_nY + k]*this->q(x, i) ;
q += b[k*_nY + i]*this->q(x, i) ;
}
res[k] = p/q ;
......@@ -99,7 +99,7 @@ std::vector<int> rational_function::index2degree(int i) const
int Nk = 1 ;
int nk = dimX() ;
int k = 1 ;
while(!(i >= Nk & i < Nk+nk))
while(!(i >= Nk && i < Nk+nk))
{
Nk += nk ;
nk *= dimX() ;
......@@ -217,7 +217,7 @@ void rational_function::save_rational_function(const std::string& filename) cons
file << "#NQ " << b.size() / _nY << std::endl ;
file << "#BASIS poly" << std::endl ;
for(unsigned int i=0; i<a.size(); ++i)
for(unsigned int i=0; i<a.size() / _nY; ++i)
{
std::vector<int> index = index2degree(i) ;
for(unsigned int j=0; j<index.size(); ++j)
......@@ -230,7 +230,7 @@ void rational_function::save_rational_function(const std::string& filename) cons
for(unsigned int i=0; i<b.size(); ++i)
{
std::vector<int> index = index2degree(i) ;
for(unsigned int j=0; j<index.size(); ++j)
for(unsigned int j=0; j<index.size() / _nY; ++j)
{
file << index[j] << "\t" ;
}
......
......@@ -148,13 +148,15 @@ int main(int argc, char** argv)
size_t n = args["output"].find('.') ;
std::string gnuplot_filename = args["output"].substr(0,n);
gnuplot_filename.append(".gnuplot") ;
/*
f->save_gnuplot(gnuplot_filename, d, args);
/* std::ofstream file(gnuplot_filename.c_str(), std::ios_base::trunc);
/*/
std::ofstream file(gnuplot_filename.c_str(), std::ios_base::trunc);
for(int i=0; i<d->size(); ++i)
{
vec v = d->get(i) ;
vec y1(d->dimY()) ;
for(int k=0; k<d->dimY(); ++k) { y1[k] = v[d->dimX() + k] ; }
// vec y1(d->dimY()) ;
// for(int k=0; k<d->dimY(); ++k) { y1[k] = v[d->dimX() + k] ; }
vec y2 = f->value(v) ;
for(int u=0; u<d->dimX(); ++u)
......@@ -165,7 +167,7 @@ int main(int argc, char** argv)
file << std::endl ;
}
*/
//*/
std::string error_filename = args["output"].substr(0,n);
error_filename.append(".errorplot") ;
std::ofstream efile(error_filename.c_str(), std::ios_base::trunc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment