-
Notifications
You must be signed in to change notification settings - Fork 184
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
Tridagonal matrices and associated spmv kernel #957
base: master
Are you sure you want to change the base?
Conversation
I got one build to work, that's encouraging. Everything works fine locally though when using On a different note: the sparse matrix-vector product currently uses |
Sure, it might be interesting to create a wrapper interface on top of the subroutine to have a matmul equivalent. Now, I personally avoid using matmul and for that matter any function procedure signature implying assignment to an array lhs, as it is difficult to control whether the compiler recycles the memory of the lhs or creates a temporary array. subroutines allow better control in that regard. At the same time, having these interfaces might also be a good study case for such performance problems. |
All tests are now passing. It was simply the
So do I. I think adding a PS: Now that the tests are passing, I'll start working on the docs and examples tomorrow. |
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.
Sorry about this. I did not realized I had fprettify
set on on automatic formatting when saving.
I've started a discussion on this at #951, great work @loiseaujc! |
Moving all the implementations to a dedicated module (and submodule) will prevent cluter of the `sparse` module as well as make things clearer from an implementation and documentation point of view.
Oh, I found the initial design as an extension of the sparse module was the ideal proposal. It would enable to improve the global structure by having different use-cases emerging from it. |
I had the same idea initially, but things started to get messy when working on the documentation. Moreover, if Circulant, Toeplitz and Hankel matrices eventually make their ways into Another possibility is to keep |
I'm curious about this. Would you mind letting me know why did you find it complicated? I would definitely like to help and make it easier to contribute/build on top of it. If it can be improved, lets try to do it :)
Sounds about right! |
Well, it is not so much the process of documenting than having a somewhat consistent documentation when you start planning for the next sets of PR. Take the
Modulo some variations in the algorithms, pretty much the same statements apply directly to Given the similarities between all these types, having them inside the same |
I see! Makes sense!! I would envision that for higher level APIs they should be unified with proper interfaces. Say, if one wants to call a generic matmul or a solve procedure, versions should be available for any matrix type defined in stdlib (dense, sparse, special). Instead of making the matrix structure per-se the center of focus, making it a helper concept for efficient storage and procedure implementation. If some of the APIs can be brought close in naming convention and usage regardless of the internal implementation details that would already be a good step forward. |
I guess we're on the same page then! That is pretty much what I tried in my personal
Indeed. Sure enough, using the correct matrix structure for computational efficiency can be utterly important, but at the end of the day I want simply to solve
That might be easy to do simply by extending already existing interfaces. In an ideal world however, I'd like these different definitions of matrices to be interoperable with packages other than
to just work even though, on my side, I've never actually imported your package anywhere in my list? I think, to some extent, this is what is driving a large part of the Julia packages interoperability. I don't think it'll be too hard (technically) to partially emulate this behaviour with well-designed fundamental derived-types (possibly abstract or not). This discussion however is beyond the scope of this PR. Let's continue it on the discourse. |
I think it is pretty much ready for review. There are just a couple of things I'm not sure how to do properly with
|
Regarding lagtm: if you check here
|
Alright. I don't know why I though extended and quadruple where not supported by default. Maybe I read in an old topic about |
This PR is the first of a series to port what I had been doing in
SpecialMatrices
tostdlib
. This first one provides the base type and spmv kernel forTridiagonal
matrices. At the moment, it is included instdlib_sparse_kinds
andstdlib_sparse_spmv
files out of simplicity. It could also be (yet) another module, I don't have a strong opinion about that.Proposed interface
A = Tridiagonal(dl, dv, du)
wheredl
,dv
anddu
are rank-1 arrays describing the tridiagonal elements.call spmv(A, x, y [, alpha] [, beta] [, op])
for the matrix-vector product.dense(A)
to convert aTridiagonal
matrix to its standard rank-2 array representation.transpose(A)
to compute the transpose of aTridiagonal
matrix.hermitian(A)
to compute the hermitian of aTridiagonal
matrix.+
and-
are being overloaded for addition and subtraction to twoTridiagonal
matrices.*
is being overloaded for scalar-matrix multiplication.Key facts
spmv
kernel useslagtm
LAPACK backend under the hood.stdlib
can be created.spmv
kernel has the same limitations asstdlib_linalg_lapack
.Progress
cc @jvdp1, @jalvesz, @perazz