From ad08368ac1bb9ecad7c538194f5b8a9f8514c3d7 Mon Sep 17 00:00:00 2001 From: Dan Spielman Date: Sun, 26 Aug 2018 15:53:07 -0400 Subject: [PATCH] Changing names --- Manifest.toml | 52 +++++++++++++++--------------- compare/baseTest.jl | 6 ++-- compare/st_chimera.jl | 6 ++-- compare/st_grid2.jl | 6 ++-- compare/st_grid3.jl | 4 +-- devel/develAKPW.ipynb | 44 ++++++++++++------------- devel/kmpTest.jl | 10 +++--- devel/testTrees.jl | 6 ++-- docs/src/Installation.md | 4 +-- docs/src/LSST.md | 10 +++--- docs/src/Laplacians.md | 4 +-- docs/src/index.md | 14 ++++---- docs/src/usingSolvers.md | 18 +++++------ notebooks/Flow IPM Tests.ipynb | 6 ++-- notebooks/KMPdevel.ipynb | 42 ++++++++++++------------ notebooks/MinCostFlow Dimacs.ipynb | 8 ++--- notebooks/MinCostFlow IPM.ipynb | 2 +- notebooks/RandomTrees.ipynb | 2 +- notebooks/Solvers.html | 8 ++--- notebooks/Solvers.ipynb | 4 +-- src/KMPSolver.jl | 12 +++---- src/Laplacians.jl | 10 +++--- src/approxChol.jl | 38 +++++++++++----------- src/augTreeSolver.jl | 8 ++--- src/complexSolvers.jl | 4 +-- src/conditionNumber.jl | 4 +-- src/deprecated.jl | 8 +++++ src/graphOps.jl | 14 ++++---- src/johnlind.jl | 2 +- src/pcg.jl | 2 +- src/solverInterface.jl | 14 ++++---- src/sparsify.jl | 2 +- src/treeAlgs.jl | 4 +-- test/testByExport.jl | 8 ++--- test/testByFile.jl | 8 ++--- test/testDrawing.jl | 2 +- test/testSolvers.jl | 18 +++++------ 37 files changed, 211 insertions(+), 203 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index 1c609b6c..ef7a57bf 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,8 +1,8 @@ [[Arpack]] deps = ["BinaryProvider", "Libdl", "LinearAlgebra", "Random", "SparseArrays", "Test"] -git-tree-sha1 = "ffc099065b47835213386df346e4a8b807c320cd" +git-tree-sha1 = "5b046410fb617d9cf2f8bc0edd5da05a2e5a2ad4" uuid = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97" -version = "0.2.2" +version = "0.2.3" [[Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" @@ -15,9 +15,9 @@ version = "0.8.10" [[BinaryProvider]] deps = ["Libdl", "Pkg", "SHA", "Test"] -git-tree-sha1 = "ffbf89cc49b073cffdb91381b7ee60557a03ec96" +git-tree-sha1 = "b530fbeb6f41ab5a83fbe3db1fcbe879334bcd2d" uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" -version = "0.4.1" +version = "0.4.2" [[BufferedStreams]] deps = ["Compat", "Pkg", "Test"] @@ -33,15 +33,15 @@ version = "0.5.4" [[ColorTypes]] deps = ["FixedPointNumbers", "Random", "Test"] -git-tree-sha1 = "b45e62af8eabea138c381c04972c4b25d47e6c69" +git-tree-sha1 = "0e3209ba7418aed732e5c3818076b4400ee36c08" uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" -version = "0.7.3" +version = "0.7.4" [[Colors]] deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Pkg", "Printf", "Reexport", "Test"] -git-tree-sha1 = "22dbaed87c2b5a2df5caeca48c5f25fe7b6b009a" +git-tree-sha1 = "26f24e97782dd19d52cf97073c316897ac4d0e30" uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" -version = "0.9.2" +version = "0.9.3" [[Compat]] deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] @@ -177,10 +177,10 @@ uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" version = "0.3.1" [[LibExpat]] -deps = ["Compat"] -git-tree-sha1 = "8ba2ca1635ec1755bcf1432c9a2aa6c91a3fb4fd" +deps = ["Compat", "Pkg"] +git-tree-sha1 = "fde352ec13479e2f90e57939da2440fb78c5e388" uuid = "522f3ed2-3f36-55e3-b6df-e94fee9b0c07" -version = "0.4.2" +version = "0.5.0" [[LibGit2]] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" @@ -256,15 +256,15 @@ version = "0.3.0" [[PlotUtils]] deps = ["Colors", "Dates", "Printf", "Random", "Reexport", "Test"] -git-tree-sha1 = "6fd6fafca71798236eccdf5fb1f7e997884e1ad2" +git-tree-sha1 = "78553a920c4869d20742ba66193e3692369086ec" uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043" -version = "0.5.3" +version = "0.5.4" [[Plots]] deps = ["Base64", "Contour", "Dates", "FixedPointNumbers", "GR", "JSON", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "Printf", "REPL", "RecipesBase", "Reexport", "Requires", "Showoff", "SparseArrays", "StaticArrays", "Statistics", "StatsBase", "Test", "UUIDs"] -git-tree-sha1 = "11d668ff24983dd998e264488f4a91a06e11760f" +git-tree-sha1 = "935241178e80158451cc33f4af7c57f671b881b8" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -version = "0.19.2" +version = "0.19.3" [[Printf]] deps = ["Unicode"] @@ -277,16 +277,16 @@ uuid = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7" version = "0.3.0" [[PyCall]] -deps = ["Compat", "Conda", "MacroTools", "VersionParsing"] -git-tree-sha1 = "7a09c45434dff15556ed6b4496390d5c5932ac5d" +deps = ["Compat", "Conda", "MacroTools", "Statistics", "VersionParsing"] +git-tree-sha1 = "993d80a2cfd0fc4b2acc698370a4f9761b27cd9e" uuid = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" -version = "1.18.0" +version = "1.18.2" [[PyPlot]] -deps = ["Colors", "Compat", "LaTeXStrings", "PyCall", "Test", "VersionParsing"] -git-tree-sha1 = "3a0908224526b378cb0eb1b770385e23b70adb5c" +deps = ["Base64", "Colors", "Compat", "LaTeXStrings", "PyCall", "VersionParsing"] +git-tree-sha1 = "1cc673ec375f6fa0e3652e23ba435195f8175387" uuid = "d330b81b-6aea-500a-939a-2ce795aea3ee" -version = "2.6.0" +version = "2.6.1" [[REPL]] deps = ["InteractiveUtils", "Markdown", "Sockets"] @@ -328,15 +328,15 @@ version = "0.5.2" [[Revise]] deps = ["Distributed", "FileWatching", "InteractiveUtils", "LibGit2", "OrderedCollections", "Pkg", "REPL", "Random", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "0a98de1780c326498d62a635ebf72654de2c4b24" +git-tree-sha1 = "97ad3c4ad52b692ae1e0f54b17c517e7c20916e0" uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" -version = "0.6.9" +version = "0.7.2" [[RoundingIntegers]] -deps = ["Compat"] -git-tree-sha1 = "b20dfee859219aadb5dc8f25190212a25d36173b" +deps = ["Pkg", "Test"] +git-tree-sha1 = "293ba0ab32218b9ffd596040224228def84f8da0" uuid = "d5f540fe-1c90-5db3-b776-2e2f362d9394" -version = "0.0.3" +version = "0.2.0" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" diff --git a/compare/baseTest.jl b/compare/baseTest.jl index 7aa9f34e..8c50cdcf 100644 --- a/compare/baseTest.jl +++ b/compare/baseTest.jl @@ -8,17 +8,17 @@ include("/Users/spielman/Laplacians/compare/matlabSafe.jl") include("/Users/spielman/Laplacians/compare/compare_solvers_TL.jl") ac_deg = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) end ac_wdeg = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) end test1 = SolverTest(ac_deg, "ac") test2 = SolverTest(ac_wdeg, "ac_w") # removed chol because killing it can cause a crash -#test3 = SolverTest(cholLap, "chol") +#test3 = SolverTest(chol_lap, "chol") #test4 = SolverTest(cgLapSolver, "cg") tests = [test1 test2] diff --git a/compare/st_chimera.jl b/compare/st_chimera.jl index 08379e8c..33d6fd33 100644 --- a/compare/st_chimera.jl +++ b/compare/st_chimera.jl @@ -22,10 +22,10 @@ include("$(lapdir)/compare/compare_solvers_TL.jl") ac_deg = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) end ac_wdeg = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) end @@ -34,7 +34,7 @@ test_acw = SolverTest(ac_wdeg, "ac_fast") test_amg = SolverTest(AMGLapSolver, "pyamg") # removed chol because killing it can cause a crash -#test3 = SolverTest(cholLap, "chol") +#test3 = SolverTest(chol_lap, "chol") #test4 = SolverTest(cgLapSolver, "cg") tests = [test_ac test_acw test_amg] diff --git a/compare/st_grid2.jl b/compare/st_grid2.jl index 2680fd6f..c5e7d5cd 100644 --- a/compare/st_grid2.jl +++ b/compare/st_grid2.jl @@ -21,17 +21,17 @@ include("$(lapdir)/compare/compare_solvers_TL.jl") ac_deg = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) end ac_wdeg = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) end test_ac = SolverTest(ac_deg, "ac") test_acw = SolverTest(ac_wdeg, "ac_fast") test_amg = SolverTest(AMGLapSolver, "pyamg") -test_chol = SolverTest(cholLap, "chol") +test_chol = SolverTest(chol_lap, "chol") tests = [test_ac test_acw test_amg test_chol] diff --git a/compare/st_grid3.jl b/compare/st_grid3.jl index 0c63c7dc..76c9ec64 100644 --- a/compare/st_grid3.jl +++ b/compare/st_grid3.jl @@ -21,10 +21,10 @@ include("$(lapdir)/compare/compare_solvers_TL.jl") ac_deg = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) end ac_wdeg = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) end diff --git a/devel/develAKPW.ipynb b/devel/develAKPW.ipynb index 9f4331cf..8d098330 100644 --- a/devel/develAKPW.ipynb +++ b/devel/develAKPW.ipynb @@ -90,7 +90,7 @@ "srand(1)\n", "a = grid2(1100)\n", "t = akpwU(a)\n", - "sum(compStretches(t,a))/nnz(a)" + "sum(comp_stretches(t,a))/nnz(a)" ] }, { @@ -115,7 +115,7 @@ "# this should produce 32.47723881214327\n", "#a = grid2(1100)\n", "t = akpw(a)\n", - "sum(compStretches(t,a))/nnz(a)" + "sum(comp_stretches(t,a))/nnz(a)" ] }, { @@ -154,7 +154,7 @@ " 6.76587 6.80419\n", "=#\n", "a = wtedChimera(60100,22)\n", - "f(t) = sum(compStretches(t,a))/nnz(a)\n", + "f(t) = sum(comp_stretches(t,a))/nnz(a)\n", "@time t5 = akpw(a);\n", "@time t2 = akpw(a, ver=2);\n", "[f(t5) f(t2)]\n", @@ -456,7 +456,7 @@ ], "source": [ "@time a = wtedChimera(601000,20)\n", - "f(t) = sum(compStretches(t,a))/nnz(a)\n", + "f(t) = sum(comp_stretches(t,a))/nnz(a)\n", "@time t6 = akpwish(a,ver=6)\n", "@time t5 = akpwish(a,ver=5)\n", "@time t2 = akpwish(a,ver=2)\n", @@ -489,7 +489,7 @@ ], "source": [ "@time a = wtedChimera(601000,20)\n", - "f(t) = sum(compStretches(t,a))/nnz(a)\n", + "f(t) = sum(comp_stretches(t,a))/nnz(a)\n", "@time t5 = akpwish(a,ver=5)\n", "@time t4 = akpwish(a,ver=4)\n", "@time t2 = akpwish(a,ver=2)\n", @@ -547,7 +547,7 @@ "\n", "for i in 1:10\n", " a = wtedChimera(n,i)\n", - " f(t) = sum(compStretches(t,a))/nnz(a)\n", + " f(t) = sum(comp_stretches(t,a))/nnz(a)\n", " \n", " try\n", " \n", @@ -657,7 +657,7 @@ ], "source": [ "a = wtedChimera(301,8)\n", - " f(t) = sum(compStretches(t,a))/nnz(a)\n", + " f(t) = sum(comp_stretches(t,a))/nnz(a)\n", "\n", " tic()\n", " tr = akpwish(a,ver=0)\n", @@ -734,17 +734,17 @@ " \n", "\n", " t1 = akpwU(a)\n", - " push!(st1, sum(compStretches(t1,a)) / nnz(a) )\n", + " push!(st1, sum(comp_stretches(t1,a)) / nnz(a) )\n", "\n", " \n", " t2 = akpwU(a,x->(1/(log(x+1))))\n", - " push!(st2, sum(compStretches(t2,a)) / nnz(a) )\n", + " push!(st2, sum(comp_stretches(t2,a)) / nnz(a) )\n", "\n", " t3 = akpwU(a,x->(1/(2*exp(sqrt(log(x))))))\n", - " push!(st3, sum(compStretches(t3,a)) / nnz(a) )\n", + " push!(st3, sum(comp_stretches(t3,a)) / nnz(a) )\n", " \n", " told = akpw(a)\n", - " push!(stold, sum(compStretches(told,a)) / nnz(a) )\n", + " push!(stold, sum(comp_stretches(told,a)) / nnz(a) )\n", "\n", "end\n", "\n", @@ -790,7 +790,7 @@ "\n", "\n", " t5 = akpwU(a,x->(1/(2*log(x))))\n", - " push!(st5, sum(compStretches(t5,a)) / nnz(a) )\n", + " push!(st5, sum(comp_stretches(t5,a)) / nnz(a) )\n", " \n", "\n", "end\n", @@ -856,19 +856,19 @@ " tic()\n", " tnew = akpwish(a)\n", " timenew += toq()\n", - " push!(stnew, sum(compStretches(tnew,a)) / nnz(a) )\n", + " push!(stnew, sum(comp_stretches(tnew,a)) / nnz(a) )\n", "\n", " \n", " tic()\n", " tp = randishPrim(a)\n", " timep += toq()\n", - " push!(stp, sum(compStretches(tp,a)) / nnz(a) ) \n", + " push!(stp, sum(comp_stretches(tp,a)) / nnz(a) ) \n", " \n", " \n", " tic()\n", " told = akpw(a)\n", " timeold += toq()\n", - " push!(stold, sum(compStretches(told,a)) / nnz(a) )\n", + " push!(stold, sum(comp_stretches(told,a)) / nnz(a) )\n", "\n", "end\n", "\n", @@ -946,19 +946,19 @@ " tic()\n", " tnew = akpwish(a)\n", " timenew += toq()\n", - " push!(stnew, sum(compStretches(tnew,a)) / nnz(a) )\n", + " push!(stnew, sum(comp_stretches(tnew,a)) / nnz(a) )\n", "\n", " \n", " tic()\n", " tp = randishPrim(a)\n", " timep += toq()\n", - " push!(stp, sum(compStretches(tp,a)) / nnz(a) ) \n", + " push!(stp, sum(comp_stretches(tp,a)) / nnz(a) ) \n", " \n", " \n", " tic()\n", " told = akpw(a)\n", " timeold += toq()\n", - " push!(stold, sum(compStretches(told,a)) / nnz(a) )\n", + " push!(stold, sum(comp_stretches(told,a)) / nnz(a) )\n", "\n", "end\n", "\n", @@ -1104,7 +1104,7 @@ "include(\"../src/akpw.jl\")\n", "tnew = akpwish(chimera(50,1))\n", "@time tnew = akpwish(a)\n", - "sum(compStretches(tnew,a)) / nnz(a)" + "sum(comp_stretches(tnew,a)) / nnz(a)" ] }, { @@ -1136,7 +1136,7 @@ "include(\"../src/akpw.jl\")\n", "tnew = akpwish(chimera(50,1))\n", "@time tnew = akpwish(a)\n", - "sum(compStretches(tnew,a)) / nnz(a)" + "sum(comp_stretches(tnew,a)) / nnz(a)" ] }, { @@ -1167,7 +1167,7 @@ "source": [ "told = akpw(chimera(50,1))\n", "@time told = akpw(a)\n", - "sum(compStretches(told,a)) / nnz(a)" + "sum(comp_stretches(told,a)) / nnz(a)" ] }, { @@ -1198,7 +1198,7 @@ "source": [ "tp = akpw(chimera(50,1))\n", "@time tp = randishPrim(a)\n", - "sum(compStretches(tp,a)) / nnz(a)" + "sum(comp_stretches(tp,a)) / nnz(a)" ] } ], diff --git a/devel/kmpTest.jl b/devel/kmpTest.jl index 8aab5988..3d3967a6 100644 --- a/devel/kmpTest.jl +++ b/devel/kmpTest.jl @@ -144,7 +144,7 @@ function testSampler(a; t=akpw(a), frac1=1/5) rest = a-t; - st = compStretches(t,rest); + st = comp_stretches(t,rest); aveStretch = sum(st)/nnz(rest) @show aveStretch @@ -180,7 +180,7 @@ end function testKMP(a; t=akpw(a), frac1=1/5, frac2=1/20) - st = compStretches(t,a); + st = comp_stretches(t,a); aveStretch = sum(st)/nnz(a) @show aveStretch @@ -189,7 +189,7 @@ function testKMP(a; t=akpw(a), frac1=1/5, frac2=1/20) heavy = rest+fac*t; n = size(a,1); - strest = compStretches(t,rest) + strest = comp_stretches(t,rest) probs = triu(strest); probs = probs * (n*frac1)/ sum(probs); @@ -200,7 +200,7 @@ function testKMP(a; t=akpw(a), frac1=1/5, frac2=1/20) samp1 = sparse(ai,aj,av.*select./pv,n,n) samp1 = samp1 + samp1'; - st1 = compStretches(t*fac, samp1); + st1 = comp_stretches(t*fac, samp1); (s1i,s1j,s1v) = findnz(triu(samp1)) nits = 20 @@ -253,7 +253,7 @@ function makeHeavy(a; t=akpw(a), params::KMPparams=defaultKMPparams) rest = aord-tord; - st = compStretches(tord,rest); + st = comp_stretches(tord,rest); aveStretch = sum(st)/nnz(rest) targetStretch = 1/(params.treeScale*log(n)/log(2)) diff --git a/devel/testTrees.jl b/devel/testTrees.jl index fcb30295..141b8450 100644 --- a/devel/testTrees.jl +++ b/devel/testTrees.jl @@ -14,7 +14,7 @@ tp = Array(Float64,0) for i in 1:nruns a = wted_chimera(n+i,1) - f(t) = sum(compStretches(t,a))/nnz(a) + f(t) = sum(comp_stretches(t,a))/nnz(a) try @@ -109,7 +109,7 @@ tp = Array(Float64,0) for i in 1:nruns a = wted_chimera(n,i) - f(t) = sum(compStretches(t,a))/nnz(a) + f(t) = sum(comp_stretches(t,a))/nnz(a) try @@ -202,7 +202,7 @@ h = open(fn,"w") for i in 1:nruns a = wted_chimera(n,i) - f(t) = sum(compStretches(t,a))/nnz(a) + f(t) = sum(comp_stretches(t,a))/nnz(a) try diff --git a/docs/src/Installation.md b/docs/src/Installation.md index 44fde808..43125120 100644 --- a/docs/src/Installation.md +++ b/docs/src/Installation.md @@ -94,12 +94,12 @@ To see if Laplacians is working, try typing ~~~julia a = chimera(100,6) -spectralDrawing(a) +spectral_drawing(a) ~~~ or ~~~julia a = generalizedNecklace(grid2(6),grid2(3),2) -spectralDrawing(a) +spectral_drawing(a) ~~~ diff --git a/docs/src/LSST.md b/docs/src/LSST.md index cab126f1..15ea215f 100644 --- a/docs/src/LSST.md +++ b/docs/src/LSST.md @@ -2,7 +2,7 @@ We have implemented a variant of the algorithm of Alon, Karp, Peleg and West for computing low stretch spanning trees. It is called `akpw`. For unweighted graphs we provide a faster variant called `akpwU`. If you require faster algorithms, with possibly higher average stretch, you can try the heuristics `randishPrim` or `randishKruskal`. -You can compute the stretch of a graph with respect to a spanning tree with the routine `compStretches`. It returns a sparse matrix with one entry for each edge in the graph giving its stretch. For example: +You can compute the stretch of a graph with respect to a spanning tree with the routine `comp_stretches`. It returns a sparse matrix with one entry for each edge in the graph giving its stretch. For example: ~~~julia julia> graph = grid2(4) @@ -11,7 +11,7 @@ julia> graph = grid2(4) julia> tree = akpwU(graph) 16x16 sparse matrix with 30 Float64 entries: -julia> st = compStretches(tree,graph) +julia> st = comp_stretches(tree,graph) 16x16 sparse matrix with 48 Float64 entries: [2 , 1] = 1.0 [5 , 1] = 1.0 @@ -50,19 +50,19 @@ julia> graph = chimera(1000000,1); julia> @time tree = akpw(graph); 5.700285 seconds (16.10 M allocations: 1.263 GB, 11.16% gc time) -julia> aveStretch = sum(compStretches(tree,graph))/nnz(graph) +julia> aveStretch = sum(comp_stretches(tree,graph))/nnz(graph) 8.793236275779616 julia> @time tree = randishPrim(graph); 3.736225 seconds (3.21 M allocations: 566.887 MB, 6.40% gc time) -julia> aveStretch = sum(compStretches(tree,graph))/nnz(graph) +julia> aveStretch = sum(comp_stretches(tree,graph))/nnz(graph) 10.800094649795756 julia> @time tree = randishKruskal(graph); 2.515443 seconds (3.21 M allocations: 423.529 MB, 4.35% gc time) -julia> aveStretch = sum(compStretches(tree,graph))/nnz(graph) +julia> aveStretch = sum(comp_stretches(tree,graph))/nnz(graph) 37.819948689847564 ~~~ diff --git a/docs/src/Laplacians.md b/docs/src/Laplacians.md index 87bbf746..f67bba92 100644 --- a/docs/src/Laplacians.md +++ b/docs/src/Laplacians.md @@ -9,14 +9,14 @@ To see if it is working, try something like this: ~~~julia a = chimera(100,6) -spectralDrawing(a) +spectral_drawing(a) ~~~ or ~~~julia a = generalizedNecklace(grid2(6),grid2(3),2) -spectralDrawing(a) +spectral_drawing(a) ~~~ ## To use Laplacians diff --git a/docs/src/index.md b/docs/src/index.md index 2357f33e..3b784b04 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -23,12 +23,12 @@ For some examples of some of the things you can do with Laplacians, look at * [An example of sparsification](http://github.com/danspielman/Laplacians.jl/blob/master/notebooks/Sparsification Demo.ipynb) * And, try the chimera and wtedChimera graph generators. They are designed to generate a wide variety of graphs so as to exercise code. -If you want to solve Laplacian equations, we recommend `approxCholLap`. +If you want to solve Laplacian equations, we recommend `approxchol_lap`. The algorithms provide by Laplacians.jl include: * `akpw`, a heuristic for computing low stretch spanning trees written by Daniel Spielman, inspired by the algorithm from the paper "A graph-theoretic game and its application to the k-server problem" by Alon, Karp, Peleg, and West, SIAM Journal on Computing, 1995. -* `approxCholLap`: a fast heuristic for solving Laplacians equations written by Daniel Spielman, based on the paper "Approximate Gaussian Elimination for Laplacians: Fast, Sparse, and Simple" by Rasmus Kyng and Sushant Sachdeva, FOCS 2016. For SDDM systems, use `approxCholSddm`. +* `approxchol_lap`: a fast heuristic for solving Laplacians equations written by Daniel Spielman, based on the paper "Approximate Gaussian Elimination for Laplacians: Fast, Sparse, and Simple" by Rasmus Kyng and Sushant Sachdeva, FOCS 2016. For SDDM systems, use `approxchol_sddm`. * `sparsify`, an implementation of sparsification by effective resistance sampling, following Spielman and Srivastava. * `KMPLapSolver` and `KMPSDDSolver`: linear equation solvers based on the paper "Approaching optimality for solving SDD systems" by Koutis, Miller, and Peng, SIAM Journal on Computing, 2014. * `samplingSDDSolver` and `samplingLapSolver`, based on the paper "Approximate Gaussian Elimination for Laplacians: Fast, Sparse, and Simple" by Rasmus Kyng and Sushant Sachdeva, FOCS 2016. @@ -72,11 +72,11 @@ This is the first version that is compatible with Julia 0.7. Other changes: ## Version 0.2.2, December 28, 2017 -Fixed two bugs: one in shortestPaths, and one that prevented passing some parameters to approxCholSddm. Improved the documentation for solving linear equations. +Fixed two bugs: one in shortestPaths, and one that prevented passing some parameters to approxchol_sddm. Improved the documentation for solving linear equations. ## Version 0.2.1, September 18, 2017 -Fixed a bug in `approxCholSddm` that caused it to be slow. +Fixed a bug in `approxchol_sddm` that caused it to be slow. ## Version 0.2.0, July 17, 2017 @@ -85,7 +85,7 @@ Julia 0.5.X. Changes: -* Added `approxCholSddm`, a wrapper of `approxCholLap` that solves +* Added `approxchol_sddm`, a wrapper of `approxchol_lap` that solves SDDM systems. ## Version 0.1.4, June 6, 2017 @@ -102,8 +102,8 @@ Changes: Major Changes: -* Changed the name of the approximate Cholesky solver from `edgeElimLap` to `approxCholLap`. Made improvements in this solver. -* Improved PCG so that it can now detect stagnation. Made options to do this even better when using it with a good preconditioner, like `approxCholLap`. +* Changed the name of the approximate Cholesky solver from `edgeElimLap` to `approxchol_lap`. Made improvements in this solver. +* Improved PCG so that it can now detect stagnation. Made options to do this even better when using it with a good preconditioner, like `approxchol_lap`. * Added in code for comparing the running times of solvers. The difficulty here is that we need to stop them if they run too long. Added code to do this with threads inside Julia, and with `gtimeout` when calling Matlab to use icc, CMG, or LAMG. ## Version 0.1.2, April 2, 2017 diff --git a/docs/src/usingSolvers.md b/docs/src/usingSolvers.md index e09317c0..688369e1 100644 --- a/docs/src/usingSolvers.md +++ b/docs/src/usingSolvers.md @@ -5,13 +5,13 @@ The main purpose of this package is to experiment with the implementation of algorithms for solving systems of linear equations in Laplacian and symmetric, diagonally dominant, M-matrices (SDDM). At present, the fastest solver in this package for Laplacians is -[`approxCholLap`](@ref). -For SDDM systems, one should use [`approxCholSddm`](@ref). Here is a quick demo. Read more for other solvers and other options you can pass to the solvers. +[`approxchol_lap`](@ref). +For SDDM systems, one should use [`approxchol_sddm`](@ref). Here is a quick demo. Read more for other solvers and other options you can pass to the solvers. ~~~julia julia> a = grid3(50); # an adjacency matrix julia> la = lap(a); # it's Laplacian -julia> sol = approxCholLap(a); # a solver for la +julia> sol = approxchol_lap(a); # a solver for la julia> b = randn(size(la,1)); b = b - mean(b); # a right-hand-side julia> x = sol(b); # the solution julia> norm(la*x-b) / norm(b) @@ -24,7 +24,7 @@ PCG stopped after: 0.022 seconds and 3 iterations with relative error 0.07929402 julia> sddm = copy(la); # doing it with a SDDM matrix julia> sddm[1,1] += 1; -julia> sol = approxCholSddm(sddm, verbose=true); # solver, with output +julia> sol = approxchol_sddm(sddm, verbose=true); # solver, with output Using greedy degree ordering. Factorization time: 0.7143130302429199 Ratio of operator edges to original edges: 2.1120548223350255 ratio of max to min diagonal of laplacian : 6.0 @@ -71,7 +71,7 @@ julia> n = 1000; julia> a = wted_chimera(n); # produces a graph, as a sparse adjacency matrix julia> b = randn(n); julia> b = b - mean(b); # so there is a solution -julia> f = cholLap(a) +julia> f = chol_lap(a) (::#79) (generic function with 1 method) julia> x = f(b); julia> la = lap(a); # construct the Laplacian of a @@ -148,13 +148,13 @@ norm(sddm*x-b) 1.0598778281116327e-14 ~~~ -As `cholfact` does not satisfy our interface, we wrap it in a routine [`cholSDDM`](@ref) that does. +As `cholfact` does not satisfy our interface, we wrap it in a routine [`chol_sddm`](@ref) that does. -To solve systems in Laplacian matrices, use [`cholLap`](@ref). Recall that this routine should be passed the adjacency matrix. +To solve systems in Laplacian matrices, use [`chol_lap`](@ref). Recall that this routine should be passed the adjacency matrix. ~~~julia -f = cholLap(a) +f = chol_lap(a) b = randn(n); b = b - mean(b); norm(la*f(b) - b) @@ -303,7 +303,7 @@ These first two follow that paper reasonably closely. The following is a modification of the algorithm that eliminates edges one at a time. The code is by Daniel Spielman. The algorithm has not yet been analyzed. It is presently the fastest in this package. -* [`approxCholLap`](@ref) +* [`approxchol_lap`](@ref) ## Algebraic Multigrid diff --git a/notebooks/Flow IPM Tests.ipynb b/notebooks/Flow IPM Tests.ipynb index 6b033cb7..48984955 100644 --- a/notebooks/Flow IPM Tests.ipynb +++ b/notebooks/Flow IPM Tests.ipynb @@ -477,7 +477,7 @@ } ], "source": [ - "@time (x_ntipm_flow,s,y) = min_cost_flow(Bt',c,b,u, lapSolver = cholLap);" + "@time (x_ntipm_flow,s,y) = min_cost_flow(Bt',c,b,u, lapSolver = chol_lap);" ] }, { @@ -531,7 +531,7 @@ "b = 0.25*Bt*rand(m);\n", "u = 0.25*ones(m);\n", "\n", - "@time (x_ntipm_flow,s,y) = min_cost_flow(Bt',c,b,u, lapSolver = cholLap);" + "@time (x_ntipm_flow,s,y) = min_cost_flow(Bt',c,b,u, lapSolver = chol_lap);" ] }, { @@ -757,7 +757,7 @@ } ], "source": [ - "@time (x_ntipm_flow,s,y) = min_cost_flow(Bt',c,b,u, lapSolver = cholLap);" + "@time (x_ntipm_flow,s,y) = min_cost_flow(Bt',c,b,u, lapSolver = chol_lap);" ] }, { diff --git a/notebooks/KMPdevel.ipynb b/notebooks/KMPdevel.ipynb index 24b0c4a4..00f889fb 100644 --- a/notebooks/KMPdevel.ipynb +++ b/notebooks/KMPdevel.ipynb @@ -26,8 +26,8 @@ " a = wtedChimera(n)\n", " t1 = randishPrim(a)\n", " t2 = randishKruskal(a)\n", - " s1 = sum(compStretches(t1,a))/nnz(a)\n", - " s2 = sum(compStretches(t2,a))/nnz(a)\n", + " s1 = sum(comp_stretches(t1,a))/nnz(a)\n", + " s2 = sum(comp_stretches(t2,a))/nnz(a)\n", " push!(x1,s1)\n", " push!(x2,s2)\n", "end\n", @@ -176,7 +176,7 @@ "LoadError: graph is not connected\nwhile loading In[38], in expression starting on line 3", "", " in matToTreeDepth at /Users/spielman/.julia/v0.4/Laplacians/src/treeAlgs.jl:162", - " in compStretches at /Users/spielman/.julia/v0.4/Laplacians/src/treeAlgs.jl:408", + " in comp_stretches at /Users/spielman/.julia/v0.4/Laplacians/src/treeAlgs.jl:408", " in augmentTree at /Users/spielman/.julia/v0.4/Laplacians/src/solvers.jl:138", " in augTreePrecon at /Users/spielman/.julia/v0.4/Laplacians/src/solvers.jl:195", " in augTreeSolver at /Users/spielman/.julia/v0.4/Laplacians/src/solvers.jl:210", @@ -1508,7 +1508,7 @@ }, "outputs": [], "source": [ - "st = compStretches(t,a);\n", + "st = comp_stretches(t,a);\n", "aveStretch = sum(st)/nnz(a)" ] }, @@ -1562,7 +1562,7 @@ }, "outputs": [], "source": [ - "strest = compStretches(t,rest)\n", + "strest = comp_stretches(t,rest)\n", "probs = triu(strest);\n", "probs = probs * (n/5)/ sum(probs);\n" ] @@ -1621,7 +1621,7 @@ }, "outputs": [], "source": [ - "st1 = compStretches(t*fac, samp1);" + "st1 = comp_stretches(t*fac, samp1);" ] }, { @@ -1706,7 +1706,7 @@ " samp1 = sparse(ai,aj,av.*select./pv,n,n)\n", "# samp1 = samp1 + samp1';\n", " \n", - "# st1 = compStretches(t*fac, samp1);\n", + "# st1 = comp_stretches(t*fac, samp1);\n", "# (s1i,s1j,s1v) = findnz(triu(samp1))" ] }, @@ -1825,7 +1825,7 @@ }, "outputs": [], "source": [ - "@time st1 = compStretches(tord,aord);" + "@time st1 = comp_stretches(tord,aord);" ] }, { @@ -1836,7 +1836,7 @@ }, "outputs": [], "source": [ - "@time st2 = compStretchesDFS(tord,aord);" + "@time st2 = comp_stretchesDFS(tord,aord);" ] }, { @@ -2058,7 +2058,7 @@ "# n = 100000\n", "a = grid2(1000)\n", "t = akpw(a)\n", - "aves = sum(compStretches(t,a))/nnz(a)" + "aves = sum(comp_stretches(t,a))/nnz(a)" ] }, { @@ -2073,7 +2073,7 @@ "for i in 1:10\n", " ap = randperm(a)\n", " tp = akpw(ap)\n", - " avc[i] = sum(compStretches(tp,ap))/nnz(a)\n", + " avc[i] = sum(comp_stretches(tp,ap))/nnz(a)\n", "end\n", "mean(avc)" ] @@ -2110,9 +2110,9 @@ "source": [ "a = grid2(700)\n", "@time t = akpw(a,exponentialX=false)\n", - "@show sum(compStretches(t,a))/nnz(a)\n", + "@show sum(comp_stretches(t,a))/nnz(a)\n", "@time t = akpw(a,exponentialX=true)\n", - "@show sum(compStretches(t,a))/nnz(a);" + "@show sum(comp_stretches(t,a))/nnz(a);" ] }, { @@ -2133,23 +2133,23 @@ " tic();\n", " t = akpw(a,exponentialX=false)\n", " push!(timef,toc())\n", - " push!(df,sum(compStretches(t,a))/nnz(a))\n", + " push!(df,sum(comp_stretches(t,a))/nnz(a))\n", " \n", " tic();\n", " t = akpw(a,exponentialX=true)\n", " push!(timet,toc())\n", - " push!(dt,sum(compStretches(t,a))/nnz(a))\n", + " push!(dt,sum(comp_stretches(t,a))/nnz(a))\n", " \n", " a = unweight(a)\n", " tic();\n", " t = akpw(a,exponentialX=false)\n", " push!(timef,toc())\n", - " push!(df,sum(compStretches(t,a))/nnz(a))\n", + " push!(df,sum(comp_stretches(t,a))/nnz(a))\n", " \n", " tic();\n", " t = akpw(a,exponentialX=true)\n", " push!(timet,toc())\n", - " push!(dt,sum(compStretches(t,a))/nnz(a))\n", + " push!(dt,sum(comp_stretches(t,a))/nnz(a))\n", "end\n", " \n" ] @@ -2296,7 +2296,7 @@ "\n", " rest = a-t;\n", "\n", - " st = compStretches(t,rest);\n", + " st = comp_stretches(t,rest);\n", " aveStretch = sum(st)/nnz(rest)\n", " @show aveStretch\n", " \n", @@ -2315,7 +2315,7 @@ " samp1 = sparse(sampijvs.i,sampijvs.j,sampijvs.v,n,n)\n", " samp1 = samp1 + samp1';\n", " \n", - " st1 = compStretches(t*fac, samp1);\n", + " st1 = comp_stretches(t*fac, samp1);\n", " (s1i,s1j,s1v) = findnz(triu(samp1))\n", "\n", " add = speye(n)/10^6;\n", @@ -2340,7 +2340,7 @@ "\n", " rest = a-t;\n", "\n", - " st = compStretches(t,rest);\n", + " st = comp_stretches(t,rest);\n", " aveStretch = sum(st)/nnz(rest)\n", " @show aveStretch\n", " \n", @@ -2484,7 +2484,7 @@ "\n", " rest = a-t;\n", "\n", - " st = compStretches(t,rest);\n", + " st = comp_stretches(t,rest);\n", " aveStretch = sum(st)/nnz(rest)\n", " @show aveStretch\n", " \n", diff --git a/notebooks/MinCostFlow Dimacs.ipynb b/notebooks/MinCostFlow Dimacs.ipynb index f13f2ae7..7eeb52d5 100644 --- a/notebooks/MinCostFlow Dimacs.ipynb +++ b/notebooks/MinCostFlow Dimacs.ipynb @@ -335,7 +335,7 @@ ], "source": [ "#sol = min_cost_flow(mcfp, lapSolver = (h->augTreeLap(h, tol=1e-12)), tol=1e-2)\n", - "@time sol = min_cost_flow(mcfp, lapSolver = cholLap, tol = 1e-5)\n", + "@time sol = min_cost_flow(mcfp, lapSolver = chol_lap, tol = 1e-5)\n", "flow = sol[1]\n", "reportMCFresults(mcfp,flow)" ] @@ -727,7 +727,7 @@ } ], "source": [ - "@time sol = min_cost_flow(mcfp, lapSolver = cholLap, tol = 1e-5)\n", + "@time sol = min_cost_flow(mcfp, lapSolver = chol_lap, tol = 1e-5)\n", "flow = sol[1]\n", "reportMCFresults(mcfp,flow)" ] @@ -1225,7 +1225,7 @@ } ], "source": [ - "@time sol = min_cost_flow(mcfp, lapSolver = cholLap , tol=1)\n", + "@time sol = min_cost_flow(mcfp, lapSolver = chol_lap , tol=1)\n", "flow = sol[1]\n", "reportMCFresults(mcfp, flow)" ] @@ -1415,7 +1415,7 @@ } ], "source": [ - "@time sol = min_cost_flow(mcfp, lapSolver = cholLap, tol=1)\n", + "@time sol = min_cost_flow(mcfp, lapSolver = chol_lap, tol=1)\n", "flow = sol[1]\n", "reportMCFresults(mcfp, flow)" ] diff --git a/notebooks/MinCostFlow IPM.ipynb b/notebooks/MinCostFlow IPM.ipynb index c73fca94..386313bf 100644 --- a/notebooks/MinCostFlow IPM.ipynb +++ b/notebooks/MinCostFlow IPM.ipynb @@ -124,7 +124,7 @@ ], "source": [ "#Profile.clear()\n", - "#@profile (xf,s,y) = min_cost_flow(Bt',c,b,u,lapSolver = cholLap);\n", + "#@profile (xf,s,y) = min_cost_flow(Bt',c,b,u,lapSolver = chol_lap);\n", "@time (xf,s,y) = min_cost_flow(Bt',c,b,u, lapSolver = (h->augTreeLap(h,tol=1e-8)));\n", "#@time (xf,s,y) = min_cost_flow(Bt',c,b,u,lapSolver = (h->matlabCmgLap(h,tol=1e-8,verbose=true)));" ] diff --git a/notebooks/RandomTrees.ipynb b/notebooks/RandomTrees.ipynb index 2155064e..c062c9d8 100644 --- a/notebooks/RandomTrees.ipynb +++ b/notebooks/RandomTrees.ipynb @@ -81,7 +81,7 @@ "source": [ "a = grid2(30,30,isotropy=10);\n", "@time t = randishKruskal(a)\n", - "@time st = compStretches(t,a);\n", + "@time st = comp_stretches(t,a);\n", "sum(st)/nnz(a)" ] }, diff --git a/notebooks/Solvers.html b/notebooks/Solvers.html index 05b7960c..8928d16d 100644 --- a/notebooks/Solvers.html +++ b/notebooks/Solvers.html @@ -1395,7 +1395,7 @@

