Skip to content

Commit cc5cbf7

Browse files
Merge pull request #39 from ChrisRackauckas-Claude/docs-improvements-20251229-195327
Documentation improvements: Expand examples and enhance docstrings
2 parents 5a947c1 + c898b72 commit cc5cbf7

3 files changed

Lines changed: 64 additions & 7 deletions

File tree

.github/dependabot.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ updates:
55
directory: "/" # Location of package manifests
66
schedule:
77
interval: "weekly"
8+
ignore:
9+
- dependency-name: "crate-ci/typos"
10+
update-types: ["version-update:semver-patch", "version-update:semver-minor"]

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,33 @@ repository.
2020

2121
## High Level Examples
2222

23+
### Basic Construction and Usage
24+
2325
```julia
24-
using FastAlmostBandedMatrices
26+
using FastAlmostBandedMatrices, LinearAlgebra
2527

26-
m = 2
27-
n = 10
28+
m = 2 # Fill rank
29+
n = 10 # Matrix dimension
2830

29-
A1 = AlmostBandedMatrix(brand(Float64, n, n, m + 1, m), rand(Float64, m, n))
31+
# Create an almost banded matrix
32+
# brand(T, m, n, lower_bandwidth, upper_bandwidth) creates a random banded matrix
33+
A = AlmostBandedMatrix(brand(Float64, n, n, m + 1, m), rand(Float64, m, n))
34+
35+
# Query matrix properties
36+
almostbandwidths(A) # Returns (3, 2) - the bandwidths of the banded part
37+
almostbandedrank(A) # Returns 2 - the rank of the fill part
38+
39+
# Access the parts
40+
B = bandpart(A) # Get the banded part
41+
F = fillpart(A) # Get the fill part (low-rank correction)
42+
43+
# Solve linear systems efficiently
44+
b = rand(n)
45+
x = A \ b # Uses specialized QR factorization
46+
47+
# QR factorization
48+
fact = qr(A)
49+
Q, R = fact.Q, fact.R
3050
```
3151

3252
## Benchmarks

src/FastAlmostBandedMatrices.jl

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ end
8181

8282
MemoryLayout(::Type{<:AlmostBandedMatrix}) = AlmostBandedLayout()
8383

84+
"""
85+
finish_part_setindex!(A::AlmostBandedMatrix)
86+
finish_part_setindex!(bands, fill)
87+
88+
Synchronize the overlapping region between the banded part and the fill part of an
89+
`AlmostBandedMatrix`. This function copies values from the `fill` part into the
90+
corresponding positions in the `bands` part where they overlap.
91+
92+
This is automatically called during construction but may need to be called manually if
93+
the fill part is modified directly after construction.
94+
"""
8495
@inline function finish_part_setindex!(A)
8596
return finish_part_setindex!(bandpart(A), fillpart(A))
8697
end
@@ -97,21 +108,44 @@ end
97108
"""
98109
bandpart(A::AlmostBandedMatrix)
99110
100-
Banded Part of the AlmostBandedMatrix.
111+
Return the banded part of the `AlmostBandedMatrix`. This is a `BandedMatrix` that stores
112+
the banded structure including the overlapping region with the fill part.
113+
114+
# Example
115+
```julia
116+
A = AlmostBandedMatrix(brand(Float64, 10, 10, 3, 2), rand(Float64, 2, 10))
117+
B = bandpart(A) # Returns the BandedMatrix component
118+
```
101119
"""
102120
@inline bandpart(A::AlmostBandedMatrix) = A.bands
103121

104122
"""
105123
fillpart(A::AlmostBandedMatrix)
106124
107-
Fill Part of the AlmostBandedMatrix.
125+
Return the fill part of the `AlmostBandedMatrix`. This is typically a low-rank matrix that
126+
represents additional structure beyond the banded part. The fill part overlaps with the
127+
first `almostbandedrank(A)` rows of the banded part.
128+
129+
# Example
130+
```julia
131+
A = AlmostBandedMatrix(brand(Float64, 10, 10, 3, 2), rand(Float64, 2, 10))
132+
F = fillpart(A) # Returns the fill matrix (2×10)
133+
```
108134
"""
109135
@inline fillpart(A::AlmostBandedMatrix) = A.fill
110136

111137
"""
112138
exclusive_bandpart(A::AlmostBandedMatrix)
113139
114-
Banded Part of the AlmostBandedMatrix without the overlapping part.
140+
Return the banded part of the `AlmostBandedMatrix` excluding the rows that overlap with
141+
the fill part. This is a view of the banded matrix starting from row
142+
`almostbandedrank(A) + 1`.
143+
144+
# Example
145+
```julia
146+
A = AlmostBandedMatrix(brand(Float64, 10, 10, 3, 2), rand(Float64, 2, 10))
147+
E = exclusive_bandpart(A) # Returns a view of rows 3:10 of the banded part
148+
```
115149
"""
116150
@inline function exclusive_bandpart(A)
117151
B, F = bandpart(A), fillpart(A)

0 commit comments

Comments
 (0)