I think you have to do it like this
reinterpret(Float64, [strain,])
Hope that helps,
Alex.
On Tuesday, 17 March 2015 16:08:09 UTC+1, Kristoffer Carlsson wrote:
> Say I have an immutable with only one type.
>
>
>
>
> immutable Strain
> exx::Float64
> eyy::Float64
> ezz::Float64
> gyz::Float64
> gxz::Float64
> gxy::Float64
> end
> Is there anyway I can reinterpret this as a Vector{Float64} in a fast way
> without copying data. The memory of the Strain type should be exactly like
> the vector.
>
>
> The reason I want to do this is because I want to i.e. be able to multiply a
> strain and a general matrix but I also want to be able to write my own
> functions for Strain.
>
>
> Naively, I tried this:
>
>
>
>
> julia> reinterpret(Vector{Float64}, strain)
> ERROR: reinterpret: expected bits type as first argument
> in reinterpret at base.jl:65
>
>
> I saw this comment in one of the issues here
> https://github.com/JuliaLang/julia/issues/5857:
>
> "ImmutableArrays has the advantage that Array(Vector4{Int}, 10) it can be
> reinterpreted as a 4x10 matrix with reinterpret and reshape without memory
> movement (e.g. when calling a c function on the data)."
>
>
> Best regards,
> Kristoffer Carlsson