Perhaps there should be a @CuArray
macro if there is not one already. StaticArrays.jl has a @SArray
macro.
julia> @SArray [x for x in 1:5]
5-element SVector{5, Int64} with indices SOneTo(5):
1
2
3
4
5
Perhaps there should be a @CuArray
macro if there is not one already. StaticArrays.jl has a @SArray
macro.
julia> @SArray [x for x in 1:5]
5-element SVector{5, Int64} with indices SOneTo(5):
1
2
3
4
5
Funny that SA
doesn’t work with comprehensions.
julia> SA[1, 2, 3]
3-element SVector{3, Int64} with indices SOneTo(3):
1
2
3
julia> SA[x for x=1:3]
ERROR: MethodError: Cannot `convert` an object of type
Int64 to an object of type
SA
So for comprehensions, you have to use the macro? Sidenote, the space between the macrocall and the brackets is optional:
julia> SArray[@SArray[1,2,3] for _=1:4]
4-element Vector{SArray}:
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
julia> @SArray[@SArray[1,2,3] for _=1:4]
4-element SVector{4, SVector{3, Int64}} with indices SOneTo(4):
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
I think custom array types can define constructors that accept generators, e.g.
CuArray(Int, (i*j for i=1:2, j=1:2))
Should that be part of AbstractArray
interface?
CuArray{Int}(i*j for i=1:2, j=1:2)
Undefs.jl is now registered: