/* * VolatilityPanel.cpp * Takes few pairs of (maturity, volatility) from the volatility * structure of zero coupon bonds, and performs a fit using the Spline class * * Created on June 8, 2006, 7:44 PM */ #include "Curve.cpp" #include "Spline.cpp" #include #include #include #include #include /** * * @author horacio aliaga */ class VolatilityPanel{ vector t; vector vol; double* time; double* sigma; double* sigma_prime; int npoints; /** Creates new form VolatilityPanel */ public: VolatilityPanel() { 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); vol.push_back(0.30);vol.push_back(0.24);vol.push_back(0.22); vol.push_back(0.21);vol.push_back(0.22); Spline s; Curve data; data=s.spline(t,vol,400,1.0); } public: void Go() { Spline s; Curve data; data=s.spline(t,vol,400,1.0); return; } public: void Add(double t1, double y1) { t.push_back(t1); vol.push_back(y1); } public: void ClearAll() { Curve data; if(t.size()>0){ t.clear(); vol.clear(); } } public: int get_npoints(){ return npoints; } public: void set_npoints(int _npoints){ npoints = _npoints; } public: double* get_time(){ return time; } 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_vol(){ return vol; } public: vector get_t(){ return t; } };