- Timestamp:
- 05/07/19 14:20:33 (6 years ago)
- Location:
- trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
r16802 r16905 140 140 FormatPower(node, strBuilder, "3"); 141 141 } else if (node.Symbol is CubeRoot) { 142 FormatPower(node, strBuilder, "1.0/3"); 142 strBuilder.Append("Cbrt("); 143 FormatRecursively(node.GetSubtree(0), strBuilder); 144 strBuilder.Append(")"); 143 145 } else if (node.Symbol is Power) { 144 146 FormatFunction(node, "Math.Pow", strBuilder); … … 252 254 strBuilder.AppendLine("public static class Model {"); 253 255 GenerateAverageSource(strBuilder); 256 GenerateCbrtSource(strBuilder); 254 257 GenerateIfThenElseSource(strBuilder); 255 258 GenerateFactorSource(strBuilder); … … 293 296 strBuilder.AppendLine("private static double Average(params double[] values) {"); 294 297 strBuilder.AppendLine(" return values.Average();"); 298 strBuilder.AppendLine("}"); 299 } 300 private void GenerateCbrtSource(StringBuilder strBuilder) { 301 strBuilder.AppendLine("private static double Cbrt(double x) {"); 302 strBuilder.AppendLine(" return x < 0 ? -Math.Pow(-x, 1.0 / 3.0) : Math.Pow(x, 1.0 / 3.0);"); 295 303 strBuilder.AppendLine("}"); 296 304 } -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r16868 r16905 144 144 stringBuilder.Append($"POWER({FormatRecursively(node.GetSubtree(0))}, 3)"); 145 145 } else if (symbol is CubeRoot) { 146 stringBuilder.Append($"POWER({FormatRecursively(node.GetSubtree(0))}, 1/3)"); 146 var arg_expr = FormatRecursively(node.GetSubtree(0)); 147 stringBuilder.Append($"IF({arg_expr} < 0, -POWER(-{arg_expr}, 1/3), POWER({arg_expr}, 1/3))"); 147 148 } else if (symbol is Division) { 148 149 if (node.SubtreeCount == 1) { -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r16802 r16905 138 138 strBuilder.Append(@"\left("); 139 139 } else if (node.Symbol is CubeRoot) { 140 strBuilder.Append(@"\ left(");140 strBuilder.Append(@"\operatorname{cbrt}\left("); 141 141 } else if (node.Symbol is Sine) { 142 142 strBuilder.Append(@"\sin \left( "); … … 420 420 strBuilder.Append(@"\right)^3"); 421 421 } else if (node.Symbol is CubeRoot) { 422 strBuilder.Append(@"\right) ^\frac{1}{3}");422 strBuilder.Append(@"\right)"); 423 423 } else if (node.Symbol is Sine) { 424 424 strBuilder.Append(@" \right) "); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs
r16802 r16905 188 188 stringBuilder.Append(").^3"); 189 189 } else if (symbol is CubeRoot) { 190 stringBuilder.Append(" (");191 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 192 stringBuilder.Append(" ).^(1/3)");190 stringBuilder.Append("NTHROOT("); 191 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 192 stringBuilder.Append(", 3)"); 193 193 } else if (symbol is GreaterThan) { 194 194 stringBuilder.Append("(("); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs
r16802 r16905 115 115 FormatPower(node, strBuilder, "3"); 116 116 } else if (node.Symbol is CubeRoot) { 117 FormatPower(node, strBuilder, "1/3"); 117 strBuilder.Append("CubeRoot["); 118 FormatRecursively(node.GetSubtree(0), strBuilder); 119 strBuilder.Append("]"); 118 120 } else if (node.Symbol is Power) { 119 121 FormatFunction(node, "Power", strBuilder); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs
r16802 r16905 92 92 stringBuilder.Append(FormatPower(node.GetSubtree(0), "3")); 93 93 } else if (symbol is CubeRoot) { 94 stringBuilder.Append(FormatPower(node.GetSubtree(0), "(1/3)")); 94 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 95 stringBuilder.Append(" cbrt"); 95 96 } else if (symbol is Division) { 96 97 if (node.SubtreeCount == 1) {
Note: See TracChangeset
for help on using the changeset viewer.