Skip to content

Commit

Permalink
Merge pull request JuliaLang#2 from JuliaLang/master
Browse files Browse the repository at this point in the history
Rebase to 8854bad
  • Loading branch information
tkelman committed Feb 26, 2014
2 parents 812fdad + 8854bad commit 627c80b
Show file tree
Hide file tree
Showing 86 changed files with 1,839 additions and 1,001 deletions.
4 changes: 2 additions & 2 deletions DISTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Juila has lots of build dependencies where we use patched versions that has not
yet been included by the popular package managers. These dependencies will usually
be automatically downloaded when you build, but if you want to be able to build
Julia on a computer without internet access you should create a source-dist archive
with the special make targed
with the special make target

make source-dist
make source-dist

that creates a julia-version-commit.tar.gz archive with all required dependencies.

Expand Down
35 changes: 26 additions & 9 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,18 @@ New language features
* Unicode identifiers are normalized (NFC) so that different encodings
of equivalent strings are treated as the same identifier ([#5462]).

New library functions
---------------------

* `GitHub` module for interacting with the GitHub API
Library improvements
--------------------

* `Pkg.submit(pkg[,commit])` function to automatically submit
a GitHub pull request to the package author.
* Well-behaved floating-point ranges ([#2333], [#5636]).
Introduced the `FloatRange` type for floating-point ranges with a step,
which will give intuitive/correct results for classically problematic
ranges like `0.1:0.1:0.3`, `0.0:0.7:2.1` or `1.0:1/49:27.0`.

* `mod2pi` function ([#4799], [#4862]).

* New functions `minmax` and `extrema` ([#5275]).

Library improvements
--------------------

* `consume(p)` extended to `consume(p, args...)`, allowing it
to optionally pass `args...` back to the producer ([#4775]).

Expand All @@ -64,6 +61,19 @@ Library improvements

* `errno([code])` function to get or set the C library's `errno`.

* `GitHub` module for interacting with the GitHub API

* Package improvements

* Packages are now installed into `.julia/v0.3` by default (or
whatever the current Julia version is), so that different
versions of Julia can co-exist with incompatible packages.
Existing `.julia` installations are unaffected unless `Pkg.init()`
is run to re-create the package directories ([#3344], [#5737]).

* `Pkg.submit(pkg[,commit])` function to automatically submit
a GitHub pull request to the package author.

* Collections improvements

* `Array` assignment (e.g. `x[:] = y`) ignores singleton dimensions
Expand Down Expand Up @@ -178,6 +188,9 @@ Library improvements
* The `setenv` function for external processes now accepts a `dir` keyword
argument for specifying the directory to start the child process in ([#4888]).

* Constructors for collections (`Set`, `Dict`, etc.) now generally accept a
single iterable argument giving the elements of the collection ([#4996], [#4871])

Deprecated or removed
---------------------

Expand Down Expand Up @@ -265,6 +278,10 @@ Deprecated or removed
[#5748]: https://github.com/JuliaLang/julia/issues/5748
[#5511]: https://github.com/JuliaLang/julia/issues/5511
[#5819]: https://github.com/JuliaLang/julia/issues/5819
[#4871]: https://github.com/JuliaLang/julia/issues/4871
[#4996]: https://github.com/JuliaLang/julia/issues/4996
[#2333]: https://github.com/JuliaLang/julia/issues/2333
[#5636]: https://github.com/JuliaLang/julia/issues/5636

Julia v0.2.0 Release Notes
==========================
Expand Down
140 changes: 13 additions & 127 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function squeeze(A::AbstractArray, dims)
reshape(A, d)
end

function copy!(dest::AbstractArray, src)
function copy!(dest::StoredArray, src)
i = 1
for x in src
dest[i] = x
Expand All @@ -174,7 +174,7 @@ end

# copy with minimal requirements on src
# if src is not an AbstractArray, moving to the offset might be O(n)
function copy!(dest::AbstractArray, doffs::Integer, src, soffs::Integer=1)
function copy!(dest::StoredArray, doffs::Integer, src, soffs::Integer=1)
st = start(src)
for j = 1:(soffs-1)
_, st = next(src, st)
Expand All @@ -191,13 +191,13 @@ end
# NOTE: this is to avoid ambiguity with the deprecation of
# copy!(dest::AbstractArray, src, doffs::Integer)
# Remove this when that deprecation is removed.
function copy!(dest::AbstractArray, doffs::Integer, src::Integer)
function copy!(dest::StoredArray, doffs::Integer, src::Integer)
dest[doffs] = src
return dest
end

# this method must be separate from the above since src might not have a length
function copy!(dest::AbstractArray, doffs::Integer, src, soffs::Integer, n::Integer)
function copy!(dest::StoredArray, doffs::Integer, src, soffs::Integer, n::Integer)
n == 0 && return dest
st = start(src)
for j = 1:(soffs-1)
Expand All @@ -212,7 +212,7 @@ function copy!(dest::AbstractArray, doffs::Integer, src, soffs::Integer, n::Inte
end

# if src is an AbstractArray and a source offset is passed, use indexing
function copy!(dest::AbstractArray, doffs::Integer, src::AbstractArray, soffs::Integer, n::Integer=length(src))
function copy!(dest::StoredArray, doffs::Integer, src::AbstractArray, soffs::Integer, n::Integer=length(src))
for i = 0:(n-1)
dest[doffs+i] = src[soffs+i]
end
Expand Down Expand Up @@ -248,8 +248,9 @@ for (f,t) in ((:char, Char),
(:uint128,Uint128))
@eval begin
($f)(x::AbstractArray{$t}) = x
($f)(x::StoredArray{$t}) = x

function ($f)(x::AbstractArray)
function ($f)(x::StoredArray)
y = similar(x,$t)
i = 1
for e in x
Expand All @@ -265,8 +266,9 @@ for (f,t) in ((:integer, Integer),
(:unsigned, Unsigned))
@eval begin
($f){T<:$t}(x::AbstractArray{T}) = x
($f){T<:$t}(x::StoredArray{T}) = x

function ($f)(x::AbstractArray)
function ($f)(x::StoredArray)
y = similar(x,typeof(($f)(one(eltype(x)))))
i = 1
for e in x
Expand Down Expand Up @@ -312,9 +314,7 @@ end
conj{T<:Real}(x::AbstractArray{T}) = x
conj!{T<:Real}(x::AbstractArray{T}) = x

real{T<:Real}(x::AbstractVector{T}) = x
real{T<:Real}(x::AbstractArray{T}) = x
imag{T<:Real}(x::AbstractVector{T}) = zero(x)
imag{T<:Real}(x::AbstractArray{T}) = zero(x)

+{T<:Number}(x::AbstractArray{T}) = x
Expand Down Expand Up @@ -356,20 +356,6 @@ end
slicedim(A::AbstractArray, d::Integer, i) =
A[[ n==d ? i : (1:size(A,n)) for n in 1:ndims(A) ]...]

function reverse(A::AbstractVector, s=1, n=length(A))
B = similar(A)
for i = 1:s-1
B[i] = A[i]
end
for i = s:n
B[i] = A[n+s-i]
end
for i = n+1:length(A)
B[i] = A[i]
end
B
end

function flipdim(A::AbstractVector, d::Integer)
d > 0 || error("dimension to flip must be positive")
d == 1 || return copy(A)
Expand All @@ -379,7 +365,7 @@ end
function flipdim(A::AbstractArray, d::Integer)
nd = ndims(A)
sd = d > nd ? 1 : size(A, d)
if sd == 1
if sd == 1 || isempty(A)
return copy(A)
end
B = similar(A)
Expand Down Expand Up @@ -857,106 +843,6 @@ function (==)(A::AbstractArray, B::AbstractArray)
return true
end

_cumsum_type{T<:Number}(v::AbstractArray{T}) = typeof(+zero(T))
_cumsum_type(v) = typeof(v[1]+v[1])

for (f, fp, op) = ((:cumsum, :cumsum_pairwise, :+),
(:cumprod, :cumprod_pairwise, :*) )
# in-place cumsum of c = s+v(i1:n), using pairwise summation as for sum
@eval function ($fp)(v::AbstractVector, c::AbstractVector, s, i1, n)
if n < 128
@inbounds c[i1] = ($op)(s, v[i1])
for i = i1+1:i1+n-1
@inbounds c[i] = $(op)(c[i-1], v[i])
end
else
n2 = div(n,2)
($fp)(v, c, s, i1, n2)
($fp)(v, c, c[(i1+n2)-1], i1+n2, n-n2)
end
end

@eval function ($f)(v::AbstractVector)
n = length(v)
c = $(op===:+ ? (:(similar(v,_cumsum_type(v)))) :
(:(similar(v))))
if n == 0; return c; end
($fp)(v, c, $(op==:+ ? :(zero(v[1])) : :(one(v[1]))), 1, n)
return c
end

@eval function ($f)(A::AbstractArray, axis::Integer)
dimsA = size(A)
ndimsA = ndims(A)
axis_size = dimsA[axis]
axis_stride = 1
for i = 1:(axis-1)
axis_stride *= size(A,i)
end

B = $(op===:+ ? (:(similar(A,_cumsum_type(A)))) :
(:(similar(A))))

if axis_size < 1
return B
end

for i = 1:length(A)
if div(i-1, axis_stride) % axis_size == 0
B[i] = A[i]
else
B[i] = ($op)(B[i-axis_stride], A[i])
end
end

return B
end

@eval ($f)(A::AbstractArray) = ($f)(A, 1)
end

for (f, op) = ((:cummin, :min), (:cummax, :max))
@eval function ($f)(v::AbstractVector)
n = length(v)
cur_val = v[1]
res = similar(v, n)
res[1] = cur_val
for i in 2:n
cur_val = ($op)(v[i], cur_val)
res[i] = cur_val
end
return res
end

@eval function ($f)(A::AbstractArray, axis::Integer)
dimsA = size(A)
ndimsA = ndims(A)
axis_size = dimsA[axis]
axis_stride = 1
for i = 1:(axis-1)
axis_stride *= size(A,i)
end

if axis_size < 1
return A
end

B = similar(A)

for i = 1:length(A)
if div(i-1, axis_stride) % axis_size == 0
B[i] = A[i]
else
B[i] = ($op)(A[i], B[i-axis_stride])
end
end

return B
end

@eval ($f)(A::AbstractArray) = ($f)(A, 1)
end

# Uses K-B-N summation
function cumsum_kbn{T<:FloatingPoint}(v::AbstractVector{T})
n = length(v)
Expand Down Expand Up @@ -1347,7 +1233,7 @@ end


## 1 argument
function map_to!(f::Callable, first, dest::AbstractArray, A::AbstractArray)
function map_to!(f::Callable, first, dest::StoredArray, A::AbstractArray)
dest[1] = first
for i=2:length(A)
dest[i] = f(A[i])
Expand All @@ -1363,7 +1249,7 @@ function map(f::Callable, A::AbstractArray)
end

## 2 argument
function map_to!(f::Callable, first, dest::AbstractArray, A::AbstractArray, B::AbstractArray)
function map_to!(f::Callable, first, dest::StoredArray, A::AbstractArray, B::AbstractArray)
dest[1] = first
for i=2:length(A)
dest[i] = f(A[i], B[i])
Expand All @@ -1382,7 +1268,7 @@ function map(f::Callable, A::AbstractArray, B::AbstractArray)
end

## N argument
function map_to!(f::Callable, first, dest::AbstractArray, As::AbstractArray...)
function map_to!(f::Callable, first, dest::StoredArray, As::AbstractArray...)
n = length(As[1])
i = 1
ith = a->a[i]
Expand Down
Loading

0 comments on commit 627c80b

Please sign in to comment.