52
52
function prefilter! (
53
53
:: Type{TWeights} , ret:: TCoefs , it:: BSpline
54
54
) where {TWeights,TCoefs<: AbstractArray }
55
- local buf, shape, retrs
56
55
sz = size (ret)
57
56
first = true
58
57
for dim in 1 : ndims (ret)
@@ -72,18 +71,7 @@ function diffop(::Type{TWeights}, n::Int, k::Int) where {TWeights}
72
71
end
73
72
diffop (n:: Int , k:: Int ) = diffop (Float64, n, k)
74
73
# ## TODO : add compiled constructor for most common operators of order k=1,2
75
- #
76
- # function diffop(::Type{TWeights}, n::Int, k::Int) where {TWeights}
77
- # D1 = spdiagm(0 => -ones(TWeights,n-1), 1 => ones(TWeights,n-1))[1:end-1, :]
78
- # D = D1
79
- # for i in 1:k-1
80
- # D = diff(D; dims=1)
81
- # # D = D1[1+i:end, 1+i:end] * D
82
- # # lmul!(D1[1+i:end, 1+i:end], D)
83
- # end
84
- #
85
- # D' * D
86
- # end
74
+
87
75
88
76
function prefilter! (
89
77
:: Type{TWeights} , ret:: TCoefs , it:: BSpline , λ:: Real , k:: Int
@@ -109,11 +97,12 @@ function prefilter!(
109
97
end
110
98
111
99
M, b = prefiltering_system (TWeights, eltype (TCoefs), sz[1 ], degree (it))
112
- # ## TEST REGULARIZATION
113
- n = sz[1 ]
114
- Q = Matrix (diffop (TWeights, n, k))
115
- K = cholesky (Matrix (M)' * Matrix (M) + λ * Q)
116
- B = Matrix (M)' * popwrapper (ret)
100
+ # # Solve with regularization
101
+ # Convert to dense Matrix because `*(Woodbury{Adjoint}, Woodbury)` is not defined
102
+ Mt = Matrix (M)'
103
+ Q = diffop (TWeights, sz[1 ], k)
104
+ K = cholesky (Mt * Matrix (M) + λ * Q)
105
+ B = Mt * popwrapper (ret)
117
106
ldiv! (popwrapper (ret), K, B)
118
107
119
108
ret
122
111
function prefilter! (
123
112
:: Type{TWeights} , ret:: TCoefs , its:: Tuple{Vararg{Union{BSpline,NoInterp}}}
124
113
) where {TWeights,TCoefs<: AbstractArray }
125
- local buf, shape, retrs
126
114
sz = size (ret)
127
115
for dim in 1 : ndims (ret)
128
116
it = iextract (its, dim)
0 commit comments