-
Couldn't load subscription status.
- Fork 122
Closed
Description
i need to send a unitful array into LinearAlgebra.BLAS.symv! as the last argument (i.e. the one assigned to). so i tried ustrip and that works if i use it on the entire array. but the tricky bit is that i just want to input a portion of it, and to be fast and efficient with memory, would like to use a view. i'm finding that a ustrip of a view cannot be assigned to. what follows is a minimal example without symv. is there a way to make this work without allocation? thx.
julia> v = zeros(3) * 1u"kg"
3-element Vector{Quantity{Float64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}}}:
0.0 kg
0.0 kg
0.0 kg
julia> vv = @view v[1:2]
2-element view(::Vector{Quantity{Float64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}}}, 1:2) with eltype Quantity{Float64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}}:
0.0 kg
0.0 kg
julia> ustrip(vv)[1] = 1 # seems to work, but...
1
julia> vv # nope, it actually doesn't
2-element view(::Vector{Quantity{Float64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}}}, 1:2) with eltype Quantity{Float64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}}:
0.0 kg
0.0 kg
julia> v # not updated here either
3-element Vector{Quantity{Float64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}}}:
0.0 kg
0.0 kg
0.0 kg
julia> ustrip(v)[1] = 1 # but without the view....
1
julia> v # it works just fine
3-element Vector{Quantity{Float64, 𝐌, Unitful.FreeUnits{(kg,), 𝐌, nothing}}}:
1.0 kg
0.0 kg
0.0 kg
Metadata
Metadata
Assignees
Labels
No labels