graphs.cxx

Go to the documentation of this file.
00001 #include <cxxtls/spline.h>
00002 #include <iostream>
00003 #include <algorithm>
00004 #include <cxxtls/ascii_chart.h>
00005 #include <vector>
00006 
00007 using namespace std;
00008 using namespace cxxtls;
00009 
00010 typedef spline<float,float>          Function;
00011 typedef vector< pair<float,float> >  values_t;
00012 
00013 
00014 int main(int argc, char **argv)
00015 {
00016    Function f1;
00017 
00018    f1.add_sample(00,00);
00019    f1.add_sample(17,10);
00020    f1.add_sample(31,00);
00021    f1.add_sample(48,-10);
00022    f1.add_sample(62,00);
00023 
00024    ascii_chart chart(70, 20);
00025 
00026    values_t values(70);  
00027 
00028    chart.title_ = "step function";
00029    f1.evaluate(0,1,values.begin(), values.end());
00030    chart.plot(values);
00031    cout << chart;
00032 
00033    chart.clear();
00034    chart.title_ = "linear function";
00035    f1.set_interpolator(&Function::interpolate_line);
00036    f1.evaluate(0,1,values.begin(), values.end());
00037    chart.plot(values);
00038    cout << chart;
00039 
00040    chart.clear();
00041    chart.title_ = "cubic function";
00042    f1.set_interpolator(&Function::interpolate_cubic);
00043    f1.evaluate(0,1,values.begin(), values.end());
00044    chart.plot(values);
00045    cout << chart;
00046 
00047 
00048 }
Generated on Wed Feb 29 22:50:05 2012 for CXXUtilities by  doxygen 1.6.3