We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fafa4d6 commit 466b1c5Copy full SHA for 466b1c5
Project.toml
@@ -1,6 +1,6 @@
1
name = "BandedMatrices"
2
uuid = "aae01518-5342-5314-be14-df237901396f"
3
-version = "0.17.32"
+version = "0.17.33"
4
5
[deps]
6
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -9,6 +9,12 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
10
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
11
12
+[weakdeps]
13
+SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
14
+
15
+[extensions]
16
+BandedMatricesSparseArraysExt = "SparseArrays"
17
18
[compat]
19
Aqua = "0.6"
20
ArrayLayouts = "1"
@@ -25,7 +31,8 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
25
31
GenericLinearAlgebra = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
26
32
InfiniteArrays = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
27
33
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
34
28
35
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
29
36
30
37
[targets]
-test = ["Aqua", "Base64", "Documenter", "GenericLinearAlgebra", "InfiniteArrays", "Random", "Test"]
38
+test = ["Aqua", "Base64", "Documenter", "GenericLinearAlgebra", "InfiniteArrays", "Random", "SparseArrays", "Test"]
ext/BandedMatricesSparseArraysExt.jl
@@ -0,0 +1,38 @@
+module BandedMatricesSparseArraysExt
+using BandedMatrices
+using BandedMatrices: _banded_rowval, _banded_colval, _banded_nzval
+using SparseArrays
+import SparseArrays: sparse
7
8
+function sparse(B::BandedMatrix)
+ sparse(_banded_rowval(B), _banded_colval(B), _banded_nzval(B), size(B)...)
+end
+function BandedMatrices.bandwidths(A::SparseMatrixCSC)
+ l,u = -size(A,1),-size(A,2)
+ m,n = size(A)
+ rows = rowvals(A)
+ vals = nonzeros(A)
+ for j = 1:n
+ for ind in nzrange(A, j)
+ i = rows[ind]
21
+ # We skip non-structural zeros when computing the
22
+ # bandwidths.
23
+ iszero(vals[ind]) && continue
24
+ ij = abs(i-j)
+ if i ≥ j
+ l = max(l, ij)
+ u = max(u, -ij)
+ elseif i < j
+ l = max(l, -ij)
+ u = max(u, ij)
+ end
+ l,u
src/BandedMatrices.jl
@@ -1,5 +1,5 @@
module BandedMatrices
-using Base, FillArrays, ArrayLayouts, LinearAlgebra, SparseArrays
+using Base, FillArrays, ArrayLayouts, LinearAlgebra
using Base: require_one_based_indexing, reindex, checkbounds, @propagate_inbounds,
oneto, promote_op, MultiplicativeInverses, OneTo, ReshapedArray, Slice
@@ -24,8 +24,6 @@ import LinearAlgebra: axpy!, _chol!, rot180, dot, cholcopy, _apply_ipiv_rows!,
using LinearAlgebra.LAPACK
using LinearAlgebra.LAPACK: chkuplo, chktrans
-import SparseArrays: sparse
-
import ArrayLayouts: MemoryLayout, transposelayout, triangulardata,
conjlayout, symmetriclayout, symmetricdata,
triangularlayout, MatLdivVec, hermitianlayout, hermitiandata,
@@ -94,6 +92,11 @@ include("tribanded.jl")
94
92
95
93
include("interfaceimpl.jl")
96
+if !isdefined(Base, :get_extension)
+ include("../ext/BandedMatricesSparseArraysExt.jl")
97
98
99
include("precompile.jl")
100
101
102
end #module
src/banded/BandedMatrix.jl
@@ -782,9 +782,6 @@ function _banded_nzval(B::AbstractMatrix)
782
end
783
784
785
-sparse(B::BandedMatrix) = sparse(_banded_rowval(B), _banded_colval(B), _banded_nzval(B), size(B)...)
786
787
788
789
790
function _bidiagonalize!(A::AbstractMatrix{T}, M::BandedColumnMajor) where T
src/generic/AbstractBandedMatrix.jl
@@ -22,32 +22,6 @@ Returns a tuple containing the lower and upper bandwidth of `A`, in order.
bandwidths(A::AbstractVecOrMat) = bandwidths(MemoryLayout(A), A)
bandwidths(_, A) = (size(A,1)-1 , size(A,2)-1)
-function BandedMatrices.bandwidths(A::SparseMatrixCSC)
- l,u = -size(A,1),-size(A,2)
- m,n = size(A)
- rows = rowvals(A)
- vals = nonzeros(A)
- for j = 1:n
- for ind in nzrange(A, j)
- i = rows[ind]
- # We skip non-structural zeros when computing the
- # bandwidths.
- iszero(vals[ind]) && continue
- ij = abs(i-j)
- if i ≥ j
39
- l = max(l, ij)
40
- u = max(u, -ij)
41
- elseif i < j
42
- l = max(l, -ij)
43
- u = max(u, ij)
44
- end
45
46
47
48
- l,u
49
-end
50
51
"""
52
bandwidth(A,i)
53
0 commit comments