-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Consistency of return type of special matrices #18
Comments
My feeling is that if the user is employing special matrix types for performance/memory reasons, then the user is entitled to receive those matrices back from operations that preserve special-matrix properties. |
I think I agree, but I forgot to mention that the original reason not to return special matrix types was that it would require many new methods to be written, i.e. ensure that all kinds of matrix multiplication is defined for the new types. |
I haven't followed that discussion too closely, but is it possible to insert a superclass |
@vtjnash I think that is the point in JuliaLang/julia#2345. It has been discussed several times. I don't know if there are technical reasons why |
We should certainly try and resolve JuliaLang/julia#2345. Perhaps start a branch? |
It would be great to resolve JuliaLang/julia#2345, but special matrices like A |
Regarding the point in this issue, I agree with @stevengj 's suggestion to return the same special matrix type when possible. We can implement more operations on special matrices as we go along, and until then, users will have to manually convert to Also, currently, we do try to implement as many operations on |
@stevengj I misunderstood the purpose of JuliaLang/julia#2345. Still, my feeling is that it would be useful to have a |
How does a It seems like only point of having a new abstract array class is if the new abstraction exposes more information about the storage or capabilities of the matrix, e.g. that it is laid out in memory with regular strides, or contiguously with transposed storage, or... I'm not sure what is being exposed in this case. |
|
What storage capabilities does a |
To me a DenseAbstractArray would be one that can use algorithms that touch every element, while for sparse arrays you'd try to touch only nonzeros. |
What if we just have |
I agree we don't necessarily need the type, just saying what I thought it meant. |
@stevengj Line 65 of matmul.jl (I gave the reference first time). My idea was that |
@andreasnoackjensen, in order to pass an array directly to most LAPACK or BLAS routines, it needs to be stored in memory in certain ways; basically, it needs to be a It cannot be a triangular or tridiagonal array in compressed format (except for a few specialized LAPACK routines which only accept that compressed format). It certainly can't be some abstracted data structure that hides its memory layout. For such data structures, your only choice is to make a copy before passing to LAPACK or BLAS, but in that case you might as well support any arbitrary |
@stevengj The main reason for the special matrix types in Julia is to exploit the special LAPACK routines. By the way,
To ask a specific question, would it make sense to have a method *(A::AbstractMatrix,B::AbstractMatrix) = *(convert(Matrix,A),convert(Matrix,B)) ? Finally, all the conversions to |
@andreasnoackjensen, I didn't realize A As discussed in JuliaLang/julia#987, we should really have a hierarchy of abstract types with known memory layout: (Regarding your other question, I would prefer that |
I like the idea to have |
The recent discussion in JuliaLang/julia#987 suggests that we are leaning in favor of preserving the special properties of the output matrix where possible. |
Effectively, we have now decided to preserve structure whenever possible. There might still be some missing cases, but they should be handled in individual issues as they show up. |
When I wrote functionality for the
Triangular
andHermitian
types, the general opinion seemed to be that the types should only be used for dispatch and that all methods should return aMatrix
.I have just noticed that methods for
Diagonal
returnDiagonal
e.g.whereas
Which solution should we go for?
The text was updated successfully, but these errors were encountered: