-
Notifications
You must be signed in to change notification settings - Fork 38
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
Check bands for zeros in lu!
and qr!
#197
Comments
Sorry, lu! does think it has a method, but that is wrong too.
|
|
Thanks,
That makes sense. lu! for dense matrices allocates the extra storage for
the pivots but I can see that as a real pain for the banded case.
Was that documented somewhere? I missed it.
This is also a very good case for using qr instead of lu.
You need to double the bandwidths if I recall correctly. Is that right?
— Tim
…On Tue, Aug 18, 2020 at 10:24 AM Sheehan Olver ***@***.***> wrote:
qr! assumes that you've pre-allocated the matrices with extra bands, as
otherwise in-place qr is not possible. Would you have a better design in
mind? We could check that the extra bands are zero.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOEX62UNJNCM2NE4I44GXTSBKFIPANCNFSM4QDN27QQ>
.
--
C. T. Kelley
Department of Mathematics, Box 8205
SAS Hall
2311 Stinson Drive
North Carolina State University
Raleigh, NC 27695-8205
(919) 515-7163, (919) 513-7336 (FAX)
[email protected]
https://ctk.math.ncsu.edu
|
If |
So lu! needs 2l and 2u?
…On Tue, Aug 18, 2020 at 10:50 AM Sheehan Olver ***@***.***> wrote:
If A has bandwidths (l,u) then qr(A).factors has bandwidth (l,u+l)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOEX67QBCSS2VYTXZFTOXLSBKIM5ANCNFSM4QDN27QQ>
.
--
C. T. Kelley
Department of Mathematics, Box 8205
SAS Hall
2311 Stinson Drive
North Carolina State University
Raleigh, NC 27695-8205
(919) 515-7163, (919) 513-7336 (FAX)
[email protected]
https://ctk.math.ncsu.edu
|
I didn't develop the |
No problem. The LAPACK manual is less than a meeter away from me.
…On Tue, Aug 18, 2020 at 10:58 AM Sheehan Olver ***@***.***> wrote:
I didn't develop the lu! code so I'm not sure I can answer. The LAPACK
documentation should provide details:
http://www.netlib.org/lapack/explore-html/d2/d2d/group__double_g_bcomputational_gad1efab86e6d869915e059286ecf1bcb1.html
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOEX6462A2MH5VFYFAT2JTSBKJI3ANCNFSM4QDN27QQ>
.
--
C. T. Kelley
Department of Mathematics, Box 8205
SAS Hall
2311 Stinson Drive
North Carolina State University
Raleigh, NC 27695-8205
(919) 515-7163, (919) 513-7336 (FAX)
[email protected]
https://ctk.math.ncsu.edu
|
You need to embed your matrix into one with bandwidths ll, and lu+2 with zeros on the unused bands. Then it works fine. So does lu! You should look at the LAPACK manual, as @dlfivefifty suggests. |
Take this example, please.
|
lu!
and qr!
A simple for loop checking that the extra bands are zero, and throwing an error if not, should fix this. The cost is negligible to the actual |
There's an argument here for not naming the current code New in 1.5 is lu!(F::UmfpackLU, A::SparseMatrixCSC) uses the UMFPACK library that is part of SuiteSparse.
As this library only supports sparse matrices with Float64 or ComplexF64 elements,
lu! converts A into a copy that is of type SparseMatrixCSC{Float64} or SparseMatrixCSC{ComplexF64} as appropriate. Actually calling this according to the example only changes One option would be to use |
No, please no. qr! does exactly what it does in LAPACK and LINPACK. You have to pad the matrix with a couple zero bands, but then it works correctly and is the same as the calls in C or Fortran. lu! does the same thing on BandedMatrices. The general sparse case is very different. I am not clear on what the right thing to do is there. |
Wait, there's a banded |
… On Tue, Aug 25, 2020 at 3:05 AM Sheehan Olver ***@***.***> wrote:
Wait, there's a banded qr! in LAPACK??
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOEX6ZASTZLJYBXLQZ3QT3SCNPDHANCNFSM4QDN27QQ>
.
--
C. T. Kelley
Department of Mathematics, Box 8205
SAS Hall
2311 Stinson Drive
North Carolina State University
Raleigh, NC 27695-8205
(919) 515-7163, (919) 513-7336 (FAX)
[email protected]
https://ctk.math.ncsu.edu
|
Must have been using old docs 🤦♂️ We aren't actually calling that function, instead using a Julia native banded QR. This should be changed |
Is there also a banded * banded function I've missed in BLAS or LAPACK??? |
I don't think so. Not in BLAS3 anyhow. There's support for Banded * vector
in BLAS2.
…On Tue, Aug 25, 2020 at 5:45 AM Sheehan Olver ***@***.***> wrote:
Is there also a banded * banded function I've missed in BLAS or LAPACK???
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOEX6Y773AZBCJLIAXXRMLSCOB5HANCNFSM4QDN27QQ>
.
--
C. T. Kelley
Department of Mathematics, Box 8205
SAS Hall
2311 Stinson Drive
North Carolina State University
Raleigh, NC 27695-8205
(919) 515-7163, (919) 513-7336 (FAX)
[email protected]
https://ctk.math.ncsu.edu
|
Yes we use Though it's probably not much faster than the Julia native code (BLAS2 rarely seems to make a difference). Unfortunately we are using a hacked together " |
I don't know if you have seen this thread on discourse or not
https://discourse.julialang.org/t/sparse-solve-vs-bandedmatrix-time-and-allocation-surprise/45119
@ChrisRackauckas suggests that I open an issue to see if spdiagm can
produce a banded matrix if the bandwidths are small enough for that to
make sense. I have been composing that message and waiting for the thread
to play out. Would it make sense for BandedMatrices to get merged into base
as well?
— Tim
…On Tue, Aug 25, 2020 at 9:28 AM Sheehan Olver ***@***.***> wrote:
Yes we use BLAS.gbmv!
https://github.com/JuliaMatrices/BandedMatrices.jl/blob/12fbc03d3798f4b1ed68f55e92c6151aa1e30b65/src/generic/matmul.jl#L23
Though it's probably not much faster than the Julia native code (BLAS2
rarely seems to make a difference).
Unfortunately we are using a hacked together "gbmm!", which I think I
made in Julia v0.3 and never properly updated. At some point I was keen on
the idea that the sub-components of a banded matrix with u = l have BLAS
storage: that is, it can be thought of as a block-tridiagonal matrix whose
diagonal blocks are dense column major arrays and whose off-diagonal blocks
are triangular. Then I realised there does not appear to be a BLAS3
triangular * triangular routine either. (Probably not too hard to make a
Julia one that chops up a triangular matrix in a hierarchical way... that
is, as a block-triangular matrix with triangular diagonal blocks and dense
off-diagonal block...)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOEX64KPN6S7VBN7SAUVOTSCO4AFANCNFSM4QDN27QQ>
.
--
C. T. Kelley
Department of Mathematics, Box 8205
SAS Hall
2311 Stinson Drive
North Carolina State University
Raleigh, NC 27695-8205
(919) 515-7163, (919) 513-7336 (FAX)
[email protected]
https://ctk.math.ncsu.edu
|
I think that would go into Julialang/julia since IIRC you're looking for |
I think adding it completely to StdLib is a nonstandard for the time being: I need ArrayLayouts.jl to support views of banded matrices behaving like banded matrices, so one would need to first talk about incorporating (a replacement for) ArrayLayouts.jl into StdLib to do trait-based dispatch. (This almost made it into Julia v1.0 but we couldn't quite get agreement on what traits should be supported.) That said, what can easily be done is incorporate the notion of bandedness into StdLib. For example, ArrayLayouts.jl has no notion of a banded matrix but already supports optimal complexity algorithms via iterating only over Then BandedMatrices.jl could play the corresponding roll as the "canonical banded matrix package", like OffsetArrays.jl does for non-1-based arrays. |
Looking at the associated working note (http://www.netlib.org/lapack/lawnspdf/lawn203.pdf), the new-to-that-version computational routines, e.g. xLARFB.f, scan Householder reflectors to be applied to a dense n x n matrix for trailing zeros, saving some cost for low profile matrices. Scanning for zeros costs O(n^2). This package, however, uses the banded storage scheme which is not the same as storing an n x n banded matrix densely. As annoying as it may seem, you can't perform an in-place QR on a banded matrix without the extra data assumption. Calling that code
Checking for zeros in pre-allocated upper bands is not the only plausible thing to do: if the data were allocated as junk ( |
It's impossible to tell if it's junk, and normwise small is probably too clever; we can just add a flag to ignore bands that users can use for that. |
Oops, yeah, in isbits type floating-point it's impossible to tell if |
I don't think it's a burden on the user (aka me) to be aware of the need
for the extra zero bands and populate them correctly. An automatic check,
if it does not cost much, would be fine.
…On Tue, Aug 25, 2020 at 10:20 AM Mikael Slevinsky ***@***.***> wrote:
Oops, yeah, in isbits type floating-point it's impossible to tell if undef
is junk
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOEX67VHE4GHPGHXDXSN23SCPCEDANCNFSM4QDN27QQ>
.
--
C. T. Kelley
Department of Mathematics, Box 8205
SAS Hall
2311 Stinson Drive
North Carolina State University
Raleigh, NC 27695-8205
(919) 515-7163, (919) 513-7336 (FAX)
[email protected]
https://ctk.math.ncsu.edu
|
I'm a bit confused now. Can/should something be added to base that supports
banded matrices and solvers like lu, qr, lu!, and qr!?
— Tim
…On Tue, Aug 25, 2020 at 10:06 AM Sheehan Olver ***@***.***> wrote:
I think adding it completely to StdLib is a nonstandard for the time
being: I need ArrayLayouts.jl to support views of banded matrices behaving
like banded matrices, so one would need to first talk about incorporating
(a replacement for) ArrayLayouts.jl into StdLib to do trait-based dispatch.
(This almost made it into Julia v1.0 but we couldn't quite get agreement on
what traits should be supported.)
That said, what can easily be done is incorporate the notion of bandedness
into StdLib. For example, ArrayLayouts.jl has no notion of a banded matrix
but already supports optimal complexity algorithms via iterating only over
colsupport and rowsupport (the non-zero entries of the corresponding
column and row...could be renamed colrange and rowrange since in practice
the "support" is always a range). E.g., the following triangular lmul!
works as-is for triangular banded matrices via (i + 1:m) ∩
rowsupport(Adata,i):
https://github.com/JuliaMatrices/ArrayLayouts.jl/blob/27736556b9dbdc1a8725b1fab1dc208c96b873a2/src/triangular.jl#L25
Then BandedMatrices.jl could play the corresponding roll as the "canonical
banded matrix package", like OffsetArrays.jl does for non-1-based arrays.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACOEX67U6RLXWFNIAQK5FV3SCPAPBANCNFSM4QDN27QQ>
.
--
C. T. Kelley
Department of Mathematics, Box 8205
SAS Hall
2311 Stinson Drive
North Carolina State University
Raleigh, NC 27695-8205
(919) 515-7163, (919) 513-7336 (FAX)
[email protected]
https://ctk.math.ncsu.edu
|
First a point of terminology: note it should be "added to StdLib": Base doesn't know anything about linear algebra, but the StdLib package LinearAlgebra.jl does. Support could be added without adding all of BandedMatrices.jl: there's a notion of "sanctioned type piracy" so Base could in theory detect a matrix is banded and call a |
Hello again, it seems that qr! thinks it has a method for BandedMatrices,
but the results are incorrect. lu! knows it has no such method and issues
the usual complaint. Example below.
I am trying to figure out how to do a PR for the Float32 issue. This may
take me awhile because I'm still not sure where the problem lives in
your code and have never issued a PR for a project that I'm not seriously
involved with.
-- Tim
The text was updated successfully, but these errors were encountered: