forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from N5N3/patch2
second try
- Loading branch information
Showing
40 changed files
with
546 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
## copy between abstract arrays - generally more efficient | ||
## since a single index variable can be used. | ||
## copyto_unaliased! use @simd to speed up, so these definition is seperated from abstractarray.jl | ||
|
||
function copyto!(dest::AbstractArray, src::AbstractArray) | ||
isempty(src) && return dest | ||
src′ = unalias(dest, src) | ||
copyto_unaliased!(IndexStyle(dest), dest, IndexStyle(src′), src′) | ||
end | ||
|
||
function copyto!(deststyle::IndexStyle, dest::AbstractArray, srcstyle::IndexStyle, src::AbstractArray) | ||
isempty(src) && return dest | ||
src′ = unalias(dest, src) | ||
copyto_unaliased!(deststyle, dest, srcstyle, src′) | ||
end | ||
|
||
function copyto_unaliased!(deststyle::IndexStyle, dest::AbstractArray, srcstyle::IndexStyle, src::AbstractArray) | ||
isempty(src) && return dest | ||
length(dest) >= length(src) || throw(BoundsError(dest, LinearIndices(src))) | ||
if deststyle isa IndexLinear | ||
if srcstyle isa IndexLinear | ||
Δi = firstindex(dest) - firstindex(src) | ||
for i in eachindex(src) | ||
@inbounds dest[i + Δi] = src[i] | ||
end | ||
else | ||
j = firstindex(dest) - 1 | ||
@inbounds @simd for I in eachindex(src) | ||
dest[j+=1] = src[I] | ||
end | ||
end | ||
else | ||
if srcstyle isa IndexLinear | ||
i = firstindex(src) - 1 | ||
@inbounds @simd for J in eachindex(dest) | ||
dest[J] = src[i+=1] | ||
end | ||
else | ||
iterdest, itersrc = eachindex(dest), eachindex(src) | ||
if iterdest == itersrc | ||
# Shared-iterator implementation | ||
@inbounds @simd for I in itersrc | ||
dest[I] = src[I] | ||
end | ||
else | ||
for (I,J) in zip(itersrc, iterdest) | ||
@inbounds dest[J] = src[I] | ||
end | ||
end | ||
end | ||
end | ||
return dest | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.