-
Notifications
You must be signed in to change notification settings - Fork 4
Add BandedPlusSemiseparable and QR #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 8 commits
e3c5666
bea0dcf
4deb7e6
0689cac
39d87ab
c181f27
7733e8e
cd70feb
b8adeaf
e6ee517
f91df4c
165491d
262b792
95c460c
8a6d491
88fadc2
66ad1cb
d51520c
24bc3fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,8 @@ jobs: | |
| fail-fast: false | ||
| matrix: | ||
| version: | ||
| - '1.10' | ||
| - 'lts' | ||
| - '1' | ||
| os: | ||
| - ubuntu-latest | ||
| - macOS-latest | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| name = "SemiseparableMatrices" | ||
| uuid = "f8ebbe35-cbfb-4060-bf7f-b10e4670cf57" | ||
| authors = ["Sheehan Olver <[email protected]>"] | ||
| version = "0.4.0" | ||
| version = "0.5.0" | ||
|
|
||
| [deps] | ||
| ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,372 @@ | ||||||
| struct BandedPlusSemiseparableMatrix{T} <: LayoutMatrix{T} | ||||||
| bands::BandedMatrix{T} | ||||||
| lowerfill::LowRankMatrix{T} | ||||||
| upperfill::LowRankMatrix{T} | ||||||
| end | ||||||
|
|
||||||
| BandedPlusSemiseparableMatrix(B, (U,V), (W,S)) = BandedPlusSemiseparableMatrix(B, LowRankMatrix(U, V'), LowRankMatrix(W, S')) | ||||||
|
|
||||||
| size(A::BandedPlusSemiseparableMatrix) = size(A.bands) | ||||||
| copy(A::BandedPlusSemiseparableMatrix) = A # not mutable | ||||||
|
|
||||||
| function getindex(A::BandedPlusSemiseparableMatrix, k::Integer, j::Integer) | ||||||
| if j > k | ||||||
| A.upperfill[k,j] + A.bands[k,j] | ||||||
| elseif k > j | ||||||
| A.lowerfill[k,j] + A.bands[k,j] | ||||||
| else | ||||||
| A.bands[k,j] | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
|
|
||||||
| """ | ||||||
| Represents factors matrix for QR for banded+semiseparable. we have | ||||||
|
|
||||||
| for j = 0, we have A₀=tril(UV',-1) + B + triu(WS',1); | ||||||
| F = qrfactUnblocked!(A₀).factors # full QR factors; | ||||||
| As j increases, for BandedPlusSemiseparableQRPerturbedFactors A: | ||||||
| A[1:j,:] == F[1:j,:]; | ||||||
| A[:,1:j] == F[:,1:j]; | ||||||
| A[k, k] == F[k, k] for k < j; | ||||||
| A[j+1:end,j+1:end] == A₀[j+1:end,j+1:end] + U[j+1:end,:]*Q*S[j+1:end]' + U[j+1:end,:]*K*U[j+1:end]'*A₀[j+1:end,j+1:end] | ||||||
| + U[j+1:end,:]*[Eₛ 0] + [Xₛ;0]*S[j+1:end]' + [Yₛ;0]*U[j+1:end]'*A₀[j+1:end,j+1:end] + [Zₛ 0;0 0] | ||||||
| """ | ||||||
|
|
||||||
| struct BandedPlusSemiseparableQRPerturbedFactors{T} <: LayoutMatrix{T} | ||||||
| n::Int # matrix size | ||||||
|
||||||
| r::Int # lower rank | ||||||
|
||||||
| p::Int # upper rank | ||||||
|
||||||
| l::Int # lower bandwidth | ||||||
|
||||||
| m::Int # upper bandwidth | ||||||
| U::Matrix{T} # n × r | ||||||
| V::Matrix{T} # n × r | ||||||
| W::Matrix{T} # n × (p+r) | ||||||
| S::Matrix{T} # n × (p+r) | ||||||
| B::BandedMatrix{T} # lower bandwidth l and upper bandwidth l + m | ||||||
|
||||||
|
|
||||||
| Q::Matrix{T} # r × p | ||||||
| K::Matrix{T} # r × r | ||||||
| Eₛ::Matrix{T} # r × min(l+m,n) | ||||||
| Xₛ::Matrix{T} # min(l,n) × p | ||||||
| Yₛ::Matrix{T} # min(l,n) × r | ||||||
| Zₛ::Matrix{T} # min(l,n) × min(l+m,n) | ||||||
|
|
||||||
| j::Base.RefValue{Int} # how many columns have been upper-triangulised | ||||||
| end | ||||||
|
|
||||||
| BandedPlusSemiseparableMatrix(A::BandedPlusSemiseparableQRPerturbedFactors) = BandedPlusSemiseparableMatrix(A.B, (A.U,A.V), (A.W,A.S)) | ||||||
| BandedPlusSemiseparableQRPerturbedFactors(A::BandedPlusSemiseparableMatrix) = BandedPlusSemiseparableQRPerturbedFactors(copy(A.lowerfill.args[1]), copy(A.lowerfill.args[2]'), copy(A.upperfill.args[1]), copy(A.upperfill.args[2]'), copy(A.bands)) | ||||||
|
|
||||||
| size(A::BandedPlusSemiseparableQRPerturbedFactors) = (A.n,A.n) | ||||||
|
|
||||||
| function BandedPlusSemiseparableQRPerturbedFactors(U,V,W,S,B) | ||||||
|
||||||
| function BandedPlusSemiseparableQRPerturbedFactors(U,V,W,S,B) | |
| function BandedPlusSemiseparableQRPerturbedFactors(B, (U,V), (W,S)) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't need any of these once we infer it from B
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all allocating. Why do we need this?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is allocating. You should use views.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is allocating. You should use views.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in all the code below.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all allocating. Why do we need them?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the [:,:]???
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the [:,:]?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| r = size(U,2) | |
| (n,r) = size(U) |
Uh oh!
There was an error while loading. Please reload this page.