Strange behavior in type system with Adjoint and DenseArray

#1

Hi,
I’m trying to tackle issue #24590 (https://github.com/JuliaLang/julia/issues/24590).
To do so I want to add a method to deal with transpose/adjoint of dense vectors (to call BLAS.dotc).
I don’t understand why the third line below returns false

julia> a = rand(ComplexF64, 1000);

julia> isa(a',Adjoint{Complex{Float64},Array{Complex{Float64},1}})
true

julia> isa(a',Adjoint{Complex{Float64},DenseArray{Complex{Float64},1}})
false

julia> isa(a',Adjoint{Complex{Float64},<:DenseArray{Complex{Float64}}})
true

julia> typeof(a')
Adjoint{Complex{Float64},Array{Complex{Float64},1}}

Thanks for any insight :slight_smile:

0 Likes

#2

There are big words for this, but this is just how parametric types work in Julia. If you think of isa as being a <: relation, this only applies to the outermost type, the parameters must be == unless you say otherwise:

julia> Array{Float64,1} <: AbstractArray{Float64,1}
true

julia> Array{Float64,1} <: AbstractArray{AbstractFloat,1}
false

julia> Array{Float64,1} <: AbstractArray{<:AbstractFloat,1}
true
0 Likes

#3

Thanks for the help ! I had read about this, but it seems I had not fully understand it :slight_smile:
And I don’t know why I did not try

Adjoint{Complex{Float64},<:DenseArray{Complex{Float64},1}}

(as I wanted to limit to 1d) which indeed works.
Thanks again !

0 Likes