-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfdjac.c
More file actions
29 lines (27 loc) · 662 Bytes
/
fdjac.c
File metadata and controls
29 lines (27 loc) · 662 Bytes
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
#include "decs.h"
#define NRANSI
#include "NRUTIL.H"
// smaller doesn't always mean better
//#define EPS (NUMSQRTEPSILON*10)
#define EPS (1E-4)
void fdjac(int n, FTYPE parms[], FTYPE x[], FTYPE fvec[], FTYPE **df,
void (*vecfunc)(int n, FTYPE parms[], FTYPE v[], FTYPE f[]))
{
int i,j;
FTYPE h,temp,*f;
f=vector(1,n);
for (j=1;j<=n;j++) {
temp=x[j];
h=EPS*fabs(temp);
if (h == 0.0) h=EPS;
x[j]=temp+h;
h=x[j]-temp;
(*vecfunc)(n,parms,x,f);
x[j]=temp;
for (i=1;i<=n;i++) df[i][j]=(f[i]-fvec[i])/h;
}
free_vector(f,1,n);
}
#undef EPS
#undef NRANSI
/* (C) Copr. 1986-92 Numerical Recipes Software *1.@Q.. */