Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia into sk/hashing
Browse files Browse the repository at this point in the history
Conflicts:
	base/operators.jl
  • Loading branch information
JeffBezanson committed May 7, 2014
2 parents 9738dd3 + ea70e4d commit 607558a
Show file tree
Hide file tree
Showing 39 changed files with 811 additions and 288 deletions.
16 changes: 16 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ New language features

* `--bounds-check=yes|no` compiler option

* Support for a limited number of infix unicode operators ([#552], [#6582]):

| Precedence class | Operators (with synonyms, if any)
| ---------------- | ---------------------------------
| == | ≥ (>=) ≤ (<=) ≡ (===) ≠ (!=) ≢ (!==) .≥ (.>=) .≤ (.<=) .!= (.≠) ∈ (`in`) ∉ (`(x,y)->!in(x, y)`) ∋ (`(x,y)->in(y, x)`) ∌ (`(x,y)->!in(y, x)`) ⊆ (`issubset`) ⊈ (`(x,y)->!issubset(x, y)`) ⊊ (`(x,y)->x⊆y && x!=y`) ⊂ ⊄ |
| + | ⊕ ⊖ ⊞ ⊟ ∪ (`union`) ∨ ⊔ |
| * | ÷ (`div`) ⋅ (`dot`) ∘ × (`cross`) ∩ (`intersect`) ∧ ⊓ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ |

* Support `` as synonym for `sqrt` ([#6582])

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

Expand Down Expand Up @@ -175,6 +185,8 @@ Library improvements

* `eigs(A, sigma)` now uses shift-and-invert for nonzero shifts `sigma` and inverse iteration for `which="SM"`. If `sigma==nothing` (the new default), computes ordinary (forward) iterations. ([#5776])

* `sprand` is faster, and whether any entry is nonzero is now determined independently with the specified probability ([#6726]).

* Dense linear algebra for special matrix types

* Interconversions between the special matrix types `Diagonal`, `Bidiagonal`,
Expand Down Expand Up @@ -253,6 +265,8 @@ Library improvements
* Extended API for ``cov`` and ``cor``, which accept keyword arguments ``vardim``,
``corrected``, and ``mean`` ([#6273])

* New functions `randsubseq` and `randsubseq!` to create a random subsequence of an array ([#6726])


Deprecated or removed
---------------------
Expand Down Expand Up @@ -376,6 +390,8 @@ Deprecated or removed
[#5380]: https://github.com/JuliaLang/julia/pull/5380
[#5585]: https://github.com/JuliaLang/julia/issues/5585
[#6273]: https://github.com/JuliaLang/julia/pull/6273
[#552]: https://github.com/JuliaLang/julia/issues/552
[#6582]: https://github.com/JuliaLang/julia/pull/6582

Julia v0.2.0 Release Notes
==========================
Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ Now you should be able to run Julia like this:

If everything works correctly, you will see a Julia banner and an interactive prompt into which you can enter expressions for evaluation. (Errors related to libraries might be caused by old, incompatible libraries sitting around in your PATH. In that case, try moving the `julia` directory earlier in the PATH).

Your first test of Julia should be to determine whether your
build is working properly. From the UNIX/Windows command prompt inside
the julia source directory, type `make testall`. You should see output
that lists a series of tests being run; if they complete without
error, you should be in good shape to start using Julia.

You can read about [getting started](http://julialang.org/manual/getting-started) in the manual.

If you are building a Julia package for distribution on Linux, OS X,
Expand Down Expand Up @@ -298,16 +304,6 @@ The following distributions include julia, but the versions may be out of date d
<a name="Editor-Terminal-Setup"/>
## Editor and Terminal Setup

Currently, Julia editing mode support is available for Emacs, Vim, Textmate, Sublime Text, Notepad++, and Kate, in `contrib/`

Adjusting your terminal bindings is optional; everything will work fine without these key bindings.
For the best interactive session experience, however, make sure that your terminal emulator (`Terminal`, `iTerm`, `xterm`, etc.) sends the `^H` sequence for `Backspace` (delete key) and that the `Shift-Enter` key combination sends a `\n` newline character to distinguish it from just pressing `Enter`, which sends a `\r` carriage return character.
These bindings allow custom readline handlers to trap and correctly deal with these key sequences; other programs will continue to behave normally with these bindings.
The first binding makes backspacing through text at the prompt behave more intuitively.
The second binding allows `Shift-Enter` to insert a newline without evaluating the current expression, even when the current expression is complete.
(Pressing an unmodified `Enter` inserts a newline if the current expression is incomplete, evaluates the expression if it is complete, or shows an error if the syntax is irrecoverably invalid.)

On Linux systems, the `Shift-Enter` binding can be set by placing the following line in the file `.xmodmaprc` in your home directory:

keysym Return = Return Linefeed
Currently, Julia editing mode support is available for Emacs, Vim, Textmate, Sublime Text, Notepad++, and Kate, in `contrib/`.

In the terminal, Julia makes great use of both control-key and meta-key bindings. To make the meta-key bindings more accessible, many terminal emulator programs (e.g., `Terminal`, `iTerm`, `xterm`, etc) allow you to use the alt or option key as meta. See the section in the manual on [interacting with Julia](http://docs.julialang.org/en/latest/manual/interacting-with-julia/) for more details.
6 changes: 4 additions & 2 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ function eval_user_input(ast::ANY, backend::REPLBackend)
iserr, lasterr = false, ()
else
ast = expand(ast)
ans = Base.Meta.quot(backend.ans)
eval(Main, :(ans = $(ans)))
ans = backend.ans
# note: value wrapped in a non-syntax value to avoid evaluating
# possibly-invalid syntax (issue #6763).
eval(Main, :(ans = $({ans})[1]))
value = eval(Main, ast)
backend.ans = value
put!(backend.response_channel, (value, nothing))
Expand Down
41 changes: 41 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1314,3 +1314,44 @@ push!(A, a, b, c...) = push!(push!(A, a, b), c...)
unshift!(A) = A
unshift!(A, a, b) = unshift!(unshift!(A, b), a)
unshift!(A, a, b, c...) = unshift!(unshift!(A, c...), a, b)

# Fill S (resized as needed) with a random subsequence of A, where
# each element of A is included in S with independent probability p.
# (Note that this is different from the problem of finding a random
# size-m subset of A where m is fixed!)
function randsubseq!(S::AbstractArray, A::AbstractArray, p::Real)
0 <= p <= 1 || throw(ArgumentError("probability $p not in [0,1]"))
n = length(A)
p == 1 && return copy!(resize!(S, n), A)
empty!(S)
p == 0 && return S
nexpected = p * length(A)
sizehint(S, iround(nexpected + 5*sqrt(nexpected)))
if p > 0.15 # empirical threshold for trivial O(n) algorithm to be better
for i = 1:n
rand() <= p && push!(S, A[i])
end
else
# Skip through A, in order, from each element i to the next element i+s
# included in S. The probability that the next included element is
# s==k (k > 0) is (1-p)^(k-1) * p, and hence the probability (CDF) that
# s is in {1,...,k} is 1-(1-p)^k = F(k). Thus, we can draw the skip s
# from this probability distribution via the discrete inverse-transform
# method: s = iceil(F^{-1}(u)) where u = rand(), which is simply
# s = iceil(log(rand()) / log1p(-p)).
L = 1 / log1p(-p)
i = 0
while true
s = log(rand()) * L # note that rand() < 1, so s > 0
s >= n - i && return S # compare before iceil to avoid overflow
push!(S, A[i += iceil(s)])
end
# [This algorithm is similar in spirit to, but much simpler than,
# the one by Vitter for a related problem in "Faster methods for
# random sampling," Comm. ACM Magazine 7, 703-718 (1984).]
end
return S
end

randsubseq{T}(A::AbstractArray{T}, p::Real) = randsubseq!(T[], A, p)

11 changes: 10 additions & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function reinterpret{T,S,N}(::Type{T}, a::Array{S}, dims::NTuple{N,Int})
end
reinterpret(t::Type,x) = reinterpret(t,[x])[1]

function reshape{T,N}(a::Array{T}, dims::NTuple{N,Int})
# reshaping to same # of dimensions
function reshape{T,N}(a::Array{T,N}, dims::NTuple{N,Int})
if prod(dims) != length(a)
throw(DimensionMismatch("new dimensions $(dims) must be consistent with array size $(length(a))"))
end
Expand All @@ -94,6 +95,14 @@ function reshape{T,N}(a::Array{T}, dims::NTuple{N,Int})
ccall(:jl_reshape_array, Array{T,N}, (Any, Any, Any), Array{T,N}, a, dims)
end

# reshaping to different # of dimensions
function reshape{T,N}(a::Array{T}, dims::NTuple{N,Int})
if prod(dims) != length(a)
throw(DimensionMismatch("new dimensions $(dims) must be consistent with array size $(length(a))"))
end
ccall(:jl_reshape_array, Array{T,N}, (Any, Any, Any), Array{T,N}, a, dims)
end

## Constructors ##

similar(a::Array, T, dims::Dims) = Array(T, dims)
Expand Down
Loading

0 comments on commit 607558a

Please sign in to comment.