struct My_Diagonal{T, AT <: AbstractVector{T}} <: AbstractArray{T,2}
buffer :: AT
end
My_Diagonal(buffer::AbstractVector) = My_Diagonal{eltype(buffer), typeof(buffer)}(buffer)
buffer = [1,2,3,4,5]
x = My_Diagonal(buffer)
报错,这种问题怎么解决呢?求指点。
ERROR: MethodError: no method matching size(::My_Diagonal{Int64, Vector{Int64}})
Closest candidates are:
size(::AbstractArray{T, N}, ::Any) where {T, N} at C:\Users\Administrator\AppData\Local\Programs\Julia-1.7.1\share\julia\base\abstractarray.jl:42
size(::Union{LinearAlgebra.Adjoint{T, var"#s859"}, LinearAlgebra.Transpose{T, var"#s859"}} where {T, var"#s859"<:(AbstractVector)}) at C:\Users\Administrator\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\LinearAlgebra\src\adjtrans.jl:172
size(::Union{LinearAlgebra.Adjoint{T, var"#s859"}, LinearAlgebra.Transpose{T, var"#s859"}} where {T, var"#s859"<:(AbstractMatrix)}) at C:\Users\Administrator\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\LinearAlgebra\src\adjtrans.jl:173
…