opt.h
Go to the documentation of this file.
1 /*
2  Harmonic sinusoidal modelling and tools
3 
4  C++ code package for harmonic sinusoidal modelling and relevant signal processing.
5  Centre for Digital Music, Queen Mary, University of London.
6  This file copyright 2011 Wen Xue.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 */
13 #ifndef optH
14 #define optH
15 
16 /*
17  opt.cpp - optimization routines
18 */
19 
20 //--tool procedures----------------------------------------------------------
21 double nextdouble(double x, double dir); //returns next double-precision floating pointer number
22 
23 //--Gradient method----------------------------------------------------------
24 double GradientMax(void* params, double (*F)(int, double*, void*), void (*dF)(double*, int, double*, void*), int dim, double* start, double ep=1e-6, int maxiter=100);
25 double GradientOneMax(void* params, double (*F)(int, double*, void*), void (*dF)(double*, int, double*, void*), int dim, double* start, double ep, int maxiter);
26 
27 //--Newton methods------------------------------------------------------------
28 double Newton(double& x0, double (*y)(double, void*), double (*y1)(double, void*), void* params=0, double epx=1e-6, int maxiter=100, double epy=1e-256);
29 int Newton(double& x0, double (*dy)(double, void*), void* params, int yshift, double epx=1e-6, int maxiter=100, double epy=1e-256, double xmin=-1e308, double xmax=1e308);
30 double Newton1dmax(double& x0, double xa, double xb, double (*ddy)(double, void*), void* params, int y1shift, int yshift, double (*dy)(double, void*), int dyshift, double epx=1e-6, int maxiter=100, double epdy=1e-128, bool checkinput=true);
31 double Newton2D(double& x1, double& x2, double (*dy)(double&, double&, void*), double (*ddy)(double&, double&, double&, void*), void* params=0, double epx1=1e-6, double epx2=1e-6, int maxiter=100, double epdy=1e-256);
32 
33 //--root search routines-----------------------------------------------------
34 double rootsearchhalf(double&x1, double x2, double (*y)(double, void*), void* params=0, double epx=1e-6, int maxiter=100);
35 double rootsearchsecant(double& x1, double x2, double (*y)(double, void*), void* params=0, double epx=1e-6, int maxiter=100);
36 double rootsearchbisecant(double&x1, double x2, double (*y)(double, void*), void* params=0, double epx=1e-6, int maxiter=100);
37 
38 //--1-D maximum search routines----------------------------------------------
39 double Search1Dmax(double& x, void* params, double (*F)(double, void*), double inf, double sup, double* maxresult=0, double ep=1e-6, int maxiter=100, bool convcheck=false);
40 double Search1DmaxEx(double& x, void* params, double (*F)(double, void*), double inf, double sup, double* maxresult=0, double ep=1e-6, int maxiter=100, double len=1);
41 double Search1Dmaxfrom(void* params, double (*F)(int, double*, void*), int dim, double* start, double* direct, double step=1e-2, double minstep=1e-6, double maxstep=1e6, double* opt=0, double* max=0, double ep=1e-6, int maxiter=100, bool convcheck=false);
42 
43 #endif
double rootsearchsecant(double &x1, double x2, double(*y)(double, void *), void *params=0, double epx=1e-6, int maxiter=100)
Definition: opt.cpp:959
double rootsearchbisecant(double &x1, double x2, double(*y)(double, void *), void *params=0, double epx=1e-6, int maxiter=100)
Definition: opt.cpp:1022
double Newton(double &x0, double(*y)(double, void *), double(*y1)(double, void *), void *params=0, double epx=1e-6, int maxiter=100, double epy=1e-256)
Definition: opt.cpp:144
double Search1Dmax(double &x, void *params, double(*F)(double, void *), double inf, double sup, double *maxresult=0, double ep=1e-6, int maxiter=100, bool convcheck=false)
Definition: opt.cpp:1124
double rootsearchhalf(double &x1, double x2, double(*y)(double, void *), void *params=0, double epx=1e-6, int maxiter=100)
Definition: opt.cpp:906
double Search1DmaxEx(double &x, void *params, double(*F)(double, void *), double inf, double sup, double *maxresult=0, double ep=1e-6, int maxiter=100, double len=1)
Definition: opt.cpp:1194
double GradientOneMax(void *params, double(*F)(int, double *, void *), void(*dF)(double *, int, double *, void *), int dim, double *start, double ep, int maxiter)
Definition: opt.cpp:71
double Search1Dmaxfrom(void *params, double(*F)(int, double *, void *), int dim, double *start, double *direct, double step=1e-2, double minstep=1e-6, double maxstep=1e6, double *opt=0, double *max=0, double ep=1e-6, int maxiter=100, bool convcheck=false)
Definition: opt.cpp:1233
double Newton1dmax(double &x0, double xa, double xb, double(*ddy)(double, void *), void *params, int y1shift, int yshift, double(*dy)(double, void *), int dyshift, double epx=1e-6, int maxiter=100, double epdy=1e-128, bool checkinput=true)
Definition: opt.cpp:766
double GradientMax(void *params, double(*F)(int, double *, void *), void(*dF)(double *, int, double *, void *), int dim, double *start, double ep=1e-6, int maxiter=100)
Definition: opt.cpp:39