1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*
4  Copyright (C) 2005, 2006 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 #include <ql/math/matrixutilities/pseudosqrt.hpp>
21 #include <ql/legacy/libormarketmodels/lmcorrmodel.hpp>
22 
23 namespace QuantLib {
24 
LmCorrelationModel(Size size,Size nArguments)25     LmCorrelationModel::LmCorrelationModel(Size size, Size nArguments)
26     : size_(size), arguments_(nArguments) {}
27 
size() const28     Size LmCorrelationModel::size() const {
29         return size_;
30     }
31 
factors() const32     Size LmCorrelationModel::factors() const {
33         return size_;
34     }
35 
isTimeIndependent() const36     bool LmCorrelationModel::isTimeIndependent() const {
37         return false;
38     }
39 
pseudoSqrt(Time t,const Array & x) const40     Disposable<Matrix> LmCorrelationModel::pseudoSqrt(
41         Time t, const Array& x) const {
42         return QuantLib::pseudoSqrt(this->correlation(t, x),
43                                     SalvagingAlgorithm::Spectral);
44     }
45 
correlation(Size i,Size j,Time t,const Array & x) const46     Real LmCorrelationModel::correlation(
47         Size i, Size j, Time t, const Array& x) const {
48         // inefficient implementation, please overload in derived classes
49         return correlation(t, x)[i][j];
50     }
51 
52 
params()53     std::vector<Parameter>& LmCorrelationModel::params() {
54         return arguments_;
55     }
56 
setParams(const std::vector<Parameter> & arguments)57     void LmCorrelationModel::setParams(
58         const std::vector<Parameter> & arguments) {
59         arguments_ = arguments;
60         generateArguments();
61     }
62 
63 }
64 
65