- original.
- See also [`copy!`](@ref Base.copy!), [`copyto!`](@ref), [`deepcopy`](@ref).
- """
- copy
- @eval function copy(a::Array{T}) where {T}
- ref = a.ref
- newmem = ccall(:jl_genericmemory_copy_slice, Ref{Memory{T}}, (Any, Ptr{Cvoid}, Int), ref.mem, ref.ptr_or_offset, length(a))
- return $(Expr(:new, :(typeof(a)), :(Core.memoryref(newmem)), :(a.size)))
- end
- ## Constructors ##
- similar(a::Array{T,1}) where {T} = Vector{T}(undef, size(a,1))
- similar(a::Array{T,2}) where {T} = Matrix{T}(undef, size(a,1), size(a,2))
- similar(a::Array{T,1}, S::Type) where {T} = Vector{S}(undef, size(a,1))
- similar(a::Array{T,2}, S::Type) where {T} = Matrix{S}(undef, size(a,1), size(a,2))
- similar(a::Array{T}, m::Int) where {T} = Vector{T}(undef, m)
- similar(a::Array, T::Type, dims::Dims{N}) where {N} = Array{T,N}(undef, dims)
- similar(a::Array{T}, dims::Dims{N}) where {T,N} = Array{T,N}(undef, dims)