Newer
Older
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
/* minimize
Tim Behrens, FMRIB Image Analysis Group
Copyright (C) 1999-2000 University of Oxford */
/* CCOPYRIGHT */
#if !defined(minimize_h)
#define minimize_h
#include <string>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <vector>
#include <algorithm>
#include "newmatap.h"
#include "newmatio.h"
#include "miscmaths/miscmaths.h"
#define WANT_STREAM
#define WANT_MATH
using namespace MISCMATHS;
using namespace NEWMAT;
using namespace std;
///////////////////////////////////////////////////////
//fminsearch.m
namespace MISCMATHS {
class pair_comparer
{
public:
bool operator()(const pair<float,ColumnVector>& p1,const pair<float,ColumnVector>& p2) const
{
return p1.first < p2.first;
}
};
class EvalFunction
{
public:
EvalFunction(){}
virtual float evaluate(const ColumnVector& x) const = 0;
virtual ~EvalFunction(){};
private:
const EvalFunction& operator=(EvalFunction& par);
EvalFunction(const EvalFunction&);
};
float diff1(const ColumnVector& x, const EvalFunction& func, int i,float h,int errorord=4);
float diff2(const ColumnVector& x, const EvalFunction& func, int i,float h,int errorord=4);
float diff2(const ColumnVector& x, const EvalFunction& func, int i,int j,float h,int errorord=4);
ReturnMatrix hessian(const ColumnVector& x, const EvalFunction& func,float h,int errorord=4);
void minimize(ColumnVector& x, const EvalFunction& func);
}
#endif