Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
haotian127 committed Apr 12, 2021
1 parent e70f674 commit fb25ec5
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions src/NGWF.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
"""
nat_spec_filter(l, D; σ = 0.25 * maximum(D), method = :regular, thres = 0.2)
assemble the natural spectral graph filter centered at the l-th eigenvector via
the distance matrix `D`.
# Input Arguments
- `l::Int64`: index of the centered eigenvector
- `D::Matrix{Float64}`: non-trivial distance matrix of the eigenvectors
- `σ::Float64`: Gaussian window width parameter (default: `0.25 * maximum(D)`)
- `method::Symbol`: `:regular` or `:reduced` (default: `:regular`)
- `thres::Float64`: cutoff threshold ∈ (0, 1).
# Output Argument
- `𝛍::Vector{Float64}`: the natural spectral graph filter
"""
function nat_spec_filter(l, D; σ = 0.25 * maximum(D), method = :regular, thres = 0.2)
d = D[:, l]
𝛍 = exp.(-(d ./ σ).^2)
Expand All @@ -8,6 +25,20 @@ function nat_spec_filter(l, D; σ = 0.25 * maximum(D), method = :regular, thres
return 𝛍
end

"""
ngwf_all_vectors(D, 𝚽; σ = 0.2 * maximum(D))
assemble the whole NGWF dictionary.
# Input Arguments
- `D::Matrix{Float64}`: non-trivial distance matrix of the eigenvectors
- `𝚽::Matrix{Float64}`: graph Laplacian eigenvectors
- `σ::Float64`: Gaussian window width parameter (default: `0.25 * maximum(D)`)
# Output Argument
- `𝓤::Matrix{Float64}`: the NGWF dictionary
"""
function ngwf_all_vectors(D, 𝚽; σ = 0.2 * maximum(D))
N = size(D, 1)
𝓤 = zeros(N, 0)
Expand All @@ -19,6 +50,23 @@ function ngwf_all_vectors(D, 𝚽; σ = 0.2 * maximum(D))
return 𝓤
end

"""
rngwf_all_vectors(D, 𝚽; σ = 0.2 * maximum(D), thres = 0.2)
assemble the reduced NGWF (rNGWF) dictionary.
# Input Arguments
- `D::Matrix{Float64}`: non-trivial distance matrix of the eigenvectors
- `𝚽::Matrix{Float64}`: graph Laplacian eigenvectors
- `σ::Float64`: Gaussian window width parameter (default: `0.25 * maximum(D)`)
- `thres::Float64`: cutoff threshold ∈ (0, 1).
# Output Argument
- `𝓤::Matrix{Float64}`: the rNGWF dictionary
- `dic_l2x::Dict`: a dictionary to store the filtered locations by QR at the l-th
centered eigenvector
"""
function rngwf_all_vectors(D, 𝚽; σ = 0.2 * maximum(D), thres = 0.2)
N = size(D, 1)
𝓤 = zeros(N, 0)
Expand All @@ -40,6 +88,22 @@ function ngwf_vector(D, l, x, 𝚽; σ = 0.1 * maximum(D))
return ψ
end

"""
frame_approx(f, U, V; num_kept = length(f))
approximate signal `f` by the frame `U`.
# Input Arguments
- `f::Vector{Float64}`: input graph signal
- `U::Matrix{Float64}`: a frame operator (matrix or dictionary)
- `V::Matrix{Float64}`: the dual frame operator of `U`
- `num_kept::Int64`: number of kept coefficients (NCR)
# Output Argument
- `rel_error::Vector{Float64}`: the relative errors
- `f_approx::Vector{Float64}`: the approximated signal
"""
function frame_approx(f, U, V; num_kept = length(f))
g = U' * f
ind = sortperm(g.^2; rev = true)[1:num_kept]
Expand All @@ -53,7 +117,19 @@ function frame_approx(f, U, V; num_kept = length(f))
return rel_error, f_approx
end

"""
rngwf_lx(dic_l2x)
find the sequential subindices of rNGWF vectors.
# Input Arguments
- `dic_l2x::Dict`: a dictionary to store the filtered locations by QR at the l-th
centered eigenvector
# Output Argument
- `Γ::Vector{Tuple{Int64,Int64}}`: the sequential subindices of rNGWF vectors.
"""
function rngwf_lx(dic_l2x)
N = length(dic_l2x)
Γ = (Tuple{Int64,Int64})[]
Expand Down

0 comments on commit fb25ec5

Please sign in to comment.