Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13240


Ignore:
Timestamp:
11/18/15 10:33:51 (9 years ago)
Author:
gkronber
Message:

#2485: merged r13116 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs

    r13047 r13240  
    8989          FormatFunction(node, "Math.Sin", strBuilder);
    9090        } else if (node.Symbol is Subtraction) {
    91           FormatOperator(node, "-", strBuilder);
     91          FormatSubtraction(node, strBuilder);
    9292        } else if (node.Symbol is Tangent) {
    9393          FormatFunction(node, "Math.Tan", strBuilder);
     
    145145    }
    146146
     147    private void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     148      if (node.SubtreeCount == 1) {
     149        strBuilder.Append("-");
     150        FormatRecursively(node.GetSubtree(0), strBuilder);
     151        return;
     152      }
     153      //Default case: more than 1 child
     154      FormatOperator(node, "-", strBuilder);
     155    }
     156
    147157    private void FormatOperator(ISymbolicExpressionTreeNode node, string symbol, StringBuilder strBuilder) {
    148158      strBuilder.Append("(");
     
    179189      }
    180190
    181       var orderedNames = varNames.OrderBy(n => n, new NaturalStringComparer()).Select(n=> "double " + n);
     191      var orderedNames = varNames.OrderBy(n => n, new NaturalStringComparer()).Select(n => "double " + n);
    182192      strBuilder.Append(string.Join(", ", orderedNames));
    183193
Note: See TracChangeset for help on using the changeset viewer.