diff --git a/src/auxiliary.jl b/src/auxiliary.jl index c990b21..862b371 100644 --- a/src/auxiliary.jl +++ b/src/auxiliary.jl @@ -122,7 +122,10 @@ end function eval_and_grad!(∇φ_A, aadot::AADot, A) φ = aadot(A) ∇φ_A_1 = P4ML._pb_evaluate(aadot.aabasis, aadot.cc, A) - ∇φ_A .= unwrap(∇φ_A_1) + # ∇φ_A .= unwrap(∇φ_A_1) + for n = 1:length(A) + ∇φ_A[n] = ∇φ_A_1[n] + end release!(∇φ_A_1) return φ end \ No newline at end of file diff --git a/src/ncorr.jl b/src/ncorr.jl index 5c82929..f4585f3 100644 --- a/src/ncorr.jl +++ b/src/ncorr.jl @@ -28,6 +28,11 @@ function generate_AA_dot(spec, c) return Polynomial(dynamic_poly) end -function eval_and_grad!(∇_A, aadot, A) - return evaluate_and_gradient!(∇_A, aadot, A) +function eval_and_grad!(∇φ_A, aadot, A) + # evaluate_and_gradient!(∇_A, aadot, A) + φ, ∇φ_A_1 = evaluate_and_gradient(aadot, A) + for n = 1:length(A) + ∇φ_A[n] = ∇φ_A_1[n] + end + return φ end diff --git a/src/splines.jl b/src/splines.jl index b6f1ff5..2fd54d8 100644 --- a/src/splines.jl +++ b/src/splines.jl @@ -86,9 +86,12 @@ function evaluate_ed!(Rn, dRn, basis::SplineRadialsZ, Rs, Zs) zj = Zs[ij] i_zj = _z2i(basis, zj) spl_ij = basis.spl[i_zj] - Rn[ij, :] .= spl_ij(rij) + # Rn[ij, :] .= spl_ij(rij) + Rn_ij = spl_ij(rij) g = Interpolations.gradient1(spl_ij, rij) - for n = 1:length(g) + @assert length(Rn_ij) == length(g) + for n = 1:length(Rn_ij) + Rn[ij, n] = Rn_ij[n] dRn[ij, n] = g[n] * 𝐫̂ij end end