Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/R2N.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ function SolverCore.solve!(
sub_kwargs::NamedTuple = NamedTuple(),
) where {T, V, G}
reset!(stats)
_reset_power_method!(solver.v0)
Comment thread
MaxenceGollier marked this conversation as resolved.
Outdated

# Retrieve workspace
selected = reg_nlp.selected
Expand Down
1 change: 1 addition & 0 deletions src/TR_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function SolverCore.solve!(
compute_grad::Bool = true,
) where {T, G, V}
reset!(stats)
_reset_power_method!(solver.v0)
Comment thread
MaxenceGollier marked this conversation as resolved.
Outdated

# Retrieve workspace
selected = reg_nlp.selected
Expand Down
5 changes: 5 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ export RegularizedExecutionStats

import SolverCore.GenericExecutionStats

# Reset the initial vector for the power method to [-1/sqrt(n), 1/sqrt(n), -1/sqrt(n), ...].
function _reset_power_method!(v0::AbstractVector)
v0 .= (isodd.(eachindex(v0)) .* -2 .+ 1) ./ sqrt(length(v0))
Comment thread
MaxenceGollier marked this conversation as resolved.
Outdated
Comment thread
MaxenceGollier marked this conversation as resolved.
Outdated
end
Comment thread
MaxenceGollier marked this conversation as resolved.
Outdated

function power_method!(B::M, v₀::S, v₁::S, max_iter::Int = 1) where {M, S}
@assert max_iter >= 1 "max_iter must be at least 1."
mul!(v₁, B, v₀)
Expand Down
Loading