Changeset 16428 for branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
- Timestamp:
- 12/21/18 10:31:49 (5 years ago)
- Location:
- branches/2845_EnhancedProgress
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2845_EnhancedProgress
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
r16311 r16428 85 85 diff: x => -(Math.Exp(-(x * x)) * Math.Sqrt(Math.Exp(x * x)) * x) / Math.Sqrt(2 * Math.PI)); 86 86 87 private static readonly Func<Term, UnaryFunc> abs = UnaryFunc.Factory( 88 eval: Math.Abs, 89 diff: x => Math.Sign(x) 90 ); 91 87 92 #endregion 88 93 … … 213 218 else return terms.Aggregate((a, b) => new AutoDiff.Product(a, 1.0 / b)); 214 219 } 220 if (node.Symbol is Absolute) { 221 var x1 = ConvertToAutoDiff(node.GetSubtree(0)); 222 return abs(x1); 223 } 224 if (node.Symbol is AnalyticQuotient) { 225 var x1 = ConvertToAutoDiff(node.GetSubtree(0)); 226 var x2 = ConvertToAutoDiff(node.GetSubtree(1)); 227 return x1 / (TermBuilder.Power(1 + x2 * x2, 0.5)); 228 } 215 229 if (node.Symbol is Logarithm) { 216 230 return AutoDiff.TermBuilder.Log( … … 228 242 return AutoDiff.TermBuilder.Power( 229 243 ConvertToAutoDiff(node.GetSubtree(0)), 0.5); 244 } 245 if (node.Symbol is Cube) { 246 return AutoDiff.TermBuilder.Power( 247 ConvertToAutoDiff(node.GetSubtree(0)), 3.0); 248 } 249 if (node.Symbol is CubeRoot) { 250 return AutoDiff.TermBuilder.Power( 251 ConvertToAutoDiff(node.GetSubtree(0)), 1.0/3.0); 230 252 } 231 253 if (node.Symbol is Sine) { … … 301 323 !(n.Symbol is Erf) && 302 324 !(n.Symbol is Norm) && 303 !(n.Symbol is StartSymbol) 325 !(n.Symbol is StartSymbol) && 326 !(n.Symbol is Absolute) && 327 !(n.Symbol is AnalyticQuotient) && 328 !(n.Symbol is Cube) && 329 !(n.Symbol is CubeRoot) 304 330 select n).Any(); 305 331 return !containsUnknownSymbol;
Note: See TracChangeset
for help on using the changeset viewer.