| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2006 Klaus Spanderen |
| 5 | Copyright (C) 2015 Peter Caspers |
| 6 | |
| 7 | This file is part of QuantLib, a free-software/open-source library |
| 8 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 9 | |
| 10 | QuantLib is free software: you can redistribute it and/or modify it |
| 11 | under the terms of the QuantLib license. You should have received a |
| 12 | copy of the license along with this program; if not, please email |
| 13 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 14 | <http://quantlib.org/license.shtml>. |
| 15 | |
| 16 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 18 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 19 | */ |
| 20 | |
| 21 | /*! \file lmdif.hpp |
| 22 | \brief wrapper for MINPACK minimization routine |
| 23 | */ |
| 24 | |
| 25 | #ifndef quantlib_optimization_lmdif_hpp |
| 26 | #define quantlib_optimization_lmdif_hpp |
| 27 | |
| 28 | #include <ql/types.hpp> |
| 29 | #include <ql/functional.hpp> |
| 30 | |
| 31 | namespace QuantLib { |
| 32 | |
| 33 | namespace MINPACK { |
| 34 | typedef ext::function<void (int, |
| 35 | int, |
| 36 | Real*, |
| 37 | Real*, |
| 38 | int*)> LmdifCostFunction; |
| 39 | |
| 40 | void lmdif(int m,int n,Real* x,Real* fvec,Real ftol, |
| 41 | Real xtol,Real gtol,int maxfev,Real epsfcn, |
| 42 | Real* diag, int mode, Real factor, |
| 43 | int nprint, int* info,int* nfev,Real* fjac, |
| 44 | int ldfjac,int* ipvt,Real* qtf, |
| 45 | Real* wa1,Real* wa2,Real* wa3,Real* wa4, |
| 46 | const LmdifCostFunction& fcn, |
| 47 | const LmdifCostFunction& jacFcn); |
| 48 | |
| 49 | void qrsolv(int n, |
| 50 | Real* r, |
| 51 | int ldr, |
| 52 | const int* ipvt, |
| 53 | const Real* diag, |
| 54 | const Real* qtb, |
| 55 | Real* x, |
| 56 | Real* sdiag, |
| 57 | Real* wa); |
| 58 | void qrfac(int m,int n,Real* a,int, int pivot,int* ipvt, |
| 59 | int,Real* rdiag,Real* acnorm,Real* wa); |
| 60 | } |
| 61 | } |
| 62 | #endif |
| 63 | |