Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters
Files:
2 edited

Legend:

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

    r7462 r7695  
    112112      } else if (node.Symbol is Exponential) {
    113113        strBuilder.Append(@"\exp \left( ");
     114      } else if (node.Symbol is Square) {
     115        strBuilder.Append(@"\left(");
     116      } else if (node.Symbol is SquareRoot) {
     117        strBuilder.Append(@"\sqrt{");
    114118      } else if (node.Symbol is Sine) {
    115119        strBuilder.Append(@"\sin \left( ");
     
    209213      } else if (node.Symbol is Exponential) {
    210214        throw new InvalidOperationException();
     215      } else if (node.Symbol is Square) {
     216        throw new InvalidOperationException();
     217      } else if (node.Symbol is SquareRoot) {
     218        throw new InvalidOperationException();
    211219      } else if (node.Symbol is Sine) {
    212220        throw new InvalidOperationException();
     
    266274      } else if (node.Symbol is Exponential) {
    267275        strBuilder.Append(@" \right) ");
     276      } else if (node.Symbol is Square) {
     277        strBuilder.Append(@"\right)^2");
     278      } else if (node.Symbol is SquareRoot) {
     279        strBuilder.Append(@"}");
    268280      } else if (node.Symbol is Sine) {
    269281        strBuilder.Append(@" \right) ");
  • 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.