Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/15 14:54:32 (10 years ago)
Author:
mkommend
Message:

#2363: Improved performance of symbolic expression tree simplifier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs

    r12012 r12227  
    299299        // simplify expressions x0..xn
    300300        // make multiplication (x0 * 1/(x1 * x1 * .. * xn))
    301         var simplifiedTrees = original.Subtrees.Select(x => GetSimplifiedTree(x));
     301        var simplifiedTrees = original.Subtrees.Select(GetSimplifiedTree).ToArray();
    302302        return
    303           MakeProduct(simplifiedTrees.First(), Invert(simplifiedTrees.Skip(1).Aggregate((a, b) => MakeProduct(a, b))));
     303          MakeProduct(simplifiedTrees.First(), Invert(simplifiedTrees.Skip(1).Aggregate(MakeProduct)));
    304304      }
    305305    }
     
    310310      } else {
    311311        return original.Subtrees
    312           .Select(x => GetSimplifiedTree(x))
    313           .Aggregate((a, b) => MakeProduct(a, b));
     312          .Select(GetSimplifiedTree).ToArray()
     313          .Aggregate(MakeProduct);
    314314      }
    315315    }
     
    321321        // simplify expressions x0..xn
    322322        // make addition (x0,-x1..-xn)
    323         var simplifiedTrees = original.Subtrees.Select(x => GetSimplifiedTree(x));
     323        var simplifiedTrees = original.Subtrees.Select(GetSimplifiedTree).ToArray();
    324324        return simplifiedTrees.Take(1)
    325           .Concat(simplifiedTrees.Skip(1).Select(x => Negate(x)))
    326           .Aggregate((a, b) => MakeSum(a, b));
     325          .Concat(simplifiedTrees.Skip(1).Select(Negate))
     326          .Aggregate(MakeSum);
    327327      }
    328328    }
     
    335335        // make addition (x0..xn)
    336336        return original.Subtrees
    337           .Select(x => GetSimplifiedTree(x))
    338           .Aggregate((a, b) => MakeSum(a, b));
     337          .Select(GetSimplifiedTree).ToArray()
     338          .Aggregate(MakeSum);
    339339      }
    340340    }
Note: See TracChangeset for help on using the changeset viewer.