summaryrefslogtreecommitdiff
path: root/support/dktools/dk4itmin.h
blob: 45784d1933a1df174ae20fa15574b55d78e82a9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
Copyright (C) 2019-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/

/*
	WARNING: This file was generated by the dkct program (see
	http://dktools.sourceforge.net/ for details).
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: dk4itmin.ctr
*/

#ifndef DK4ITMIN_H_INCLUDED
/** Avoid multiple inclusions. */
#define DK4ITMIN_H_INCLUDED 1


#line 10 "dk4itmin.ctr"

/**	@file	dk4itmin.h	Iteration algorithms for minimum search.
Iteration can be used on functions unimodal on interval [a;b] only.
This means the function must have exactly one local minimum on
interval [a;b], no local maximum.

To search for a maximum of f(x) simply search for the minimum of
the 0-f(x) function.
*/


#ifndef	DK4ITER_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4iter.h"
#else
#include <dktools-4/dk4iter.h>
#endif
#endif

#ifdef	__cplusplus
extern "C" {
#endif

/**	Run iteration for minimum search.
	@param	d	Address of result array, 2 elements: x-value and y-value.
	@param	pp	Address of variable to store number of passes, may be NULL.
	@param	fct	Function to find minimum for.
				The function must be unimodal on [a;b], the dk4itmin_interval()
				function can not check this.
	@param	ps	Parameter set for function, may be NULL.
	@param	a	Left interval border.
	@param	b	Right interval border.
				Required: f(c)<f(a) and f(c)<f(b).
	@param	ctx	Iteration context.
				Only eps_x and eps_y are used, other information in the
				context is ignored.
	@return	DK4_ITER_RESULT_SUCCESS on success, one from
	DK4_ITER_RESULT_E_ARGS, DK4_ITER_RESULT_E_PASSES,
	DK4_ITER_RESULT_E_INFINITE, DK4_ITER_RESULT_E_OOR, DK4_ITER_RESULT_E_CONV
	or DK4_ITER_RESULT_E_FCT on error.
*/
int
dk4itmin_interval(
	double					*d,
	unsigned long			*pp,
	dk4_iter_fct_t			*fct,
	void			const	*ps,
	double					 a,
	double					 b,
	dk4_iter_ctx_t	const	*ctx
);

#ifdef	__cplusplus
}
#endif



#endif