You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* implement Q based qrjacobimatrix in O(n)
* fix test name
* factor 2 spee-up for Q method
* more optimisations (final for now)
* same QR in both bands. affects both R and Q method
* reduce cost slightly
* Update src/choleskyQR.jl
Co-authored-by: Sheehan Olver <[email protected]>
* Update src/choleskyQR.jl
Co-authored-by: Sheehan Olver <[email protected]>
* Update src/choleskyQR.jl
Co-authored-by: Sheehan Olver <[email protected]>
* Update src/choleskyQR.jl
Co-authored-by: Sheehan Olver <[email protected]>
* implement dlfivefifty's notes
* a number of small fixes
* add a test that checks resizing is consistent
* bugfix in test
* add missing import in tests
* write out the dot products in R method
* view instead of getindex to allocations
* remove more allocations
* switch to in-place householder
* bugfix for changes in R method
* generate bands in tandem but also keep them as vectors
* Update src/choleskyQR.jl
Co-authored-by: Sheehan Olver <[email protected]>
* remove redundant dv = J.dv
* steps towards lowering allocations
* reduce allocations again
* clarify minor comment
* use reflectorApply!
* removal of redundant computation
* replace reflectorapply! with inplaceHouseholder!
* prep for 1.9 fix
* Update Project.toml
* Update ci.yml
* Update Project.toml
---------
Co-authored-by: Sheehan Olver <[email protected]>
returns the Jacobi matrix `X` associated to a quasi-matrix of polynomials
38
-
orthogonal with respect to `w(x) w_p(x)` where `w_p(x)` is the weight of the polynomials in `P`.
38
+
orthogonal with respect to `w(x) w_p(x)` where `w_p(x)` is the weight of the polynomials in `P` by computing a Cholesky decomposition of the weight modification.
39
39
40
40
The resulting polynomials are orthonormal on the same domain as `P`. The supplied `P` must be normalized. Accepted inputs are `w` as a function or `W` as an infinite matrix representing multiplication with the function `w` on the basis `P`.
41
41
"""
@@ -51,61 +51,62 @@ function cholesky_jacobimatrix(W::AbstractMatrix, Q)
data::Vector{T}# store band entries, :dv for diagonal, :ev for off-diagonal
58
+
# The generated Jacobi operators are symmetric tridiagonal, so we store their data in two cached bands which are generated in tandem but can be accessed separately.
returns the Jacobi matrix `X` associated to a quasi-matrix of polynomials
117
-
orthogonal with respect to `w(x) w_p(x)` where `w_p(x)` is the weight of the polynomials in `P`.
118
+
orthogonal with respect to `w(x) w_p(x)` where `w_p(x)` is the weight of the polynomials in `P` by computing a QR decomposition of the square root weight modification.
118
119
119
120
The resulting polynomials are orthonormal on the same domain as `P`. The supplied `P` must be normalized. Accepted inputs for `sqrtw` are the square root of the weight modification as a function or `sqrtW` as an infinite matrix representing multiplication with the function `sqrt(w)` on the basis `P`.
121
+
122
+
The underlying QR approach allows two methods, one which uses the Q matrix and one which uses the R matrix. To change between methods, an optional argument :Q or :R may be supplied. The default is to use the Q method.
data::Vector{T}# store band entries, :dv for diagonal, :ev for off-diagonal
135
-
U::ApplyArray{T}# store upper triangular conversion matrix (needed to extend available entries)
136
-
UX::ApplyArray{T}# store U*X, where X is the Jacobi matrix of the original P (needed to extend available entries)
132
+
F =qr(sqrtW)
133
+
QRJD =QRJacobiData{method,T}(F,Q)
134
+
SymTridiagonal(view(QRJD,:,1),view(QRJD,:,2))
135
+
end
136
+
137
+
# The generated Jacobi operators are symmetric tridiagonal, so we store their data in two cached bands which are generated in tandem but can be accessed separately.
ev[1] = M[1,2]*sign(F.R[1,1]*F.R[2,2]) # includes possible correction for sign (only needed in off-diagonal case), since the QR decomposition does not guarantee positive diagonal on R
170
+
K =Matrix(X[2:b+1,2:b+1])
171
+
K[1:end-1,1:end-1] .=view(M,2:b,2:b)
172
+
returnQRJacobiData{:Q,T}(dv, ev, F, K, P, 1)
173
+
end
174
+
functionQRJacobiData{:R,T}(F, P) where T
175
+
U = F.R
176
+
U =ApplyArray(*,Diagonal(sign.(view(U,band(0)))),U) # QR decomposition does not force positive diagonals on R by default
154
177
X =jacobimatrix(P)
155
178
UX =ApplyArray(*,U,X)
156
-
ev =zeros(T,2) # compute a length 2 vector on first go
dv[k] =-U[k-1,k]*UX[k,k-1]/(U[k-1,k-1]*U[k,k])+UX[k,k]./U[k,k] # this is dot(view(UX,k,k-1:k), U[k-1:k,k-1:k] \ ek)
244
+
ev[k] = UX[k,k-1]/U[k+1,k+1]*(-U[k-1,k+1]/U[k-1,k-1]+U[k-1,k]*U[k,k+1]/(U[k-1,k-1]*U[k,k]))+UX[k,k]/U[k+1,k+1]*(-U[k,k+1]/U[k,k])+UX[k,k+1]/U[k+1,k+1] # this is dot(view(UX,k,k-1:k+1), U[k-1:k+1,k-1:k+1] \ ek)
0 commit comments