Exemple #1
0
 public static void mincgoptimize(mincgstate state, ndimensional_grad grad, ndimensional_rep rep, object obj)
 {
     if( grad==null )
         throw new alglibexception("ALGLIB: error in 'mincgoptimize()' (grad is null)");
     while( alglib.mincgiteration(state) )
     {
         if( state.needfg )
         {
             grad(state.x, ref state.innerobj.f, state.innerobj.g, obj);
             continue;
         }
         if( state.innerobj.xupdated )
         {
             if( rep!=null )
                 rep(state.innerobj.x, state.innerobj.f, obj);
             continue;
         }
         throw new alglibexception("ALGLIB: error in 'mincgoptimize' (some derivatives were not provided?)");
     }
 }
Exemple #2
0
 public static void lsfitfit(lsfitstate state, ndimensional_pfunc func, ndimensional_pgrad grad, ndimensional_phess hess, ndimensional_rep rep, object obj)
 {
     if( func==null )
         throw new alglibexception("ALGLIB: error in 'lsfitfit()' (func is null)");
     if( grad==null )
         throw new alglibexception("ALGLIB: error in 'lsfitfit()' (grad is null)");
     if( hess==null )
         throw new alglibexception("ALGLIB: error in 'lsfitfit()' (hess is null)");
     while( alglib.lsfititeration(state) )
     {
         if( state.needf )
         {
             func(state.c, state.x, ref state.innerobj.f, obj);
             continue;
         }
         if( state.needfg )
         {
             grad(state.c, state.x, ref state.innerobj.f, state.innerobj.g, obj);
             continue;
         }
         if( state.needfgh )
         {
             hess(state.c, state.x, ref state.innerobj.f, state.innerobj.g, state.innerobj.h, obj);
             continue;
         }
         if( state.innerobj.xupdated )
         {
             if( rep!=null )
                 rep(state.innerobj.x, state.innerobj.f, obj);
             continue;
         }
         throw new alglibexception("ALGLIB: error in 'lsfitfit' (some derivatives were not provided?)");
     }
 }