Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/04/10 17:43:04 (13 years ago)
Author:
swinkler
Message:

Worked on MATLAB formatter, added special version of log function that behaves like Math.Log. (#1314)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis.Extensions/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Formatters/SymbolicExpressionTreeMATLABFormatter.cs

    r5021 r5022  
    5959          .Distinct()
    6060          .OrderBy(x => x);
     61        stringBuilder.AppendLine("function test_model");
    6162        foreach (string variableName in variableNames)
    62           stringBuilder.AppendLine(variableName + " = Data(:, ???);");
     63          stringBuilder.AppendLine("  " + variableName + " = Data(:, ???);");
    6364        stringBuilder.AppendLine();
    64         stringBuilder.AppendLine("Target_estimated(i) = " + FormatRecursively(node.SubTrees[0]));
     65        stringBuilder.AppendLine("  for i = size(Data,1):-1:1");
     66        stringBuilder.AppendLine("    Target_estimated(i) = " + FormatRecursively(node.SubTrees[0]) + ";");
     67        stringBuilder.AppendLine();
     68        stringBuilder.AppendLine("function y = log_(x)");
     69        stringBuilder.AppendLine("  if(x<=0) y = NaN;");
     70        stringBuilder.AppendLine("  else     y = log(x);");
    6571        return stringBuilder.ToString();
    6672      }
     
    148154        stringBuilder.Append(")-0.5)*2"); // MATLAB maps false and true to 0 and 1, resp., we map this result to -1.0 and +1.0, resp.
    149155      } else if (symbol is Logarithm) {
    150         stringBuilder.Append("log(");
     156        stringBuilder.Append("log_(");
    151157        stringBuilder.Append(FormatRecursively(node.SubTrees[0]));
    152158        stringBuilder.Append(")");
Note: See TracChangeset for help on using the changeset viewer.