Skip to content

Commit 21e5a2f

Browse files
author
Tomas Lycken
committed
Merge pull request #104 from tlycken/remove-build-woodbury-specs
WIP: Remove `_build_woodbury_specs`
2 parents 9068682 + aceba94 commit 21e5a2f

File tree

5 files changed

+11
-43
lines changed

5 files changed

+11
-43
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
julia 0.4
22

3-
WoodburyMatrices 0.1
3+
WoodburyMatrices 0.1.5
44
Ratios
55
AxisAlgorithms

src/b-splines/cubic.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function prefiltering_system{T,TC}(::Type{T}, ::Type{TC}, n::Int,
167167
du[1] = dl[end] = zero(T)
168168

169169
# Now Woodbury correction to set `[1, 3], [n, n-2] ==> 1`
170-
specs = _build_woodbury_specs(T, n, (1, 3, one(T)), (n, n-2, one(T)))
170+
specs = WoodburyMatrices.sparse_factors(T, n, (1, 3, one(T)), (n, n-2, one(T)))
171171

172172
Woodbury(lufact!(Tridiagonal(dl, d, du), Val{false}), specs...), zeros(TC, n)
173173
end
@@ -187,7 +187,7 @@ function prefiltering_system{T,TC}(::Type{T}, ::Type{TC}, n::Int,
187187
# now need Woodbury correction to set :
188188
# - [1, 3] and [n, n-2] ==> -3
189189
# - [1, 4] and [n, n-3] ==> 1
190-
specs = _build_woodbury_specs(T, n,
190+
specs = WoodburyMatrices.sparse_factors(T, n,
191191
(1, 3, T(-3)),
192192
(n, n-2, T(-3)),
193193
(1, 4, one(T)),
@@ -212,7 +212,7 @@ function prefiltering_system{T,TC}(::Type{T}, ::Type{TC}, n::Int,
212212
# now need Woodbury correction to set :
213213
# - [1, 3] and [n, n-2] ==> -3
214214
# - [1, 4] and [n, n-3] ==> 1
215-
specs = _build_woodbury_specs(T, n,
215+
specs = WoodburyMatrices.sparse_factors(T, n,
216216
(1, 3, T(5)),
217217
(n, n-2, T(5)),
218218
(1, 4, -one(T)),
@@ -239,7 +239,7 @@ function prefiltering_system{T,TC}(::Type{T}, ::Type{TC}, n::Int,
239239

240240
# now need Woodbury correction to set :
241241
# - [1, 3] and [n, n-2] ==> 1
242-
specs = _build_woodbury_specs(T, n,
242+
specs = WoodburyMatrices.sparse_factors(T, n,
243243
(1, 3, one(T)),
244244
(n, n-2, one(T)),
245245
)
@@ -251,7 +251,7 @@ function prefiltering_system{T,TC,GT<:GridType}(::Type{T}, ::Type{TC}, n::Int,
251251
::Type{Cubic{Periodic}}, ::Type{GT})
252252
dl, d, du = inner_system_diags(T,n,Cubic{Periodic})
253253

254-
specs = _build_woodbury_specs(T, n,
254+
specs = WoodburyMatrices.sparse_factors(T, n,
255255
(1, n, du[1]),
256256
(n, 1, dl[end])
257257
)
@@ -273,7 +273,7 @@ function prefiltering_system{T,TC,GT<:GridType}(::Type{T}, ::Type{TC}, n::Int,
273273
::Type{Cubic{Free}}, ::Type{GT})
274274
dl, d, du = inner_system_diags(T,n,Cubic{Periodic})
275275

276-
specs = _build_woodbury_specs(T, n,
276+
specs = WoodburyMatrices.sparse_factors(T, n,
277277
(1, n, du[1]),
278278
(n, 1, dl[end])
279279
)

src/b-splines/quadratic.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function prefiltering_system{T,TC,BC<:Union{Flat,Reflect}}(::Type{T}, ::Type{TC}
136136
d[1] = d[end] = -1
137137
du[1] = dl[end] = 0
138138

139-
specs = _build_woodbury_specs(T, n,
139+
specs = WoodburyMatrices.sparse_factors(T, n,
140140
(1, 3, one(T)),
141141
(n, n-2, one(T))
142142
)
@@ -149,7 +149,7 @@ function prefiltering_system{T,TC,GT<:GridType}(::Type{T}, ::Type{TC}, n::Int, :
149149
d[1] = d[end] = 1
150150
du[1] = dl[end] = -2
151151

152-
specs = _build_woodbury_specs(T, n,
152+
specs = WoodburyMatrices.sparse_factors(T, n,
153153
(1, 3, one(T)),
154154
(n, n-2, one(T)),
155155
)
@@ -162,7 +162,7 @@ function prefiltering_system{T,TC,GT<:GridType}(::Type{T}, ::Type{TC}, n::Int, :
162162
d[1] = d[end] = 1
163163
du[1] = dl[end] = -3
164164

165-
specs = _build_woodbury_specs(T, n,
165+
specs = WoodburyMatrices.sparse_factors(T, n,
166166
(1, 3, 3),
167167
(1, 4, -1),
168168
(n, n-2, 3),
@@ -174,7 +174,7 @@ end
174174
function prefiltering_system{T,TC,GT<:GridType}(::Type{T}, ::Type{TC}, n::Int, ::Type{Quadratic{Periodic}}, ::Type{GT})
175175
dl,d,du = inner_system_diags(T,n,Quadratic{Periodic})
176176

177-
specs = _build_woodbury_specs(T, n,
177+
specs = WoodburyMatrices.sparse_factors(T, n,
178178
(1, n, du[1]),
179179
(n, 1, dl[end])
180180
)

src/utils.jl

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,2 @@
11
@inline sqr(x) = x*x
22
@inline cub(x) = x*x*x
3-
4-
"""
5-
Build `rowspec`, `valspec`, `colspec` such that the product
6-
7-
`out = rowspec * valspec * colspec` will be equivalent to:
8-
9-
```julia
10-
out = zeros(n, n)
11-
12-
for (i, j, v) in args
13-
out[i, j] = v
14-
end
15-
```
16-
17-
"""
18-
function _build_woodbury_specs{T}(::Type{T}, n::Int, args::Tuple{Int, Int, Any}...)
19-
m = length(args)
20-
rowspec = spzeros(T, n, m)
21-
colspec = spzeros(T, m, n)
22-
valspec = zeros(T, m, m)
23-
24-
ix = 1
25-
for (i, (row, col, val)) in enumerate(args)
26-
rowspec[row, ix] = 1
27-
colspec[ix, col] = 1
28-
valspec[ix, ix] = val
29-
ix += 1
30-
end
31-
32-
rowspec, valspec, colspec
33-
end

test/b-splines/cubic.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,4 @@ itp_flat_c = interpolate(A, BSpline(Cubic(Flat())), OnCell())
8181
@test_approx_eq_eps gradient(itp_flat_c, .5)[1] 0 eps()
8282
@test_approx_eq_eps gradient(itp_flat_c, ix[end]+.5)[1] 0 eps()
8383

84-
8584
end

0 commit comments

Comments
 (0)