Skip to content

Make compatible with FastDifferentiation 0.4.5#121

Open
duetosymmetry wants to merge 1 commit into
moble:mainfrom
duetosymmetry:FastDifferentiation_update
Open

Make compatible with FastDifferentiation 0.4.5#121
duetosymmetry wants to merge 1 commit into
moble:mainfrom
duetosymmetry:FastDifferentiation_update

Conversation

@duetosymmetry

@duetosymmetry duetosymmetry commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Related issues

Closes #110 (and thereby #120)

Checklist

  • Tests are passing
  • Lint workflow is passing
  • Docs were updated and workflow is passing

FD.make_Expr changed so that in_place and init_with_zeros are both keyword args.

The code generation changed to have a bounds checking preamble before the
@inbounds (actual) code block.

The code generation changed to allow for multiple vector args, which means that
the first argument in the code is now named input_variables1 instead of
input_variables.

Minor bugfixes in ArgumentError strings that tried to interpolate the old
variable name $pnsystem instead of $fdpnsystem.

FD.make_Expr changed so that in_place and init_with_zeros are both keyword args.

The code generation changed to have a bounds checking preamble before the
@inbounds (actual) code block.

The code generation changed to allow for multiple vector args, which means that
the first argument in the code is now named input_variables1 instead of
input_variables.

Minor bugfixes in ArgumentError strings that tried to interpolate the old
variable name $pnsystem instead of $fdpnsystem.
@duetosymmetry duetosymmetry force-pushed the FastDifferentiation_update branch from 177578a to 0da2b46 Compare April 1, 2026 16:45
@duetosymmetry

Copy link
Copy Markdown
Contributor Author

Sorry for the force push, I didn't realize the linter ran JuliaFormatter and required no changes. Just updated so that JuliaFormatter will be happy.

@duetosymmetry

Copy link
Copy Markdown
Contributor Author

@moble any idea why the test is failing? It's in the test of the Hessian of the "full-order" system. Snippet:

using PostNewtonian
using ForwardDiff
using Random

Random.seed!(1234)
pn = rand(PostNewtonian.BBH; v=0.5)
function c5(u)
    pnsystem = PostNewtonian.BBH(u; PNOrder=PostNewtonian.pn_order(pn))
    inspiral = PostNewtonian.orbital_evolution(pnsystem; vₑ=0.6)
    h = PostNewtonian.inertial_waveform(inspiral)
    return sum(abs2, h)
end

∇c = ForwardDiff.gradient(c5, pn.state)
# Yields: 
# 14-element Vector{Float64}:
#   14.990245312394162
#  -54.357556232368374
#   -6.687492593541796
#   -7.527668111301677
#   11.21251862573012
#   -1.5455683131206928
#   -1.8142250030527391
#    2.3620067547668357
#   -7.476167782324888
#    0.700624861014795
#    4.86046429300934
#  -11.094029185528715
#   54.673132167863805
#    0.0

Hc = ForwardDiff.hessian(c5, pn.state)
# Yields:
# 14×14 Matrix{Float64}:
#    399.614    -1389.0     -132.137    -145.431     225.626    -27.6861    -30.1599      65.7419    -220.586     21.8922     145.274    -337.84      700.567    0.0
#  -1365.22      4794.07     434.865     480.858    -742.702     92.5739    101.411     -222.673      739.545    -72.0894    -486.346    1129.0     -2658.34     0.0
#   -130.451      436.316     41.1711     44.8527    -67.6969     9.54944    10.4588     -22.2959      52.4884   -19.0623     -48.7998    128.062    -208.203    0.0
#   -142.111      477.269     44.3957     47.6051    -74.9423    10.2845     10.9258     -26.8847      67.055     -6.86303    -44.012     101.579    -286.812    0.0
#    222.329     -743.632    -67.5615    -75.5699    117.094    -15.6639    -17.5785      43.7195    -158.367      5.54988     93.6726   -206.151     478.234    0.0
#    -27.3708      93.1871     9.57365    10.4177    -15.7366     2.25412     2.38725    -28.6024      85.9849   -12.1013     -59.469     140.17     -546.023    0.0
#    -29.3763     100.479     10.345      10.9141    -17.4187     2.35469     2.50555     -5.56245     13.5658    -1.41221     -8.9086     20.6221    -52.1816   0.0
#    -23.9911      70.1501     4.63845     3.36708    -6.86618    1.2446      0.64836      5.61851    -21.7463     0.155569    12.3307    -26.7754     33.9043   0.0
#     96.3558    -294.987    -42.9019    -39.1863     17.4661   -10.3298     -8.45636    -21.7134      57.8518    -3.15036    -24.0939     89.9042   -109.216    0.0
#     51.7415    -169.663    -27.8404    -15.0235     17.9871    -6.65938    -3.42806      0.188049    -3.26294    9.41366      9.83746   -17.1024      5.81976  0.0
#    183.595     -612.154    -58.6041    -49.5317     99.3879   -13.7712    -11.328       12.2971     -24.0556     9.7603      15.6868    -49.2973     69.3304   0.0
#   -402.228     1340.72     144.049     107.008    -207.355     33.6163     24.556      -26.6963      89.8102   -16.9245     -49.2934    114.939    -168.615    0.0
#    756.036    -2850.62    -208.599    -241.247     366.503    -46.2126    -54.1972      36.744     -118.839      6.03694     75.8516   -183.64      957.119    0.0
#      7.14202    -23.3337    -2.08946    -2.18007     3.51506   -0.493543   -0.489158     0.0          0.0        0.0          0.0         0.0         0.0      0.0

So, obviously the last row is not all 0 like the test requires. But the Hessian isn't even symmetric... I don't know how this happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastDifferentiation v0.4.3 and newer break usage of make_Expr

1 participant