Computing StretchIn [32]: @@ -1863,7 +1863,7 @@

Preconditioned Solvers
a = grid2(1000)
 t = randishKruskal(a);
-st = compStretches(t,a);
+st = comp_stretches(t,a);
 sum(st)/nnz(a)
 
@@ -1894,7 +1894,7 @@

Preconditioned Solvers
t = randishPrim(a);
-st = compStretches(t,a);
+st = comp_stretches(t,a);
 sum(st)/nnz(a)
 
diff --git a/notebooks/Solvers.ipynb b/notebooks/Solvers.ipynb index 8f1ad273..e7c8006e 100644 --- a/notebooks/Solvers.ipynb +++ b/notebooks/Solvers.ipynb @@ -949,7 +949,7 @@ } ], "source": [ - "st = compStretches(mst,a)" + "st = comp_stretches(mst,a)" ] }, { @@ -1027,7 +1027,7 @@ "@time a = uniformWeight(a)\n", "@time a = a + a';\n", "@time mst = kruskal(a);\n", - "@time st = compStretches(mst,a);" + "@time st = comp_stretches(mst,a);" ] }, { diff --git a/src/KMPSolver.jl b/src/KMPSolver.jl index 6effbb75..03054515 100644 --- a/src/KMPSolver.jl +++ b/src/KMPSolver.jl @@ -259,7 +259,7 @@ function KMPLapSolver1(a; verbose=false, println("The graph is small. Solve directly") end - return cholLap(a) + return chol_lap(a) end @@ -268,7 +268,7 @@ function KMPLapSolver1(a; verbose=false, println("The graph is a tree. Solve directly") end - return cholLap(a) + return chol_lap(a) end @@ -277,7 +277,7 @@ function KMPLapSolver1(a; verbose=false, else tree = akpw(a) if verbose - println("akpw stretch : ", sum(compStretches(tree,a))/nnz(a)) + println("akpw stretch : ", sum(comp_stretches(tree,a))/nnz(a)) end end @@ -340,7 +340,7 @@ function KMPLapPrecon(a, t, params; verbose=false) rest = a-t; - st = compStretches(t,rest); + st = comp_stretches(t,rest); aveStretch = sum(st)/nnz(rest) if params.treeScale > 0 @@ -390,7 +390,7 @@ function KMPLapPreconSub(tree, ijvs::IJVS, targetStretch::Real, level::Int, para # if is nothing in ijvs if m == 0 la = lap(tree) - return cholLap(a) + return chol_lap(a) end @@ -403,7 +403,7 @@ function KMPLapPreconSub(tree, ijvs::IJVS, targetStretch::Real, level::Int, para rest = sparse(ijvs1.i,ijvs1.j,ijvs1.v,n,n) - return cholLap(rest + rest' + tree) + return chol_lap(rest + rest' + tree) else diff --git a/src/Laplacians.jl b/src/Laplacians.jl index 5cb79a85..c3ad8dbe 100644 --- a/src/Laplacians.jl +++ b/src/Laplacians.jl @@ -119,8 +119,8 @@ module Laplacians export lap export adj - export spectralCoords - export spectralDrawing + export spectral_coords + export spectral_drawing export diagmat @@ -141,7 +141,7 @@ module Laplacians export matToTreeDepth export tarjanStretch export compDepth - export compStretches + export comp_stretches export dfsOrder include("pcg.jl") @@ -179,7 +179,7 @@ module Laplacians export blockSample include("solverInterface.jl") - export cholSDDM, cholLap, lapWrapSDDM + export chol_sddm, chol_lap, lapWrapSDDM include("augTreeSolver.jl") @@ -194,7 +194,7 @@ module Laplacians include("approxCholTypes.jl") include("approxChol.jl") - export approxCholLap, ApproxCholParams, approxCholSddm + export approxchol_lap, ApproxCholParams, approxchol_sddm include("complexSolvers.jl") export SDDMSolvers diff --git a/src/approxChol.jl b/src/approxChol.jl index 5bebd08a..91f76568 100644 --- a/src/approxChol.jl +++ b/src/approxChol.jl @@ -23,12 +23,12 @@ We then have the outline: * get_ll_col and compress_ll_col : used inside the elimination * approxChol : the main routine * LDLsolver, and its forward and backward solve the apply LDLinv -* approxCholLap: the main solver, which calls approxCholLap1 on connected +* approxchol_lap: the main solver, which calls approxchol_lap1 on connected components. - This then calls one of approxCholLapWdeg, approxCholLapGiven or approxCholLapGreedy, + This then calls one of approxchol_lapWdeg, approxchol_lapGiven or approxchol_lapGreedy, depending on the parameters. -* approxCholLapChol - for producing a Cholesky factor instead of an LDLinv. +* approxchol_lapChol - for producing a Cholesky factor instead of an LDLinv. might be useful if optimized. * data structures that are used for the adaptive low-degree version to choose the next vertex. @@ -727,8 +727,8 @@ end """ - solver = approxCholLap(a); x = solver(b); - solver = approxCholLap(a; tol::Real=1e-6, maxits=1000, maxtime=Inf, verbose=false, pcgIts=Int[], params=ApproxCholParams()) + solver = approxchol_lap(a); x = solver(b); + solver = approxchol_lap(a; tol::Real=1e-6, maxits=1000, maxtime=Inf, verbose=false, pcgIts=Int[], params=ApproxCholParams()) A heuristic by Daniel Spielman inspired by the linear system solver in https://arxiv.org/abs/1605.02353 by Rasmus Kyng and Sushant Sachdeva. Whereas that paper eliminates vertices one at a time, this eliminates edges one at a time. It is probably possible to analyze it. The `ApproxCholParams` let you choose one of three orderings to perform the elimination. @@ -741,7 +741,7 @@ The `ApproxCholParams` let you choose one of three orderings to perform the elim For more info, see http://danspielman.github.io/Laplacians.jl/latest/usingSolvers/index.html """ -function approxCholLap(a::SparseMatrixCSC{Tv,Ti}; +function approxchol_lap(a::SparseMatrixCSC{Tv,Ti}; tol::Real=1e-6, maxits=1000, maxtime=Inf, @@ -749,7 +749,7 @@ function approxCholLap(a::SparseMatrixCSC{Tv,Ti}; pcgIts=Int[], params=ApproxCholParams()) where {Tv,Ti} - return Laplacians.lapWrapComponents(approxCholLap1, a, + return Laplacians.lapWrapComponents(approxchol_lap1, a, verbose=verbose, tol=tol, maxits=maxits, @@ -760,7 +760,7 @@ function approxCholLap(a::SparseMatrixCSC{Tv,Ti}; end -function approxCholLapGreedy(a::SparseMatrixCSC; +function approxchol_lapGreedy(a::SparseMatrixCSC; tol::Real=1e-6, maxits=1000, maxtime=Inf, @@ -796,7 +796,7 @@ function approxCholLapGreedy(a::SparseMatrixCSC; end -function approxCholLapGiven(a::SparseMatrixCSC; +function approxchol_lapGiven(a::SparseMatrixCSC; tol::Real=1e-6, maxits=1000, maxtime=Inf, @@ -832,7 +832,7 @@ function approxCholLapGiven(a::SparseMatrixCSC; end -function approxCholLapWdeg(a::SparseMatrixCSC; +function approxchol_lapWdeg(a::SparseMatrixCSC; tol::Real=1e-6, maxits=1000, maxtime=Inf, @@ -883,7 +883,7 @@ end -function approxCholLap1(a::SparseMatrixCSC{Tv,Ti}; +function approxchol_lap1(a::SparseMatrixCSC{Tv,Ti}; tol::Real=1e-6, maxits=1000, maxtime=Inf, @@ -900,7 +900,7 @@ function approxCholLap1(a::SparseMatrixCSC{Tv,Ti}; if params.order == :deg - return approxCholLapGreedy(a, + return approxchol_lapGreedy(a, verbose=verbose, tol=tol, maxits=maxits, @@ -911,7 +911,7 @@ function approxCholLap1(a::SparseMatrixCSC{Tv,Ti}; elseif params.order == :wdeg - return approxCholLapWdeg(a, + return approxchol_lapWdeg(a, verbose=verbose, tol=tol, maxits=maxits, @@ -921,7 +921,7 @@ function approxCholLap1(a::SparseMatrixCSC{Tv,Ti}; else - return approxCholLapGiven(a, + return approxchol_lapGiven(a, verbose=verbose, tol=tol, maxits=maxits, @@ -935,15 +935,15 @@ function approxCholLap1(a::SparseMatrixCSC{Tv,Ti}; end """ - solver = approxCholSddm(sddm); x = solver(b); - solver = approxCholSddm(sddm; tol=1e-6, maxits=1000, maxtime=Inf, verbose=false, pcgIts=Int[], params=ApproxCholParams()) + solver = approxchol_sddm(sddm); x = solver(b); + solver = approxchol_sddm(sddm; tol=1e-6, maxits=1000, maxtime=Inf, verbose=false, pcgIts=Int[], params=ApproxCholParams()) -Solves sddm systems by wrapping approxCholLap. +Solves sddm systems by wrapping approxchol_lap. Not yet optimized directly for sddm. For more info, see http://danspielman.github.io/Laplacians.jl/latest/usingSolvers/index.html """ -approxCholSddm = sddmWrapLap(approxCholLap) +approxchol_sddm = sddmWrapLap(approxchol_lap) @@ -1118,7 +1118,7 @@ end This variation of approxChol creates a cholesky factor to do the elimination. It has not yet been optimized, and does not yet make the cholesky factor lower triangular """ -function approxCholLapChol(a::SparseMatrixCSC{Tv,Ti}; tol::Real=1e-6, maxits=1000, maxtime=Inf, verbose=false, pcgIts=Int[]) where {Tv,Ti} +function approxchol_lapChol(a::SparseMatrixCSC{Tv,Ti}; tol::Real=1e-6, maxits=1000, maxtime=Inf, verbose=false, pcgIts=Int[]) where {Tv,Ti} tol_ =tol maxits_ =maxits diff --git a/src/augTreeSolver.jl b/src/augTreeSolver.jl index 9eccfae4..957acf1c 100644 --- a/src/augTreeSolver.jl +++ b/src/augTreeSolver.jl @@ -40,7 +40,7 @@ This is the old alg. We now recommend using augmentTreeOpt. """ function augmentTree(tree::SparseMatrixCSC{Tv,Ti}, A::SparseMatrixCSC{Tv,Ti}, k::Ti) where {Tv,Ti} - st = compStretches(tree, A) + st = comp_stretches(tree, A) # just to be safe, remove the tree from this #= @@ -102,7 +102,7 @@ function augmentTreeOpt(tree::SparseMatrixCSC{Tv,Ti}, A::SparseMatrixCSC{Tv,Ti}; n = A.n m = length(ai) - st = compStretches(tree, Aminus) + st = comp_stretches(tree, Aminus) _,_,sv = findnz(triu(st)) @@ -270,7 +270,7 @@ function augTreeLapPrecon(a::SparseMatrixCSC{Tv,Ti}; params=AugTreeParams()) whe F = (h -> h) try - F = cholLap(augtree) + F = chol_lap(augtree) catch println("cholfact failed in augTreeLapPrecon. Going to backup routine") F = augTreeFactor(augtree, tree) @@ -362,7 +362,7 @@ function augTreeFactor(a, tree; verbose=false, a1 = rest + subtree la1 = lap(a1) - fsub = cholLap(a1) + fsub = chol_lap(a1) f1 = function(b::Array{Float64,1}) diff --git a/src/complexSolvers.jl b/src/complexSolvers.jl index bef2f2de..c20bb979 100644 --- a/src/complexSolvers.jl +++ b/src/complexSolvers.jl @@ -27,7 +27,7 @@ include("powerIteration.jl") export powerIteration """A list containing SDDM linear system solvers. They take in a SDDM matrix plus tol, maxits and maxtime parameters.""" -SDDMSolvers = [augTreeSddm, KMPSDDMSolver, approxCholSddm] +SDDMSolvers = [augTreeSddm, KMPSDDMSolver, approxchol_sddm] """A list containing Laplacian linear system solvers. They take in an adjacency matrix plus tol, maxits and maxtime parameters.""" -LapSolvers = [approxCholLap, augTreeLap, KMPLapSolver, cgLapSolver] +LapSolvers = [approxchol_lap, augTreeLap, KMPLapSolver, cgLapSolver] diff --git a/src/conditionNumber.jl b/src/conditionNumber.jl index 2382280b..27b9dc16 100644 --- a/src/conditionNumber.jl +++ b/src/conditionNumber.jl @@ -14,8 +14,8 @@ It is randomized, so you might want to run it again if you don't trust the answe function support(a1,a2; tol=1e-5) la1 = lap(a1) la2 = lap(a2) - f1 = approxCholLap(a1,tol=tol) - f2 = approxCholLap(a2,tol=tol) + f1 = approxchol_lap(a1,tol=tol) + f2 = approxchol_lap(a2,tol=tol) op12 = SqLinOp(false,1.0,size(a1,1),b->la2*f1(b)) op21 = SqLinOp(false,1.0,size(a2,1),b->la1*f2(b)) diff --git a/src/deprecated.jl b/src/deprecated.jl index 09141cec..f34f11fb 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -32,3 +32,11 @@ @deprecate plotGraph(gr,x,y;color=[0,0,1],dots=true,setaxis=true,number=false) plot_graph(gr,x,y;color=color,dots=dots,setaxis=setaxis,number=number) @deprecate plotGraph(gr,x,y,z;color=[0,0,1],dots=true,setaxis=true,number=false) plot_graph(gr,x,y,z;color=color,dots=dots,setaxis=setaxis,number=number) +@deprecate approxCholLap(a; args...) approxchol_lap(a; args...) +@deprecate approxCholSDDM(a; args...) approxchol_sddm(a; args...) +@deprecate cholLap(a; args...) chol_lap(a; args...) +@deprecate cholSDDM(a; args...) chol_sddm(a; args...) + +@deprecate spectralDrawing(a) spectral_drawing(a) +@deprecate spectralCoords(a) spectral_coords(a) +@deprecate compStretches(tree, mat) comp_stretches(tree, mat) diff --git a/src/graphOps.jl b/src/graphOps.jl index 90bb3221..d7cdd4d7 100644 --- a/src/graphOps.jl +++ b/src/graphOps.jl @@ -647,29 +647,29 @@ function plot_graph(gr,x,y,z;color=[0,0,1],dots=true,setaxis=true,number=false) end # plotGraph """ - spectralDrawing(a) + spectral_drawing(a) Computes spectral coordinates, and then uses plotGraph to draw """ -function spectralDrawing(a) +function spectral_drawing(a) - x, y = spectralCoords(a) + x, y = spectral_coords(a) plot_graph(a,x,y) -end # spectralDrawing +end # spectral_drawing """ - spectralCoords(a) + spectral_coords(a) Computes the spectral coordinates of a graph """ -function spectralCoords(a) +function spectral_coords(a) E = eigs(lap(a), nev = 3, which=:SR) V = E[2] return V[:,2], V[:,3] -end # spectralCoords +end # spectral_coords """ diff --git a/src/johnlind.jl b/src/johnlind.jl index 2889dbd6..f6a3d6b4 100644 --- a/src/johnlind.jl +++ b/src/johnlind.jl @@ -9,7 +9,7 @@ of the actual bounds. """ function johnlind(a::SparseMatrixCSC{Tv,Ti}; eps::Tv = 0.5, - solver=approxCholLap, + solver=approxchol_lap, retXhat::Bool = false) where {Tv,Ti} n = a.n diff --git a/src/pcg.jl b/src/pcg.jl index 0b12bca9..79532ac9 100644 --- a/src/pcg.jl +++ b/src/pcg.jl @@ -129,7 +129,7 @@ Specialized for the case when the preconditioner the Laplacian matrix of `B`. It solves the preconditioner by Cholesky Factorization. """ function pcgLapSolver(A::AbstractMatrix, B::AbstractMatrix; tol::Real=1e-6, maxits=Inf, maxtime=Inf, verbose=false, pcgIts=Int[]) - fact = cholLap(B) + fact = chol_lap(B) tol_=tol maxits_=maxits diff --git a/src/solverInterface.jl b/src/solverInterface.jl index 09077b6a..3c34c5c4 100644 --- a/src/solverInterface.jl +++ b/src/solverInterface.jl @@ -71,12 +71,12 @@ function nullSolver(a;params...) end """ - solveSDDM = cholSDDM(sddm::AbstractMatrix; tol, maxits, maxtime, verbose, pcgIts=Int[]) + solveSDDM = chol_sddm(sddm::AbstractMatrix; tol, maxits, maxtime, verbose, pcgIts=Int[]) This functions wraps cholfact so that it satsfies our interface. It ignores all the keyword arguments. """ -cholSDDM = wrapInterface(X->cholesky(X)) +chol_sddm = wrapInterface(X->cholesky(X)) """ @@ -240,7 +240,7 @@ function lapWrapComponents(solver, a::AbstractArray; tol::Real=1e-6, maxits=Inf, subSolver = nullSolver elseif (length(ind) < 50) - subSolver = lapWrapConnected(cholSDDM,asub) + subSolver = lapWrapConnected(chol_sddm,asub) else @@ -293,11 +293,11 @@ end """ - solver = cholLap(A::AbstractArray) + solver = chol_lap(A::AbstractArray) Uses Cholesky Factorization to solve systems in Laplacians. """ -cholLap = lapWrapSDDM(cholSDDM) +chol_lap = lapWrapSDDM(chol_sddm) @@ -347,7 +347,7 @@ For example ```julia julia> rhss = [] julia> a = wted_chimera(100) -julia> sola = approxCholLap(a) +julia> sola = approxchol_lap(a) julia> wrappedSolver = wrapCaptureRhs(sola,rhss) julia> b = randn(100) julia> x = wrappedSolver(b,verbose=true) @@ -384,7 +384,7 @@ For example ```julia julia> mats = [] julia> rhss = [] -julia> solver = wrapCapture(approxCholLap, mats, rhss) +julia> solver = wrapCapture(approxchol_lap, mats, rhss) julia> a = chimera(10) julia> f = solver(a); julia> size(mats[1]) diff --git a/src/sparsify.jl b/src/sparsify.jl index 2b22b70b..614cc16e 100644 --- a/src/sparsify.jl +++ b/src/sparsify.jl @@ -18,7 +18,7 @@ function sparsify(a; ep=0.3, matrixConcConst=4.0, JLfac=4.0) @warn "Calling sparsify with ep > 1 can produce a disconnected graph." end - f = approxCholLap(a,tol=1e-2); + f = approxchol_lap(a,tol=1e-2); n = size(a,1) k = round(Int, JLfac*log(n)) # number of dims for JL diff --git a/src/treeAlgs.jl b/src/treeAlgs.jl index 6b057b4b..8a5bef92 100644 --- a/src/treeAlgs.jl +++ b/src/treeAlgs.jl @@ -378,14 +378,14 @@ end # TarjanStretchSub Returns the answer as a sparse matrix with the same nonzero structure as `mat`. Assumes that `mat` is symmetric. `tree` should be the adjacency matrix of a spanning tree.""" -function compStretches(tree::SparseMatrixCSC{Tv,Ti}, mat::SparseMatrixCSC{Tv,Ti}) where {Tv,Ti} +function comp_stretches(tree::SparseMatrixCSC{Tv,Ti}, mat::SparseMatrixCSC{Tv,Ti}) where {Tv,Ti} t, depth = matToTreeDepth(tree) stretches = tarjanStretch(t,mat,depth) return stretches -end # compStretches +end # comp_stretches """Compute the vector of depths in a tree that is in DFS order, diff --git a/test/testByExport.jl b/test/testByExport.jl index 8697c87a..33c94e8a 100644 --- a/test/testByExport.jl +++ b/test/testByExport.jl @@ -204,8 +204,8 @@ twoLift(a,3) # export lap # export adj - # export spectralCoords - # export spectralDrawing + # export spectral_coords + # export spectral_drawing # export toUnitVector @@ -248,7 +248,7 @@ d2 = Laplacians.treeDepthDFS(t) # export tarjanStretch # export compDepth - # export compStretches + # export comp_stretches # export dfsOrder Laplacians.bfsOrder(t,1) @@ -302,7 +302,7 @@ blockSample(r) # export SolverTest, speedTestLapSolvers -solvers = [SolverTest(approxCholLap,"ac") SolverTest(augTreeLap,"aug")] +solvers = [SolverTest(approxchol_lap,"ac") SolverTest(augTreeLap,"aug")] dic = Dict() n = 1000 diff --git a/test/testByFile.jl b/test/testByFile.jl index 3351559f..ff692488 100644 --- a/test/testByFile.jl +++ b/test/testByFile.jl @@ -13,15 +13,15 @@ Laplacians.forceLap(abs.(a)) a = wted_chimera(100,101); la = lap(a); la[1,1] += 1; -f = Laplacians.sddmWrapLap(approxCholLap, la, verbose=true); +f = Laplacians.sddmWrapLap(approxchol_lap, la, verbose=true); b = randn(100); x = f(b); a = grid2(20) a2 = subsampleEdges(grid2(20),0.45) -f = approxCholLap(a2) +f = approxchol_lap(a2) its = [0] -f = approxCholLap(a2, pcgIts=its, verbose=true) +f = approxchol_lap(a2, pcgIts=its, verbose=true) # conditionNumber @@ -30,7 +30,7 @@ support(a2,a) conditionNumber(a, akpw(a), verbose=true) -f = approxCholLap(a, maxits=1) +f = approxchol_lap(a, maxits=1) conditionNumber(a, f, verbose=true) println("End of testByFile") diff --git a/test/testDrawing.jl b/test/testDrawing.jl index 4e484bd7..e138a9a3 100644 --- a/test/testDrawing.jl +++ b/test/testDrawing.jl @@ -1,7 +1,7 @@ if !haskey(ENV,"LAPLACIANS_NOPLOT") println("*** TESTING PLOTTING ***") a = wted_chimera(102,2) - spectralDrawing(a) + spectral_drawing(a) else println("NOT TESTING PLOTTING") end diff --git a/test/testSolvers.jl b/test/testSolvers.jl index 34edd007..d3eb22bb 100644 --- a/test/testSolvers.jl +++ b/test/testSolvers.jl @@ -56,19 +56,19 @@ f0 = Laplacians.lapWrapComponents(Laplacians.cgLapSolver, a) @test norm(la*f0(b,tol=1e-4,maxits=200,verbose=true)-b)/norm(b) < 1e-2 -f = Laplacians.lapWrapComponents(Laplacians.lapWrapConnected(cholSDDM),a) +f = Laplacians.lapWrapComponents(Laplacians.lapWrapConnected(chol_sddm),a) @test norm(la*f(b)-b)/norm(b) < 1e-8 -solver = Laplacians.lapWrapComponents(Laplacians.lapWrapConnected(Laplacians.cholSDDM)) +solver = Laplacians.lapWrapComponents(Laplacians.lapWrapConnected(Laplacians.chol_sddm)) f = solver(a,verbose = true) norm(la*f(b,tol=1e-3)-b)/norm(b) its2 = [0] f = Laplacians.lapWrapSDDM(Laplacians.cgSolver,a,tol=1e-2,pcgIts=its) @test norm(la*f(b,verbose=true,pcgIts = its2, tol=1e-3)-b) / norm(b) < 1e-2 -f = Laplacians.lapWrapSDDM(Laplacians.cholSDDM,a) +f = Laplacians.lapWrapSDDM(Laplacians.chol_sddm,a) @test norm(la*f(b)-b) / norm(b) < 1e-2 -f = Laplacians.cholLap(a) +f = Laplacians.chol_lap(a) @test norm(la*f(b)-b) / norm(b) < 1e-2 fs = Laplacians.lapWrapSDDM(cgSolver) f = fs(a, tol=1e-2, verbose=true) @@ -79,7 +79,7 @@ x = f(b, tol=1e-6); mats = [] rhss = [] -solver = Laplacians.wrapCapture(approxCholLap, mats, rhss) +solver = Laplacians.wrapCapture(approxchol_lap, mats, rhss) a = chimera(10) as = shortIntGraph(a) f = solver(a); @@ -89,7 +89,7 @@ b = randn(10) x = f(b); xs = fs(b); -solver = Laplacians.approxCholLapChol(a,verbose=true) +solver = Laplacians.approxchol_lapChol(a,verbose=true) x = solver(b); # testing approxChol internals @@ -189,13 +189,13 @@ b = b .- mean(b) la = lap(a) ee1 = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:deg), verbose=verbose, args...) end ee2 = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:wdeg), verbose=verbose, args...) end ee3 = function(a; verbose=false, args...) - approxCholLap(a; params=ApproxCholParams(:given), verbose=verbose, args...) + approxchol_lap(a; params=ApproxCholParams(:given), verbose=verbose, args...) end for sol in [augTreeLap, KMPLapSolver, cgLapSolver, ee1, ee2, ee3] fx1 = sol(a, tol=1e-6, maxtime=5);