Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/03/12 00:32:03 (12 years ago)
Author:
gkronber
Message:

#1810 merged patch to add square and square root function symbols by mkommend

File:
1 edited

Legend:

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

    r7653 r7695  
    2020#endregion
    2121
     22using System.Globalization;
    2223using System.Text;
    23 using System.Linq;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    25 using HeuristicLab.Common;
     26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using HeuristicLab.Problems.DataAnalysis;
    28 using System.Collections.Generic;
    29 using System;
    30 using System.Globalization;
    31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3228
    3329namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    8480    }
    8581
    86     public string FormatOnlyExpression(ISymbolicExpressionTreeNode expressionNode)
    87     {
     82    public string FormatOnlyExpression(ISymbolicExpressionTreeNode expressionNode) {
    8883      var stringBuilder = new StringBuilder();
    8984      stringBuilder.AppendLine("  for " + CurrentIndexVariable + " = 1:1:rows");
     
    151146      } else if (symbol is Exponential) {
    152147        stringBuilder.Append("exp(");
     148        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     149        stringBuilder.Append(")");
     150      } else if (symbol is Square) {
     151        stringBuilder.Append("(");
     152        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     153        stringBuilder.Append(").^2");
     154      } else if (symbol is SquareRoot) {
     155        stringBuilder.Append("sqrt(");
    153156        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    154157        stringBuilder.Append(")");
     
    283286
    284287
    285     private string LagToString(int lag)
    286     {
     288    private string LagToString(int lag) {
    287289      if (lag < 0) {
    288290        return "(" + CurrentIndexVariable + "" + lag + ")";
Note: See TracChangeset for help on using the changeset viewer.