/* * YieldPanel.cpp * * Takes few pairs of (maturity, forward rates) from the term structure * of zero coupon bonds, and performs a fit using the Spline class */ #include "Curve.cpp" #include "Spline.cpp" #include #include #include #include #include /** * * @author horacio aliaga */ class YieldPanel { vector t; vector y; double* time; double* yield; int npoints; /** Creates new form DataTextField */ public: YieldPanel() { t.push_back(0.0);t.push_back(0.2);t.push_back(0.4); t.push_back(0.8);t.push_back(1.0); y.push_back(0.10);y.push_back(0.14);y.push_back(0.24); y.push_back(0.15);y.push_back(0.11); Spline s; Curve data; data=s.spline(t,y,400,1.0); } public: void set_npoints(int _npoints){ npoints = _npoints; } public: int get_npoints(){ return npoints; } public: void Go() { Spline s; Curve data; data=s.spline(t,y,400,1.0); return; } public: void Add(double t1, double y1) { t.push_back(t1); y.push_back(y1); } public: void ClearAll() { Curve data; if(t.size()>0){ t.clear(); y.clear(); } } public: void set_time(double maturity){ double dt = maturity/(1.0*npoints); double* time=new double[npoints]; double t=0; for (int i=0;i get_t(){ return t; } public: vector get_y(){ return y; } };