-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
lufact()
, qr()
and svd()
use similar()
but expect Array
#18772
Comments
So far, my thinking has been that the vectors of singular values and permutation would be okay to store in a |
This is one of some overly limiting type constraints that were introduced early in the development of Julia and then layered upon without relaxation. As a current, remediable, consequence, at least five packagings of number types and of number collective types now balk, unable to promulgate their designed-in willingness to |
I am trying to wrap my head around this, but it seems that a lot has changed since this issue was authored, because basically all error messages listed in the first post are now different on master. To start of with a simple confusion. Let's say the type restriction for the vector is gone. How could the base function get the type of the vector given your matrix? similar only seems to work if I query it without additional parameters. julia> m = @SMatrix [1.0 2.0; 3.0 4.0]
2×2 StaticArrays.SMatrix{2,2,Float64,4}:
1.0 2.0
3.0 4.0
julia> similar(m)
2×2 StaticArrays.MMatrix{2,2,Float64,4}:
1.4822e-323 6.92545e-310
6.92545e-310 6.92544e-310
julia> similar(m, 2)
2-element Array{Float64,1}:
6.92545e-310
6.92545e-310 The second aspect is that the methods you list expect a |
julia> type MyVec{T} <: DenseVector{T} end
julia> MyVec{Float64} <: StridedVector{Float64}
true |
Ah ok. Thanks for clearing that up. So then to even potentially allow it to work with StaticArrays the following has to be made true in the package itself if I am not mistaken julia> m = @SMatrix [1.0 2.0; 3.0 4.0]
2×2 StaticArrays.SMatrix{2,2,Float64,4}:
1.0 2.0
3.0 4.0
julia> typeof(m) <: DenseArray
false |
Right, I removed the
This is specific to There are several other steps that need to be taken to get
+1. Not sure why this kind of thing is there... |
What kind of thing? |
What I was trying to ask, but maybe sounded a bit too assertive (sorry, not intentional), is if the linked method really requires the matrix to be a I would like to take a shot at this issue if it is still considered relevant. I don't think I could solve all problems for StaticArrays though, but I came across some things I think could be worth doing while trying to figure out if this issue is something I could manage. For example this method here uses julia> copy(m)
2×2 StaticArrays.SMatrix{2,2,Float64,4}:
1.0 2.0
3.0 4.0
julia> similar(m)
2×2 StaticArrays.MMatrix{2,2,Float64,4}:
6.93696e-310 6.93696e-310
6.93696e-310 4.94066e-324 |
Exactly. And, yes, EDIT: there is the |
The base linalg methods were written without any |
Well, if we get something along the lines of #11902, then (There was also a talk at Juliacon in the context of parallelism (distributed arrays) of the power of using a locally-mutating function to evaluate the output of functions which are then "published" to be considered more-or-less immutable. This "functional" approach to parallelism supposedly avoided issues with concurrency and so-on that arise when working with multiple workers writing and reading to mutable objects at the same time.)
That's the current approach, but it's a lot of work to duplicate all the functionality in Base! |
All the factorizations reported in OP work on StaticArrays now.
|
I have tried to make StaticArrays.jl compatible with the functions in
Base.LinAlg
but I get hung up on some inconsistencies.The functions
lufact()
,qr()
andsvd()
all usesimilar()
to construct a (mutable) array for working with and returning output. In StaticArrays that would be e.g. theMMatrix
type for a matrix. However, internal types likeBase.LinAlg.SVD
have fields which must be of typeArray
.I consider this a bug since, according to the docs,
similar
should "Create an uninitialized mutable array with the given element type and size" and is not bound to returnArray
. We should widen the array field types inSVD
andLU
using an extra type parameter like inEigen
, and do something to fix the problem withqr()
(also, there may be other functions with similar problems).Alternatively we could use
Array
constructors where they are required, but I think this is not preferable. Julia is meant to be a generic language.Examples:
The text was updated successfully, but these errors were encountered: