@@ -178,5 +178,47 @@ using Test, MultiscaleGraphSignalTransforms, LinearAlgebra, SparseArrays, JLD2,
178178 println (" \n " )
179179 end
180180
181+ # ########################################################
182+ # 7. Testing VM-NGWP, PC-NGWP, LP-NGWP functions on P64 #
183+ # ########################################################
184+
185+ @testset " 7. testing VM-NGWP/PC-NGWP/LP-NGWP on P64" begin
186+ println (" 7. testing VM-NGWP/PC-NGWP/LP-NGWP on P64" )
187+ N = 64
188+ G = gpath (N)
189+ # use Chebyshev polynomial T₅(x) (x ∈ [0, 1]) as the path signal
190+ G. f = reshape ([16 * x^ 5 - 20 * x^ 3 + 5 * x for x in LinRange (0 , 1 , N)], (N, 1 ))
191+ # compute graph Laplacian eigenvectors
192+ W = G. W
193+ L = diagm (sum (W; dims = 1 )[:]) - W
194+ 𝛌, 𝚽 = eigen (L); 𝚽 = 𝚽 .* sign .(𝚽[1 ,:])'
195+ # build Gstar
196+ Gstar = GraphSig (W)
197+ GP = partition_tree_fiedler (G; swapRegion = false )
198+ GP_dual = partition_tree_fiedler (Gstar; swapRegion = false )
199+ GP_primal = pairclustering (𝚽, GP_dual) # for PC-NGWP
200+ # construct NGWP dictionaries
201+ VM_NGWP = vm_ngwp (𝚽, GP_dual)
202+ PC_NGWP = pc_ngwp (𝚽, GP_dual, GP_primal)
203+ LP_NGWP = lp_ngwp (𝚽, W, GP_dual; ϵ = 0.3 )
204+ # NGWP analysis
205+ dmatrix_VM = ngwp_analysis (G, VM_NGWP)
206+ dvec_vm_ngwp, BS_vm_ngwp = ngwp_bestbasis (dmatrix_VM, GP_dual)
207+ dmatrix_PC = ngwp_analysis (G, PC_NGWP)
208+ dvec_pc_ngwp, BS_pc_ngwp = ngwp_bestbasis (dmatrix_PC, GP_dual)
209+ dmatrix_LP = ngwp_analysis (G, LP_NGWP)
210+ dvec_lp_ngwp, BS_lp_ngwp = ngwp_bestbasis (dmatrix_LP, GP_dual)
211+
212+ println (" The original signal has L2 norm: " , norm (G. f))
213+ println (" The coefficients of VM-NGWP best-basis has L2 norm: " , norm (dvec_vm_ngwp))
214+ @test abs (norm (G. f) - norm (dvec_vm_ngwp)) / norm (G. f) < 10 * eps ()
215+ println (" The coefficients of PC-NGWP best-basis has L2 norm: " , norm (dvec_pc_ngwp))
216+ @test abs (norm (G. f) - norm (dvec_pc_ngwp)) / norm (G. f) < 10 * eps ()
217+ println (" The coefficients of LP-NGWP best-basis has L2 norm: " , norm (dvec_lp_ngwp))
218+ @test abs (norm (G. f) - norm (dvec_lp_ngwp)) / norm (G. f) < 10 * eps ()
219+ println (" \n " )
220+ end
221+
222+
181223end
182224# End of runtests.jl
0 commit comments