Skip to content

Commit

Permalink
debug dispatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Dec 28, 2024
1 parent 59b41a3 commit ede72a3
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions src/plans/vectorial_plan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,15 @@ get_jacobian!(M::AbstractManifold, JF, vgf::AbstractVectorGradientFunction, p)
function get_jacobian!(
M::AbstractManifold,
J,
vgf::AbstractVectorGradientFunction{<:AllocatingEvaluation,FT,<:FunctionVectorialType},
vgf::VGF,
p;
basis::B=get_jacobian_basis(vgf),
range::Union{AbstractPowerRepresentation,Nothing}=get_range(vgf.jacobian_type),
) where {FT,B<:AbstractBasis}
) where {
FT,
VGF<:AbstractVectorGradientFunction{<:AllocatingEvaluation,FT,<:FunctionVectorialType},
B<:AbstractBasis,
}
n = vgf.range_dimension
gradients = vgf.jacobian!!(M, p)
mP = PowerManifold(M, range, vgf.range_dimension)
Expand All @@ -686,27 +690,25 @@ function get_jacobian!(
end
# (b) We have a vector of gradient functions
function get_jacobian!(
M::AbstractManifold,
JF,
vgf::AbstractVectorGradientFunction{<:AllocatingEvaluation,FT,<:ComponentVectorialType},
p;
basis=get_jacobian_basis(vgf),
) where {FT}
M::AbstractManifold, JF, vgf::VGF, p; basis=get_jacobian_basis(vgf)
) where {
FT,
VGF<:AbstractVectorGradientFunction{<:AllocatingEvaluation,FT,<:ComponentVectorialType},
}
for i in 1:(vgf.range_dimension)
JF[i, :] .= get_coordinates(M, p, vgf.jacobian!![i](M, p), basis)
end
return JF
end
# (c) We have a Jacobian function
function get_jacobian!(
M::AbstractManifold,
JF,
vgf::AbstractVectorGradientFunction{
M::AbstractManifold, JF, vgf::VGF, p; basis=get_jacobian_basis(vgf)
) where {
FT,
VGF<:AbstractVectorGradientFunction{
<:AllocatingEvaluation,FT,<:CoordinateVectorialType
},
p;
basis=get_jacobian_basis(vgf),
) where {FT}
}
JF .= vgf.jacobian!!(M, p)
_change_basis!(JF, vgf.jacobian_type.basis, basis)
return JF
Expand All @@ -715,12 +717,12 @@ end
# Part II: mutating vgf – allocating jacobian
# (a) We have a single gradient function
function get_jacobian!(
M::AbstractManifold,
JF,
vgf::AbstractVectorGradientFunction{<:InplaceEvaluation,FT,<:FunctionVectorialType},
p;
basis::B=DefaultOrthonormalBasis(),
) where {FT,B<:AbstractBasis}
M::AbstractManifold, JF, vgf::VGF, p; basis::B=DefaultOrthonormalBasis()
) where {
FT,
VGF<:AbstractVectorGradientFunction{<:InplaceEvaluation,FT,<:FunctionVectorialType},
B<:AbstractBasis,
}
gradients = zero_vector(mP, fill(p, pM))
vgf.jacobian!!(M, gradients, p)
for i in 1:n
Expand All @@ -730,13 +732,10 @@ function get_jacobian!(
end
# (b) We have a vector of gradient functions
function get_jacobian!(
M::AbstractManifold,
JF,
vgf::AbstractVectorGradientFunction{<:InplaceEvaluation,FT,<:ComponentVectorialType},
p;
basis=get_jacobian_basis(vgf),
X=zero_vector(M, p),
) where {FT}
M::AbstractManifold, JF, vgf::VGF, p; basis=get_jacobian_basis(vgf), X=zero_vector(M, p)
) where {
FT,VGF<:AbstractVectorGradientFunction{<:InplaceEvaluation,FT,<:ComponentVectorialType}
}
for i in 1:n
vgf.jacobian!![i](M, X, p)
JF[i, :] .= get_coordinates(M, p, X, basis)
Expand All @@ -748,12 +747,10 @@ function get_jacobian!(
end
# (c) We have a Jacobian function
function get_jacobian!(
M::AbstractManifold,
JF,
vgf::AbstractVectorGradientFunction{<:InplaceEvaluation,FT,<:CoordinateVectorialType},
p;
basis=get_jacobian_basis(vgf),
) where {FT}
M::AbstractManifold, JF, vgf::VGF, p; basis=get_jacobian_basis(vgf)
) where {
FT,VGF<:AbstractVectorGradientFunction{<:InplaceEvaluation,FT,<:CoordinateVectorialType}
}
vgf.jacobian!!(M, JF, p)
_change_basis!(JF, vgf.jacobian_type.basis, basis)
return JF
Expand Down

0 comments on commit ede72a3

Please sign in to comment.