项目作者: simeonschaub

项目描述 :
Julia interface for GNU Diffutils
高级语言: Julia
项目地址: git://github.com/simeonschaub/DiffUtils.jl.git
创建时间: 2021-01-12T19:55:29Z
项目社区:https://github.com/simeonschaub/DiffUtils.jl

开源协议:MIT License

下载


DiffUtils

Stable
Dev
Build Status
Coverage

Example

For more details, please read the docs.

  1. julia> using DiffUtils
  2. julia> DiffUtils.diff(code_lowered(cos, Tuple{Float64}), code_lowered(sin, Tuple{Float64}))
  3. Core.CodeInfo[CodeInfo( Core.CodeInfo[CodeInfo(
  4. 1 ── Core.NewvarNode(:(@_3)) 1 ── Core.NewvarNode(:(@_3))
  5. Core.NewvarNode(:(y)) Core.NewvarNode(:(y))
  6. Core.NewvarNode(:(n)) Core.NewvarNode(:(n))
  7. absx = Base.Math.abs(x) absx = Base.Math.abs(x)
  8. %5 = absx %5 = absx
  9. %6 = ($(Expr(:static_parameter, 1)))(Base.Math.pi) %6 = ($(Expr(:static_parameter, 1)))(Base.Math.pi)
  10. %7 = %6 / 4 %7 = %6 / 4
  11. %8 = %5 < %7 %8 = %5 < %7
  12. └─── goto #5 if not %8 └─── goto #5 if not %8
  13. 2 ── %10 = absx 2 ── %10 = absx
  14. %11 = Base.Math.eps($(Expr(:static_parameter, 1))) %11 = Base.Math.eps($(Expr(:static_parameter, 1)))
  15. %12 = ($(Expr(:static_parameter, 1)))(2.0) | %12 = Base.Math.sqrt(%11)
  16. %13 = %11 / %12 | %13 = %10 < %12
  17. %14 = Base.Math.sqrt(%13) | └─── goto #4 if not %13
  18. %15 = %10 < %14 | 3 ── return x
  19. └─── goto #4 if not %15 | 4 ── %16 = Base.Math.sin_kernel(x)
  20. 3 ── %17 = ($(Expr(:static_parameter, 1)))(1.0) | └─── return %16
  21. └─── return %17 | 5 ── %18 = Base.Math.isnan(x)
  22. 4 ── %19 = Base.Math.cos_kernel(x) | └─── goto #7 if not %18
  23. └─── return %19 | 6 ── %20 = ($(Expr(:static_parameter, 1)))(Base.Math.NaN)
  24. 5 ── %21 = Base.Math.isnan(x) | └─── return %20
  25. └─── goto #7 if not %21 | 7 ── %22 = Base.Math.isinf(x)
  26. 6 ── %23 = ($(Expr(:static_parameter, 1)))(Base.Math.NaN) | └─── goto #9 if not %22
  27. └─── return %23 | 8 ── Base.Math.sin_domain_error(x)
  28. 7 ── %25 = Base.Math.isinf(x) | 9 ┄─ %25 = Base.Math.rem_pio2_kernel(x)
  29. └─── goto #9 if not %25 | │ %26 = Base.indexed_iterate(%25, 1)
  30. 8 ── %27 = Base.Math.cos_domain_error(x) | n = Core.getfield(%26, 1)
  31. └─── return %27 | @_3 = Core.getfield(%26, 2)
  32. 9 ── %29 = Base.Math.rem_pio2_kernel(x) | %29 = Base.indexed_iterate(%25, 2, @_3)
  33. %30 = Base.indexed_iterate(%29, 1) | y = Core.getfield(%29, 1)
  34. n = Core.getfield(%30, 1) <
  35. @_3 = Core.getfield(%30, 2) <
  36. %33 = Base.indexed_iterate(%29, 2, @_3) <
  37. y = Core.getfield(%33, 1) <
  38. n = n & 3 n = n & 3
  39. %36 = n == 0 | %32 = n == 0
  40. └─── goto #11 if not %36 | └─── goto #11 if not %32
  41. 10 %38 = Base.Math.cos_kernel(y) | 10 %34 = Base.Math.sin_kernel(y)
  42. > └─── return %34
  43. > 11 %36 = n == 1
  44. > └─── goto #13 if not %36
  45. > 12 %38 = Base.Math.cos_kernel(y)
  46. └─── return %38 └─── return %38
  47. 11 %40 = n == 1 | 13 %40 = n == 2
  48. └─── goto #13 if not %40 | └─── goto #15 if not %40
  49. 12 %42 = Base.Math.sin_kernel(y) | 14 %42 = Base.Math.sin_kernel(y)
  50. %43 = -%42 %43 = -%42
  51. └─── return %43 └─── return %43
  52. 13 %45 = n == 2 | 15 %45 = Base.Math.cos_kernel(y)
  53. └─── goto #15 if not %45 | │ %46 = -%45
  54. 14 %47 = Base.Math.cos_kernel(y) | └─── return %46
  55. %48 = -%47 <
  56. └─── return %48 <
  57. 15 %50 = Base.Math.sin_kernel(y) <
  58. └─── return %50 <
  59. )] )]