Skip to content

Commit ea56397

Browse files
authored
Make BandedMatrix immutable (#403)
* Make BandedMatrix immutable * Don't export isbanded * Add brandn * Update BandedMatrices.jl * Update index.md
1 parent 59f4758 commit ea56397

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BandedMatrices"
22
uuid = "aae01518-5342-5314-be14-df237901396f"
3-
version = "0.17.38"
3+
version = "1.0.0"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

docs/src/index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ BandedMatrix
1111
brand
1212
```
1313

14+
```@docs
15+
brandn
16+
```
17+
1418
```@meta
1519
DocTestSetup = quote
1620
using BandedMatrices
@@ -98,6 +102,10 @@ band
98102
BandRange
99103
```
100104

105+
```@docs
106+
BandedMatrices.isbanded
107+
```
108+
101109
To loop over the nonzero elements of a BandedMatrix, you can use `colrange(A, c)` and `rowrange(A, r)`.
102110

103111

@@ -116,7 +124,7 @@ interface consists of the following:
116124
| Required methods | Brief description |
117125
| :--------------- | :--------------- |
118126
| `bandwidths(A)` | Returns a tuple containing the sub-diagonal and super-diagonal bandwidth |
119-
| `isbanded(A)` | Override to return `true` |
127+
| `BandedMatrices.isbanded(A)` | Override to return `true` |
120128

121129
| Optional methods | Brief description |
122130
| :--------------- | :--------------- |

src/BandedMatrices.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const TransposeFact = isdefined(LinearAlgebra, :TransposeFactorization) ?
4848
export BandedMatrix,
4949
bandrange,
5050
brand,
51+
brandn,
5152
bandwidth,
5253
BandError,
5354
band,
@@ -56,7 +57,6 @@ export BandedMatrix,
5657
bandwidths,
5758
colrange,
5859
rowrange,
59-
isbanded,
6060
Zeros,
6161
Fill,
6262
Ones,

src/banded/BandedMatrix.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
function _BandedMatrix end
1515

16-
mutable struct BandedMatrix{T, CONTAINER, RAXIS} <: AbstractBandedMatrix{T}
16+
struct BandedMatrix{T, CONTAINER, RAXIS} <: AbstractBandedMatrix{T}
1717
data::CONTAINER # l+u+1 x n (# of columns)
1818
raxis::RAXIS # axis for rows (col axis comes from data)
1919
l::Int # lower bandwidth ≥0
@@ -163,7 +163,7 @@ promote_rule(::Type{BandedMatrix{T1, C1}}, ::Type{BandedMatrix{T2, C2}}) where {
163163
BandedMatrix{promote_type(T1,T2), promote_type(C1, C2)}
164164

165165

166-
for (op,bop) in ((:(rand),:brand),)
166+
for (op,bop) in ((:rand,:brand), (:randn,:brandn))
167167
@eval begin
168168
$bop(::Type{T},n::Integer,m::Integer,a::Integer,b::Integer) where {T} =
169169
_BandedMatrix($op(T,max(0,b+a+1),m),n,a,b)
@@ -193,6 +193,13 @@ Creates an `n×m` banded matrix with random numbers in the bandwidth of type `T
193193
"""
194194
brand
195195

196+
"""
197+
brandn(T,n,m,l,u)
198+
199+
Creates an `n×m` banded matrix with random normals in the bandwidth of type `T` with bandwidths `(l,u)`
200+
"""
201+
brand
202+
196203
## Conversions from AbstractArrays, we include FillArrays in case `zeros` is ever faster
197204
BandedMatrix{T}(A::AbstractMatrix, bnds::NTuple{2,Integer}) where T =
198205
BandedMatrix{T, Matrix{T}}(A, bnds)

test/test_subarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using BandedMatrices, FillArrays, ArrayLayouts, Test
22
import LinearAlgebra: axpy!
3-
import BandedMatrices: BandedColumns, bandeddata, MemoryLayout, BandedSubBandedMatrix, _BandedMatrix, sub_materialize
3+
import BandedMatrices: BandedColumns, bandeddata, MemoryLayout, BandedSubBandedMatrix, _BandedMatrix, sub_materialize, isbanded
44

55

66
@testset "BandedMatrix SubArray" begin

test/test_symbanded.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using ArrayLayouts
22
using BandedMatrices
3-
import BandedMatrices: MemoryLayout, SymmetricLayout, HermitianLayout, BandedColumns
3+
import BandedMatrices: MemoryLayout, SymmetricLayout, HermitianLayout, BandedColumns, isbanded
44
using FillArrays
55
using GenericLinearAlgebra
66
using LinearAlgebra

test/test_tribanded.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using BandedMatrices, LinearAlgebra, ArrayLayouts, Test
2-
import BandedMatrices: BandedColumns, BandedRows
2+
import BandedMatrices: BandedColumns, BandedRows, isbanded
33

44

55
@testset "Triangular" begin

0 commit comments

Comments
 (0)