Skip to content

Commit

Permalink
🤖 Format .jl files (#456)
Browse files Browse the repository at this point in the history
Co-authored-by: tmigot <[email protected]>
  • Loading branch information
github-actions[bot] and tmigot authored Apr 23, 2024
1 parent 543d63c commit dcd7cba
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 42 deletions.
56 changes: 25 additions & 31 deletions src/nlp/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -687,15 +687,7 @@ function jac_op!(
end
return res
end
return LinearOperator{T}(
nlp.meta.ncon,
nlp.meta.nvar,
false,
false,
prod!,
ctprod!,
ctprod!,
)
return LinearOperator{T}(nlp.meta.ncon, nlp.meta.nvar, false, false, prod!, ctprod!, ctprod!)
end

"""
Expand Down Expand Up @@ -785,15 +777,7 @@ function jac_lin_op!(
end
return res
end
return LinearOperator{T}(
nlp.meta.nlin,
nlp.meta.nvar,
false,
false,
prod!,
ctprod!,
ctprod!,
)
return LinearOperator{T}(nlp.meta.nlin, nlp.meta.nvar, false, false, prod!, ctprod!, ctprod!)
end

"""
Expand Down Expand Up @@ -883,15 +867,7 @@ function jac_nln_op!(
end
return res
end
return LinearOperator{T}(
nlp.meta.nnln,
nlp.meta.nvar,
false,
false,
prod!,
ctprod!,
ctprod!,
)
return LinearOperator{T}(nlp.meta.nnln, nlp.meta.nvar, false, false, prod!, ctprod!, ctprod!)
end

"""
Expand Down Expand Up @@ -935,7 +911,12 @@ end
Evaluate the product of the Hessian of j-th constraint at `x` with the vector `v`.
"""
function jth_hprod(nlp::AbstractNLPModel{T, S}, x::AbstractVector, v::AbstractVector, j::Integer) where {T, S}
function jth_hprod(
nlp::AbstractNLPModel{T, S},
x::AbstractVector,
v::AbstractVector,
j::Integer,
) where {T, S}
@lencheck nlp.meta.nvar x v
@rangecheck 1 nlp.meta.ncon j
Hv = S(undef, nlp.meta.nvar)
Expand All @@ -955,7 +936,12 @@ function jth_hprod! end
Return the vector whose i-th component is gᵀ ∇²cᵢ(x) v.
"""
function ghjvprod(nlp::AbstractNLPModel{T, S}, x::AbstractVector, g::AbstractVector, v::AbstractVector) where {T, S}
function ghjvprod(
nlp::AbstractNLPModel{T, S},
x::AbstractVector,
g::AbstractVector,
v::AbstractVector,
) where {T, S}
@lencheck nlp.meta.nvar x g v
gHv = S(undef, nlp.meta.ncon)
return ghjvprod!(nlp, x, g, v, gHv)
Expand Down Expand Up @@ -1025,7 +1011,11 @@ with objective function scaled by `obj_weight`, i.e.,
$(OBJECTIVE_HESSIAN).
Only the lower triangle is returned.
"""
function hess_coord(nlp::AbstractNLPModel{T, S}, x::AbstractVector; obj_weight::Real = one(T)) where {T, S}
function hess_coord(
nlp::AbstractNLPModel{T, S},
x::AbstractVector;
obj_weight::Real = one(T),
) where {T, S}
@lencheck nlp.meta.nvar x
vals = S(undef, nlp.meta.nnzh)
return hess_coord!(nlp, x, vals; obj_weight = obj_weight)
Expand Down Expand Up @@ -1061,7 +1051,11 @@ with objective function scaled by `obj_weight`, i.e.,
$(OBJECTIVE_HESSIAN).
A `Symmetric` object wrapping the lower triangle is returned.
"""
function hess(nlp::AbstractNLPModel{T, S}, x::AbstractVector; obj_weight::Real = one(T)) where {T, S}
function hess(
nlp::AbstractNLPModel{T, S},
x::AbstractVector;
obj_weight::Real = one(T),
) where {T, S}
@lencheck nlp.meta.nvar x
rows, cols = hess_structure(nlp)
vals = hess_coord(nlp, x, obj_weight = obj_weight)
Expand Down
23 changes: 12 additions & 11 deletions src/nls/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ function hess_coord_residual! end
Computes the linear combination of the Hessians of the residuals at `x` with coefficients
`v` in sparse coordinate format.
"""
function hess_coord_residual(nls::AbstractNLSModel{T, S}, x::AbstractVector, v::AbstractVector) where {T, S}
function hess_coord_residual(
nls::AbstractNLSModel{T, S},
x::AbstractVector,
v::AbstractVector,
) where {T, S}
@lencheck nls.meta.nvar x
@lencheck nls.nls_meta.nequ v
vals = S(undef, nls.nls_meta.nnzh)
Expand Down Expand Up @@ -366,7 +370,12 @@ end
Computes the Hessian of the i-th residual at x, in linear operator form. The vector `Hiv` is used as preallocated storage for the operation.
"""
function hess_op_residual!(nls::AbstractNLSModel{T, S}, x::AbstractVector, i::Int, Hiv::AbstractVector) where {T, S}
function hess_op_residual!(
nls::AbstractNLSModel{T, S},
x::AbstractVector,
i::Int,
Hiv::AbstractVector,
) where {T, S}
@lencheck nls.meta.nvar x Hiv
prod! = @closure (res, v, α, β) -> begin
hprod_residual!(nls, x, i, v, Hiv)
Expand All @@ -377,15 +386,7 @@ function hess_op_residual!(nls::AbstractNLSModel{T, S}, x::AbstractVector, i::In
end
return res
end
return LinearOperator{T}(
nls_meta(nls).nvar,
nls_meta(nls).nvar,
true,
true,
prod!,
prod!,
prod!,
)
return LinearOperator{T}(nls_meta(nls).nvar, nls_meta(nls).nvar, true, true, prod!, prod!, prod!)
end

"""
Expand Down

0 comments on commit dcd7cba

Please sign in to comment.