-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #401 from avik-pal/ap/banded_qr
Banded QR for non square matrices
- Loading branch information
Showing
5 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using BandedMatrices, LinearAlgebra, LinearSolve, Test | ||
|
||
# Square Case | ||
n = 8 | ||
A = BandedMatrix(Matrix(I, n, n), (2, 2)) | ||
b = ones(n) | ||
A1 = A / 1; | ||
b1 = rand(n); | ||
x1 = zero(b); | ||
A2 = A / 2; | ||
b2 = rand(n); | ||
x2 = zero(b); | ||
|
||
sol1 = solve(LinearProblem(A1, b1; u0 = x1)) | ||
@test sol1.u ≈ A1 \ b1 | ||
sol2 = solve(LinearProblem(A2, b2; u0 = x2)) | ||
@test sol2.u ≈ A2 \ b2 | ||
|
||
# Square Symmetric | ||
A1s = Symmetric(A1) | ||
A2s = Symmetric(A2) | ||
|
||
sol1s = solve(LinearProblem(A1s, b1; u0 = x1)) | ||
@test sol1s.u ≈ A1s \ b1 | ||
sol2s = solve(LinearProblem(A2s, b2; u0 = x2)) | ||
@test sol2s.u ≈ A2s \ b2 | ||
|
||
# Underdetermined | ||
A = BandedMatrix(rand(8, 10), (2, 2)) | ||
b = rand(8) | ||
|
||
@test_throws ErrorException solve(LinearProblem(A, b)).u | ||
|
||
# Overdetermined | ||
A = BandedMatrix(ones(10, 8), (2, 0)) | ||
b = rand(10) | ||
|
||
@test_nowarn solve(LinearProblem(A, b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters