jawinston
03-08-2008, 03:26 PM
In function frprmn we have the following C code:
(from function frprmn, NR in C, Second Edition, page 423-424)
...
(*dfunc)(p,xi);
dgg=gg=0.0;
for(j=1;j<=n;j++) {
gg += g[j]*g[j];
dgg += (xi[j]+g[j])*xi[j];
}
if(gg == 0) {
FREEALL
return;
}
...
I get a problem when dfunc returns a zero vector for the gradiant, xi. The check below ( if(gg == 0)) misses this, since it is checking g, the negative of the previous gradient. Then when I go into linmin on the next iteration with xi = zero vector, my results are meaningless.
Shouldn't there be a test on xi, before we use it? Thanks for any help!
(from function frprmn, NR in C, Second Edition, page 423-424)
...
(*dfunc)(p,xi);
dgg=gg=0.0;
for(j=1;j<=n;j++) {
gg += g[j]*g[j];
dgg += (xi[j]+g[j])*xi[j];
}
if(gg == 0) {
FREEALL
return;
}
...
I get a problem when dfunc returns a zero vector for the gradiant, xi. The check below ( if(gg == 0)) misses this, since it is checking g, the negative of the previous gradient. Then when I go into linmin on the next iteration with xi = zero vector, my results are meaningless.
Shouldn't there be a test on xi, before we use it? Thanks for any help!