Skip to content

Commit

Permalink
adds minor changes to verbose functionality for lsqr
Browse files Browse the repository at this point in the history
  • Loading branch information
mischmi96 committed Jan 18, 2021
1 parent d4dde6d commit 620a25c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ANOVAapprox"
uuid = "5e027bd6-ab01-4733-8320-e0223e929ebb"
authors = ["Michael Schmischke <[email protected]> and Felix Bartel <[email protected]>"]
version = "1.0.6"
version = "1.0.7"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
16 changes: 9 additions & 7 deletions src/nperiodic_approx_scat_lsqr.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mutable struct nperiodic_approx_scat_lsqr{d,ds} <: nperiodic_approx
mutable struct nperiodic_approx_scat_lsqr{d,ds} <: nperiodic_approx
basis::String
X::Matrix{Float64}
y::Vector{ComplexF64}
Expand All @@ -9,11 +9,11 @@ mutable struct nperiodic_approx_scat_lsqr{d,ds} <: nperiodic_approx

function nperiodic_approx_scat_lsqr{d,ds}( basis::String, X::Matrix{Float64}, y::Vector{ComplexF64}, U::Vector{Vector{Int64}}, trafo::GroupedTransform, N::Vector{Int64} ) where {d,ds}
return new( basis, X, y, U, trafo, N, Dict{Float64,GroupedCoeff}() )
end
end
end

function const_one( x )::Float64
return 1.0
return 1.0
end

function approximate( approx::nperiodic_approx_scat_lsqr{d,ds}; max_iter::Int64=30, lambda::Vector{Float64}=[0.0,], smoothness::Float64=1.5, density::Function=const_one, verbose::Bool=false )::Nothing where {d,ds}
Expand All @@ -23,8 +23,10 @@ function approximate( approx::nperiodic_approx_scat_lsqr{d,ds}; max_iter::Int64=
nf = get_NumFreq( approx )
dsqrt = [ sqrt(density(approx.X[:,i])) for i in 1:M ]

for i = 1:length(lambda)
println( i, ". Lambda: ", lambda[i] )
for i = 1:length(lambda)
if verbose
println( i, ". Lambda: ", lambda[i] )
end
wsqrt = sqrt(lambda[i]).*(sqrt.(vec(what)))

F_vec = LinearMap{ComplexF64}(
Expand All @@ -33,9 +35,9 @@ function approximate( approx::nperiodic_approx_scat_lsqr{d,ds}; max_iter::Int64=
size(approx.X, 2)+nf, nf )

tmp = zeros( ComplexF64, nf )
lsqr!( tmp, F_vec, vcat(dsqrt .* approx.y,zeros(ComplexF64,nf)), maxiter = max_iter, verbose=verbose )
lsqr!( tmp, F_vec, vcat(dsqrt .* approx.y,zeros(ComplexF64,nf)), maxiter = max_iter, verbose=verbose )
approx.fc[lambda[i]] = GroupedCoeff(approx.trafo.setting, tmp)
end

return
return
end
14 changes: 8 additions & 6 deletions src/periodic_approx_scat_lsqr.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mutable struct periodic_approx_scat_lsqr{d,ds} <: periodic_approx
mutable struct periodic_approx_scat_lsqr{d,ds} <: periodic_approx
X::Matrix{Float64}
y::Vector{ComplexF64}
U::Vector{Vector{Int64}}
Expand All @@ -8,16 +8,18 @@ mutable struct periodic_approx_scat_lsqr{d,ds} <: periodic_approx

function periodic_approx_scat_lsqr{d,ds}( X::Matrix{Float64}, y::Vector{ComplexF64}, U::Vector{Vector{Int64}}, trafo::GroupedTransform, N::Vector{Int64} ) where {d,ds}
return new( X, y, U, trafo, N, Dict{Float64,GroupedCoeff}() )
end
end
end

function approximate( approx::periodic_approx_scat_lsqr{d,ds}; max_iter::Int64=30, lambda::Vector{Float64}=[0.0,], smoothness::Float64=1.5, verbose::Bool=false )::Nothing where {d,ds}
what = sobolev_weights( approx.trafo.setting, smoothness=smoothness )
M = size(approx.X,2)
nf = get_NumFreq( approx )

for i = 1:length(lambda)
println( i, ". Lambda: ", lambda[i] )
for i = 1:length(lambda)
if verbose
println( i, ". Lambda: ", lambda[i] )
end
wsqrt = sqrt(lambda[i]).*(sqrt.(vec(what)))

F_vec = LinearMap{ComplexF64}(
Expand All @@ -26,9 +28,9 @@ function approximate( approx::periodic_approx_scat_lsqr{d,ds}; max_iter::Int64=3
size(approx.X, 2)+nf, nf )

tmp = zeros( ComplexF64, nf )
lsqr!( tmp, F_vec, vcat(approx.y,zeros(ComplexF64,nf)), maxiter = max_iter, verbose=verbose )
lsqr!( tmp, F_vec, vcat(approx.y,zeros(ComplexF64,nf)), maxiter = max_iter, verbose=verbose )
approx.fc[lambda[i]] = GroupedCoeff(approx.trafo.setting, tmp)
#@save string( "fc_", i, "_10noise.jld2" ) tmp
end
return
return
end

2 comments on commit 620a25c

@mischmi96
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register branch=main

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/28846

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.7 -m "<description of version>" 620a25c25044584dff0b21b4bf4e8eb8fb7c192a
git push origin v1.0.7

Please sign in to comment.