gnuplot.hpp 634 B

123456789101112131415161718192021222324252627282930
  1. #ifndef GNUPLOT__HPP
  2. #define GNUPLOT__HPP
  3. #include <fstream>
  4. // montrer les points d'interpolation.
  5. template<class M> void gnuplotfile(const M& Points,string fich)
  6. {
  7. ofstream f;
  8. f.open(fich);
  9. for(typename M::const_iterator I=Points.begin();I!=Points.end();
  10. I++)
  11. {
  12. auto p=I->first;
  13. f<<p.first<<" "<<p.second<<endl;
  14. }
  15. f.close();
  16. }
  17. // montrer une "image"
  18. template<class real> void gnuplotfile(int nx,int ny,real* a,string fich)
  19. {
  20. ofstream f;
  21. f.open(fich);
  22. for(int j=0;j<ny;j++)
  23. {
  24. for(int i=0;i<nx;i++)
  25. f<<i<<" "<<j<<" "<<a[j*nx+i]<<endl;
  26. f<<" "<<endl;
  27. }
  28. f.close();
  29. }
  30. #endif