Closed andreasvarga closed 7 months ago
If you would like to avoid type piracies, your package needs to own function or argument type.
The definition Base.complex(A::UniformScaling) = complex(A.λ)*I
looks correct, so that should be defined in LinearAlgebra.jl.
The following articles would be useful to learn type piracies.
Thanks for the explanation @hyrodium!
Thanks for the explanation. I fixed the type piracy issue by defining my own function tocomplex
as follows:
tocomplex(A::LinearAlgebra.UniformScaling) = complex(A.λ)*I
tocomplex(A::AbstractArray) = complex(A)
tocomplex(A::Number) = complex(A)
I am trying to define in my package MatrixEquations a simple conversion to complex type of an arbirary
UniformScaling
. For my first trial withBase.complex(A::UniformScaling) = complex(A.λ)*I
Aqua complains of possible type piracy. The same occurs for two other definitions
I wonder what is the cause of this, because all three definitions work well for my purposes.