1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2010 Klaus Spanderen 5 6 This file is part of QuantLib, a free-software/open-source library 7 for financial quantitative analysts and developers - http://quantlib.org/ 8 9 QuantLib is free software: you can redistribute it and/or modify it 10 under the terms of the QuantLib license. You should have received a 11 copy of the license along with this program; if not, please email 12 <quantlib-dev@lists.sf.net>. The license is also available online at 13 <http://quantlib.org/license.shtml>. 14 15 This program is distributed in the hope that it will be useful, but WITHOUT 16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 17 FOR A PARTICULAR PURPOSE. See the license for more details. 18 */ 19 20 21 /*! \file fdm2dblackscholesop.hpp 22 */ 23 24 #ifndef quantlib_fdm_2d_black_scholes_op_hpp 25 #define quantlib_fdm_2d_black_scholes_op_hpp 26 27 #include <ql/methods/finitedifferences/operators/ninepointlinearop.hpp> 28 #include <ql/methods/finitedifferences/operators/fdmblackscholesop.hpp> 29 #include <ql/methods/finitedifferences/operators/fdmlinearopcomposite.hpp> 30 31 namespace QuantLib { 32 33 class FdmMesher; 34 class GeneralizedBlackScholesProcess; 35 36 class Fdm2dBlackScholesOp : public FdmLinearOpComposite { 37 public: 38 Fdm2dBlackScholesOp( 39 const ext::shared_ptr<FdmMesher>& mesher, 40 const ext::shared_ptr<GeneralizedBlackScholesProcess>& p1, 41 const ext::shared_ptr<GeneralizedBlackScholesProcess>& p2, 42 Real correlation, 43 Time maturity, 44 bool localVol = false, 45 Real illegalLocalVolOverwrite = -Null<Real>()); 46 47 Size size() const; 48 void setTime(Time t1, Time t2); 49 Disposable<Array> apply(const Array& x) const; 50 Disposable<Array> apply_mixed(const Array& x) const; 51 52 Disposable<Array> apply_direction(Size direction,const Array& x) const; 53 54 Disposable<Array> solve_splitting(Size direction, 55 const Array& x, Real s) const; 56 Disposable<Array> preconditioner(const Array& r, Real s) const; 57 58 #if !defined(QL_NO_UBLAS_SUPPORT) 59 Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const; 60 #endif 61 private: 62 const ext::shared_ptr<FdmMesher> mesher_; 63 const ext::shared_ptr<GeneralizedBlackScholesProcess> p1_, p2_; 64 const ext::shared_ptr<LocalVolTermStructure> localVol1_, localVol2_; 65 const Array x_, y_; 66 67 Real currentForwardRate_; 68 FdmBlackScholesOp opX_, opY_; 69 NinePointLinearOp corrMapT_; 70 const NinePointLinearOp corrMapTemplate_; 71 const Real illegalLocalVolOverwrite_; 72 }; 73 } 74 #endif 75