Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

BasketLattice.h

Go to the documentation of this file.
00001 /* WARANTY NOTICE AND COPYRIGHT
00002 This program is free software; you can redistribute it and/or
00003 modify it under the terms of the GNU General Public License
00004 as published by the Free Software Foundation; either version 2
00005 of the License, or (at your option) any later version.
00006 
00007 This program is distributed in the hope that it will be useful,
00008 but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 GNU General Public License for more details.
00011 
00012 You should have received a copy of the GNU General Public License
00013 along with this program; if not, write to the Free Software
00014 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00015 
00016 Copyright (C) Michael J. Meyer
00017 
00018 matmjm@mindspring.com
00019 spyqqqdia@yahoo.com
00020 
00021 */
00022 
00023 #ifndef martingale_basketlattice_h    
00024 #define martingale_basketlattice_h
00025 
00026 #include "TypedefsMacros.h"
00027 #include "Matrix.h"             // direct members must have fully specified type
00028 #include "Lattice.h"            // base class template
00029 #include "Node.h"               // base class template parameter
00030 
00031 
00032 MTGL_BEGIN_NAMESPACE(Martingale)
00033 
00034 
00035 
00036 
00126 /**********************************************************************************
00127  *
00128  *         LATTICE FOR A BASKET OF ASSETS WITH CONSTANT VOLATILITIES
00129  *
00130  *********************************************************************************/
00131  
00132  
00133 // forward declarations
00134 class ConstantFactorLoading;
00135 class std::ostream;
00136  
00137  
00138 
00139 
00144 class BasketLattice : public Lattice<StandardBrownianNode> {
00145         
00146 protected:
00147         
00148         ConstantFactorLoading* fl;   // the asst factor loading
00149         
00150         int      n_,          T_,       r_;
00154         
00156         Real dt;
00158         Real a;
00160         const RealArray1D& sg;
00162         RealArray1D log_S0;
00164         RealArray1D mu;  
00166         const RealMatrix& R;     
00167 
00168         
00169 public:
00170 
00171 // ACCESSORS
00172 
00175 int getDimension() const { return n_; }
00176         
00178 Real getTimeStep(){ return dt; }
00179         
00181 RealArray1D& get_log_S0() { return log_S0; }
00182         
00184 ConstantFactorLoading* getFactorLoading(){ return fl; }
00185         
00187 Real transitionProbability(int i){ return 1.0/(2<<r_); }
00188 
00189         
00190 // ERROR IN THE RANK 2 FATCORIZATION OF THE COVARIANCE MATRICES
00191         
00195 void testFactorization() const;
00196         
00197         
00198 // CONSTRUCTOR
00199         
00208 BasketLattice
00209 (int r, ConstantFactorLoading* fl, int T, Real dt, RealArray1D S0);
00210 
00211 virtual ~BasketLattice(){ }
00212 
00213 
00219 static BasketLattice* sample(int r, int n, int T);
00220 
00221 std::ostream& printSelf(std::ostream& os) const;
00222 
00223 
00227 static void test(int r, int n, int T);
00228                 
00229 
00230 private:
00231         
00232 // build lattice with m time steps.
00233 void buildLattice(int m, bool verbose);
00234 
00235 
00236         static RealArray1D S_;           // workspace for the assets H_j
00237         static RealArray1D V_;           // workspace for volatility parts V_j of the log(S_j)
00238                                          // book, 3.11 and 8.1.
00239 
00240   
00241 }; // end BasketLattice
00242 
00243 
00244 // out of class initialization necessary
00245 RealArray1D BasketLattice::S_(BASKET_MAX_DIM);
00246 RealArray1D BasketLattice::V_(BASKET_MAX_DIM);
00247 
00248 
00249 
00250 
00251 MTGL_END_NAMESPACE(Martingale)
00252 
00253 #endif
00254  

Generated on Mon Sep 22 02:16:32 2003 for Libor-Library by doxygen1.3-rc3