Skip to content

Commit 38e13a1

Browse files
committed
Minor polish
1 parent 12c13fb commit 38e13a1

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

docs/src/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ import Arpack, IterativeSolvers, KrylovKit, TSVD, ArnoldiMethod
5050
# Example 1, 1-dimensional Laplacian with periodic boundary conditions
5151
function leftdiff!(y::AbstractVector, x::AbstractVector) # left difference assuming periodic boundary conditions
5252
N = length(x)
53-
length(y) == N || throw(DimensionMismatch())
54-
@inbounds for i=1:N
53+
axes(y) == axes(x) || throw(DimensionMismatch())
54+
@inbounds for i in eachindex(x, y)
5555
y[i] = x[i] - x[mod1(i-1, N)]
5656
end
5757
return y
5858
end
5959

6060
function mrightdiff!(y::AbstractVector, x::AbstractVector) # minus right difference
6161
N = length(x)
62-
length(y) == N || throw(DimensionMismatch())
63-
@inbounds for i=1:N
62+
axes(y) == axes(x) || throw(DimensionMismatch())
63+
@inbounds for i in eachindex(x, y)
6464
y[i] = x[i] - x[mod1(i+1, N)]
6565
end
6666
return y

docs/src/related.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The following open-source packages provide similar or even extended functionalit
88
[`LinearOperators.jl`](https://github.com/JuliaSmoothOptimizers/LinearOperators.jl)
99
and the Python package [`PyLops`](https://github.com/equinor/pylops)
1010
* [`fastmat`: fast linear transforms in Python](https://pypi.org/project/fastmat/)
11+
* [`JOLI.jl`: Julia Operators LIbrary](https://github.com/slimgroup/JOLI.jl)
1112
* [`FunctionOperators.jl`](https://github.com/hakkelt/FunctionOperators.jl)
1213
and [`LinearMapsAA.jl`](https://github.com/JeffFessler/LinearMapsAA.jl)
1314
also support mappings between `Array`s, inspired by the `fatrix` object type in the
@@ -19,8 +20,10 @@ there exist further related packages in the Julia ecosystem:
1920
* [`LazyArrays.jl`](https://github.com/JuliaArrays/LazyArrays.jl)
2021
* [`BlockArrays.jl`](https://github.com/JuliaArrays/BlockArrays.jl)
2122
* [`BlockDiagonals.jl`](https://github.com/invenia/BlockDiagonals.jl)
23+
* [`BlockFactorizations.jl`](https://github.com/SebastianAment/BlockFactorizations.jl)
2224
* [`Kronecker.jl`](https://github.com/MichielStock/Kronecker.jl)
2325
* [`FillArrays.jl`](https://github.com/JuliaArrays/FillArrays.jl)
26+
* [`LiftedMaps.jl](https://github.com/krcools/LiftedMaps.jl)
2427

2528
Since these packages provide types that are subtypes of Julia `Base`'s `AbstractMatrix` type,
2629
objects of those types can be wrapped by a `LinearMap` and freely mixed with, for instance,

src/blockmap.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MulStyle(A::BlockMap) = MulStyle(A.maps...)
2626
function _getranges(maps, dim, inds=1:length(maps))
2727
ends = map(i -> size(maps[i], dim)::Int, inds)
2828
cumsum!(ends, ends)
29-
starts = vcat(1, 1 .+ @views ends[1:end-1])
29+
starts = vcat(1, 1 .+ @views ends[firstindex(ends):lastindex(ends)-1])
3030
return UnitRange.(starts, ends)
3131
end
3232

@@ -172,7 +172,7 @@ function Base.hvcat(rows::Tuple{Vararg{Int}},
172172
throw(ArgumentError("mismatch between row sizes and number of arguments"))
173173
n = fill(-1, length(As))
174174
j = 0
175-
for i in 1:nr # infer UniformScaling sizes from row counts, if possible:
175+
for i in eachindex(rows) # infer UniformScaling sizes from row counts, if possible:
176176
ni = -1 # number of rows in this block-row, -1 indicates unknown
177177
for k in 1:rows[i]
178178
if !isa(As[j+k], UniformScaling)
@@ -190,10 +190,10 @@ function Base.hvcat(rows::Tuple{Vararg{Int}},
190190
# check for consistent total column number
191191
nc = -1
192192
j = 0
193-
for i in 1:nr
193+
for i in eachindex(rows)
194194
nci = 0
195195
rows[i] > 0 && n[j+1] == -1 && (j += rows[i]; continue)
196-
for k = 1:rows[i]
196+
for k in 1:rows[i]
197197
nci += isa(As[j+k], UniformScaling) ? n[j+k] : size(As[j+k], 2)::Int
198198
end
199199
nc >= 0 && nc != nci && throw(DimensionMismatch("mismatch in number of columns"))
@@ -202,11 +202,11 @@ function Base.hvcat(rows::Tuple{Vararg{Int}},
202202
end
203203
nc == -1 && throw(ArgumentError("sizes of UniformScalings could not be inferred"))
204204
j = 0
205-
for i in 1:nr
205+
for i in eachindex(rows)
206206
if rows[i] > 0 && n[j+1] == -1 # this row consists entirely of UniformScalings
207207
nci, r = divrem(nc, rows[i])
208208
r != 0 && throw(DimensionMismatch("indivisible UniformScaling sizes"))
209-
for k = 1:rows[i]
209+
for k in 1:rows[i]
210210
n[j+k] = nci
211211
end
212212
end

src/conversion.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function SparseArrays.sparse(A::LinearMap{T}) where {T}
2828
v = fill(zero(T), N)
2929
Av = Vector{T}(undef, M)
3030

31-
@inbounds for i in 1:N
31+
@inbounds for i in eachindex(v, colptr)
3232
v[i] = one(T)
3333
_unsafe_mul!(Av, A, v)
3434
js = findall(!iszero, Av)

0 commit comments

Comments
 (0)