C#, Calcul numérique - Méthode de calcul et programme source de Frprmn

 

utiliser le système ;

espace de noms Legalsoft.Truffer
{     public class Frprmn : Dlinemethod     {         private inter { get; ensemble; }         double frette privée { get ; ensemble; }         double privé ftol { obtenir ; ensemble; }




        public Frprmn(RealValueFunWithDiff funcd, double ftoll = 3.0e-8) : base(funcd)
        {             this.ftol = ftoll;         }

        public double[] minimiser(double[] pp)
        {             const int ITMAX = 200;             const double EPS = 1.0e-18 ;             const double GTOL = 1.0e-8 ;


            int n = pp. Longueur ;
            //p = pp;
            p = Globals.CopyFrom(pp);
            double[] g = nouveau double[n] ;
            double[] h = nouveau double[n] ;
            //xi.resize(n);
            xi = nouveau double[n] ;
            double fp = func.funk(p);
            func.df(p, xi);
            for (int j = 0; j < n; j++)
            {                 g[j] = -xi[j];                 xi[j] = h[j] = g[j] ;             }             for (int son = 0; son < ITMAX; son++)             {                 iter = son;                 frette = linmin();







                if (2.0 * Math.Abs(fret - fp) <= ftol * (Math.Abs(fret) + Math.Abs(fp) + EPS)) {
                return                     p;                 }                 fp = frette ;                 func.df(p, xi);                 test double = 0,0 ;                 double den = Math.Max(Math.Abs(fp), 1.0);                 for (int j = 0; j < n; j++)                 {                     double temp = Math.Abs(xi[j]) * Math.Max(Math.Abs(p[j]), 1.0) / den;                     if (temp > test)                     {                         test = temp;                     }                 }














                if (test < GTOL)
                {                     return p;                 }                 double dgg = 0.0 ;                 double gg = 0,0 ;                 for (int j = 0; j < n; j++)                 {                     gg += g[j] * g[j];                     // dgg += xi[j]*xi[j] ;                     dgg += (xi[j] + g[j]) * xi[j] ;                 }                 //if (gg == 0.0)                 if (Math.Abs(gg) <= float.Epsilon)                 {                     return p;                 }                 double gam = dgg / gg ;
















                for (int j = 0; j < n; j++)
                {                     g[j] = -xi[j];                     xi[j] = h[j] = g[j] + gam * h[j] ;                 }             }             throw new Exception("Trop d'itérations dans frprmn");         }     } }








 

Je suppose que tu aimes

Origine blog.csdn.net/beijinghorn/article/details/132219001
conseillé
Classement