Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8952


Ignore:
Timestamp:
11/27/12 13:35:51 (12 years ago)
Author:
mkommend
Message:

#1976: Performance improvements in AutoDiff library.

Location:
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.AutoDiff/1.0/AutoDiff-1.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.AutoDiff/1.0/AutoDiff-1.0/CompiledDifferentiator.cs

    r8703 r8952  
    5454            ReverseSweep();
    5555
    56             var gradient = tape.Take(Dimension).Select(elem => elem.Adjoint).ToArray();
    57             var value = tape.Last().Value;
     56            var gradient = new double[Dimension];
     57            for (int i = 0; i < Dimension; i++)
     58               gradient[i] = tape[i].Adjoint;
     59            var value = tape.Last().Value;           
    5860
    5961            return Tuple.Create(gradient, value);
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.AutoDiff/1.0/AutoDiff-1.0/ParametricCompiledTerm.cs

    r8703 r8952  
    2020        public double Evaluate(double[] arg, double[] parameters)
    2121        {
    22             var combinedArg = arg.Concat(parameters).ToArray();
     22            var combinedArg = new double[arg.Length + parameters.Length];
     23            arg.CopyTo(combinedArg, 0);
     24            parameters.CopyTo(combinedArg, arg.Length);
    2325            return compiledTerm.Evaluate(combinedArg);
    2426        }
     
    2628        public Tuple<double[], double> Differentiate(double[] arg, double[] parameters)
    2729        {
    28             var combinedArg = arg.Concat(parameters).ToArray();
     30            var combinedArg = new double[arg.Length + parameters.Length];
     31            arg.CopyTo(combinedArg, 0);
     32            parameters.CopyTo(combinedArg, arg.Length);
    2933            var diffResult = compiledTerm.Differentiate(combinedArg);
    3034
Note: See TracChangeset for help on using the changeset viewer.