[Index for tmp_for_tar/deriv_min.doc] [Return to Master Index]

test_dfp_min_1

(tmp_for_tar/deriv_min.doc/test_dfp_min_1.m)


Function Synopsis

dv = dff(x)

Help text

 test_dfp_min            - Test that dfp_min works

 Defines some simple functions and verifies that calling

 dfp_min on them returns the correct minimum.

 Sets 'ok' to 1 if success, 0 otherwise

 Last modified: October 2000



Cross-Reference Information

This function calls

Listing of function file tmp_for_tar/deriv_min.doc/test_dfp_min_1.m

## test_dfp_min            - Test that dfp_min works
##
## Defines some simple functions and verifies that calling
## 
## dfp_min on them returns the correct minimum.
##
## Sets 'ok' to 1 if success, 0 otherwise


## Author:        Etienne Grossmann  <etienne@isr.ist.utl.pt>
## Last modified: October 2000

ok = 1;

if ! exist ("verbose"), verbose = 0; end

P = 10+floor(30*rand(1)) ;	# Nparams
R = P+floor(30*rand(1)) ;	# Nobses

noise = 0 ;
global obsmat ;
obsmat = randn(R,P) ;
global truep ;
truep = randn(P,1) ;
xinit = randn(P,1) ;

global obses ;
obses = obsmat*truep ;
if noise, obses = adnois(obses,noise); end


function v = ff(x)
  global obsmat;
  global obses;
  v = msq( obses - obsmat*x ) ;
endfunction


function dv = dff(x)
  global obsmat;
  global obses;
  er = -obses + obsmat*x ;
  dv = 2*er'*obsmat / rows(obses) ;
endfunction



sayif(verbose, "gonna do : dfp_min\n");
if verbose,
  printf ("Nparams = P = %i,  Nobses = R = %i\n",P,R);
end

mytic() ;
[xlev,vlev,nlev] = dfp_min("ff","dff",xinit) ;
tlev = mytic() ;


if max (abs(xlev-truep )) > 100*sqrt (eps),
  sayif (verbose, "Error is too big : %8.3g\n", max (abs (xlev-truep)));
  ok = 0;
end

if verbose,
  printf ("  Costs :     init=%8.3g, final=%8.3g, best=%8.3g\n",\
	  ff(xinit), vlev, ff(truep));    
end
sayif (verbose, "   time : %8.3g\n",tlev);
sayif (verbose && ok, "All tests ok\n");

Produced by oct2html on Tue Oct 17 10:08:37 2000
Cross-Directory links are: ON