Skip to content

Commit 8bad637

Browse files
committed
Merge branch 'master' into install
Conflicts: deps/Makefile
2 parents f917c96 + cd3359c commit 8bad637

17 files changed

+256
-142
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ First, acquire the source code by cloning the git repository:
4444
Next, enter the `julia/` directory and run `make` to build the `julia` executable. To perform a parallel build, use `make -j N` and supply the maximum number of concurrent processes.
4545
When compiled the first time, it will automatically download and build its [external dependencies](#Required-Build-Tools-External-Libraries).
4646
This takes a while, but only has to be done once.
47-
Building julia requires 1.5GiB of diskspace and 512MiB of memory.
47+
Building julia requires 1.5GiB of diskspace and approximately 700MiB of virtual memory.
4848

4949
**Note:** the build process will not work if any of the build directory's parent directories have spaces in their names (this is due to a limitation in GNU make).
5050

base/distributions.jl

+58-13
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,27 @@ _jl_libRmath = dlopen("libRmath")
1414
## var -> variance
1515
## std -> standard deviation
1616
## rand -> random sampler
17-
ccdf(d::Distribution, q::Real) = 1 - cdf(d,q)
18-
logpdf(d::ContinuousDistribution, x::Real) = log(pdf(d,x))
19-
logpmf(d::DiscreteDistribution, x::Real) = log(pmf(d,x))
20-
logcdf(d::Distribution, q::Real) = log(cdf(d,q))
21-
logccdf(d::Distribution, q::Real) = log(ccdf(d,q))
22-
cquantile(d::Distribution, p::Real) = quantile(d, 1-p)
23-
invlogcdf(d::Distribution, lp::Real) = quantile(d, exp(lp))
24-
invlogccdf(d::Distribution, lp::Real) = quantile(d, exp(-lp))
25-
std(d::Distribution) = sqrt(var(d))
26-
rand(d::Distribution, n::Int) = [rand(d) for i=1:n]
27-
## Should we add?
28-
## rand(d::DiscreteDistribution, n::Int) = [int(rand(d)) for i=1:n]
17+
ccdf(d::Distribution, q::Real) = 1 - cdf(d,q)
18+
logpdf(d::ContinuousDistribution, x::Real) = log(pdf(d,x))
19+
logpmf(d::DiscreteDistribution, x::Real) = log(pmf(d,x))
20+
logcdf(d::Distribution, q::Real) = log(cdf(d,q))
21+
logccdf(d::Distribution, q::Real) = log(ccdf(d,q))
22+
cquantile(d::Distribution, p::Real) = quantile(d, 1-p)
23+
invlogcdf(d::Distribution, lp::Real) = quantile(d, exp(lp))
24+
invlogccdf(d::Distribution, lp::Real) = quantile(d, exp(-lp))
25+
std(d::Distribution) = sqrt(var(d))
26+
function rand!(d::ContinuousDistribution, A::Array{Float64})
27+
for i in 1:numel(A) A[i] = rand(d) end
28+
A
29+
end
30+
rand(d::ContinuousDistribution, dims::Dims) = rand!(d, Array(Float64,dims))
31+
rand(d::ContinuousDistribution, dims::Int...) = rand(d, dims)
32+
function rand!(d::DiscreteDistribution, A::Array{Int})
33+
for i in 1:numel(A) A[i] = int(rand(d)) end
34+
A
35+
end
36+
rand(d::DiscreteDistribution, dims::Dims) = rand!(d, Array(Int,dims))
37+
rand(d::DiscreteDistribution, dims::Int...) = rand(d, dims)
2938

3039
## FIXME: Replace the three _jl_dist_*p macros with one by defining
3140
## the argument tuples for the ccall dynamically from pn
@@ -276,6 +285,8 @@ Beta() = Beta(1) # uniform
276285
mean(d::Beta) = d.alpha / (d.alpha + d.beta)
277286
var(d::Beta) = (ab = d.alpha + d.beta; d.alpha * d.beta /(ab * ab * (ab + 1.)))
278287
skewness(d::Beta) = 2(d.beta - d.alpha)*sqrt(d.alpha + d.beta + 1)/((d.alpha + d.beta + 2)*sqrt(d.alpha*d.beta))
288+
rand(d::Beta) = randbeta(d.alpha, d.beta)
289+
rand!(d::Beta, A::Array{Float64}) = randbeta!(alpha, beta, A)
279290

280291
type BetaPrime <: ContinuousDistribution
281292
alpha::Float64
@@ -321,6 +332,8 @@ mean(d::Chisq) = d.df
321332
var(d::Chisq) = 2d.df
322333
skewness(d::Chisq) = sqrt(8/d.df)
323334
kurtosis(d::Chisq) = 12/d.df
335+
rand(d::Chisq) = randchi2(d.df)
336+
rand!(d::Chisq, A::Array{Float64}) = randchi2!(d.df, A)
324337

325338
type Erlang <: ContinuousDistribution
326339
shape::Float64
@@ -332,12 +345,43 @@ type Exponential <: ContinuousDistribution
332345
Exponential(sc) = sc > 0 ? new(float64(sc)) : error("scale must be positive")
333346
end
334347
Exponential() = Exponential(1.)
335-
@_jl_dist_1p Exponential exp
336348
mean(d::Exponential) = d.scale
337349
median(d::Exponential) = d.scale * log(2.)
338350
var(d::Exponential) = d.scale * d.scale
339351
skewness(d::Exponential) = 2.
340352
kurtosis(d::Exponential) = 6.
353+
function cdf(d::Exponential, q::Real)
354+
q <= 0. ? 0. : -expm1(-q/d.scale)
355+
end
356+
function logcdf(d::Exponential, q::Real)
357+
q <= 0. ? -Inf : (qs = -q/d.scale; qs > log(0.5) ? log(-expm1(qs)) : log1p(-exp(qs)))
358+
end
359+
function ccdf(d::Exponential, q::Real)
360+
q <= 0. ? 1. : exp(-q/d.scale)
361+
end
362+
function logccdf(d::Exponential, q::Real)
363+
q <= 0. ? 0. : -q/d.scale
364+
end
365+
function pdf(d::Exponential, x::Real)
366+
x <= 0. ? 0. : exp(-x/d.scale) / d.scale
367+
end
368+
function logpdf(d::Exponential, x::Real)
369+
x <= 0. ? -Inf : (-x/d.scale) - log(d.scale)
370+
end
371+
function quantile(d::Exponential, p::Real)
372+
0. <= p <= 1. ? -d.scale * log1p(-p) : NaN
373+
end
374+
function invlogcdf(d::Exponential, lp::Real)
375+
lp <= 0. ? -d.scale * (lp > log(0.5) ? log(-expm1(lp)) : log1p(-exp(lp))) : NaN
376+
end
377+
function cquantile(d::Exponential, p::Real)
378+
0. <= p <= 1. ? -d.scale * log(p) : NaN
379+
end
380+
function invlogccdf(d::Exponential, lp::Real)
381+
lp <= 0. ? -d.scale * lp : NaN
382+
end
383+
rand(d::Exponential) = d.scale * randexp()
384+
rand!(d::Exponential, A::Array{Float64}) = d.scale * randexp!(A)
341385

342386
type FDist <: ContinuousDistribution
343387
ndf::Float64
@@ -360,6 +404,7 @@ mean(d::Gamma) = d.shape * d.scale
360404
var(d::Gamma) = d.shape * d.scale * d.scale
361405
skewness(d::Gamma) = 2/sqrt(d.shape)
362406
rand(d::Gamma) = d.scale * randg(d.shape)
407+
rand!(d::Gamma, A::Array{Float64}) = d.scale * randg!(d.shape, A)
363408

364409
type Geometric <: DiscreteDistribution # In the form of # of failures before the first success
365410
prob::Float64

base/int.jl

+46-40
Original file line numberDiff line numberDiff line change
@@ -141,42 +141,6 @@ itrunc(x::Integer) = x
141141
ifloor(x::Integer) = x
142142
iceil (x::Integer) = x
143143

144-
## integer promotions ##
145-
146-
promote_rule(::Type{Int16}, ::Type{Int8} ) = Int
147-
promote_rule(::Type{Int32}, ::Type{Int8} ) = Int
148-
promote_rule(::Type{Int32}, ::Type{Int16}) = Int
149-
promote_rule(::Type{Int64}, ::Type{Int8} ) = Int64
150-
promote_rule(::Type{Int64}, ::Type{Int16}) = Int64
151-
promote_rule(::Type{Int64}, ::Type{Int32}) = Int64
152-
153-
promote_rule(::Type{Uint16}, ::Type{Uint8} ) = Uint
154-
promote_rule(::Type{Uint32}, ::Type{Uint8} ) = Uint
155-
promote_rule(::Type{Uint32}, ::Type{Uint16}) = Uint
156-
promote_rule(::Type{Uint64}, ::Type{Uint8} ) = Uint64
157-
promote_rule(::Type{Uint64}, ::Type{Uint16}) = Uint64
158-
promote_rule(::Type{Uint64}, ::Type{Uint32}) = Uint64
159-
160-
promote_rule(::Type{Uint8} , ::Type{Int8} ) = Uint
161-
promote_rule(::Type{Uint8} , ::Type{Int16}) = Uint
162-
promote_rule(::Type{Uint8} , ::Type{Int32}) = Uint
163-
promote_rule(::Type{Uint8} , ::Type{Int64}) = Uint64
164-
165-
promote_rule(::Type{Uint16}, ::Type{Int8} ) = Uint
166-
promote_rule(::Type{Uint16}, ::Type{Int16}) = Uint
167-
promote_rule(::Type{Uint16}, ::Type{Int32}) = Uint
168-
promote_rule(::Type{Uint16}, ::Type{Int64}) = Uint64
169-
170-
promote_rule(::Type{Uint32}, ::Type{Int8} ) = Uint
171-
promote_rule(::Type{Uint32}, ::Type{Int16}) = Uint
172-
promote_rule(::Type{Uint32}, ::Type{Int32}) = Uint
173-
promote_rule(::Type{Uint32}, ::Type{Int64}) = Uint64
174-
175-
promote_rule(::Type{Uint64}, ::Type{Int8} ) = Uint64
176-
promote_rule(::Type{Uint64}, ::Type{Int16}) = Uint64
177-
promote_rule(::Type{Uint64}, ::Type{Int32}) = Uint64
178-
promote_rule(::Type{Uint64}, ::Type{Int64}) = Uint64
179-
180144
## integer arithmetic ##
181145

182146
-(x::Signed) = -int(x)
@@ -410,6 +374,52 @@ trailing_ones(x::Integer) = trailing_zeros(~x)
410374
<=(x::Signed , y::Unsigned) = (x <= 0) | (unsigned(x) <= y)
411375
<=(x::Unsigned, y::Signed ) = (y >= 0) & (x <= unsigned(y))
412376

377+
## system word size ##
378+
379+
const WORD_SIZE = int(Int.nbits)
380+
381+
## integer promotions ##
382+
383+
promote_rule(::Type{Int16}, ::Type{Int8} ) = Int
384+
promote_rule(::Type{Int32}, ::Type{Int8} ) = Int
385+
promote_rule(::Type{Int32}, ::Type{Int16}) = Int
386+
promote_rule(::Type{Int64}, ::Type{Int8} ) = Int64
387+
promote_rule(::Type{Int64}, ::Type{Int16}) = Int64
388+
promote_rule(::Type{Int64}, ::Type{Int32}) = Int64
389+
390+
promote_rule(::Type{Uint16}, ::Type{Uint8} ) = Uint
391+
promote_rule(::Type{Uint32}, ::Type{Uint8} ) = Uint
392+
promote_rule(::Type{Uint32}, ::Type{Uint16}) = Uint
393+
promote_rule(::Type{Uint64}, ::Type{Uint8} ) = Uint64
394+
promote_rule(::Type{Uint64}, ::Type{Uint16}) = Uint64
395+
promote_rule(::Type{Uint64}, ::Type{Uint32}) = Uint64
396+
397+
promote_rule(::Type{Uint8} , ::Type{Int8} ) = Int
398+
promote_rule(::Type{Uint8} , ::Type{Int16}) = Int
399+
promote_rule(::Type{Uint8} , ::Type{Int32}) = Int
400+
promote_rule(::Type{Uint8} , ::Type{Int64}) = Int64
401+
402+
promote_rule(::Type{Uint16}, ::Type{Int8} ) = Int
403+
promote_rule(::Type{Uint16}, ::Type{Int16}) = Int
404+
promote_rule(::Type{Uint16}, ::Type{Int32}) = Int
405+
promote_rule(::Type{Uint16}, ::Type{Int64}) = Int64
406+
407+
if WORD_SIZE == 64
408+
promote_rule(::Type{Uint32}, ::Type{Int8} ) = Int
409+
promote_rule(::Type{Uint32}, ::Type{Int16}) = Int
410+
promote_rule(::Type{Uint32}, ::Type{Int32}) = Int
411+
else
412+
promote_rule(::Type{Uint32}, ::Type{Int8} ) = Uint
413+
promote_rule(::Type{Uint32}, ::Type{Int16}) = Uint
414+
promote_rule(::Type{Uint32}, ::Type{Int32}) = Uint
415+
end
416+
promote_rule(::Type{Uint32}, ::Type{Int64}) = Int64
417+
418+
promote_rule(::Type{Uint64}, ::Type{Int8} ) = Uint64
419+
promote_rule(::Type{Uint64}, ::Type{Int16}) = Uint64
420+
promote_rule(::Type{Uint64}, ::Type{Int32}) = Uint64
421+
promote_rule(::Type{Uint64}, ::Type{Int64}) = Uint64
422+
413423
## traits ##
414424

415425
typemin(::Type{Int8 }) = int8(-128)
@@ -437,7 +447,3 @@ sizeof(::Type{Int32}) = 4
437447
sizeof(::Type{Uint32}) = 4
438448
sizeof(::Type{Int64}) = 8
439449
sizeof(::Type{Uint64}) = 8
440-
441-
## system word size ##
442-
443-
const WORD_SIZE = int(Int.nbits)

base/linalg.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# It defines functions in cases where sufficiently few assumptions about
77
# storage can be made.
88

9-
#aCb(x::AbstractVector, y::AbstractVector)
10-
#aTb{T<:Real}(x::AbstractVector{T}, y::AbstractVector{T})
9+
#Ac_mul_B(x::AbstractVector, y::AbstractVector)
10+
#At_mul_B{T<:Real}(x::AbstractVector{T}, y::AbstractVector{T})
1111

1212
#dot(x::AbstractVector, y::AbstractVector)
1313

base/linalg_blas.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function (*){T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T}
237237
_jl_gemm('N', 'N', A, B)
238238
end
239239

240-
function aTb{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T},
240+
function At_mul_B{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T},
241241
B::StridedMatrix{T})
242242
if is(A, B) && size(A,1)>=500
243243
_jl_syrk('T', A)
@@ -246,7 +246,7 @@ function aTb{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T}
246246
end
247247
end
248248

249-
function abT{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T},
249+
function A_mul_Bt{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T},
250250
B::StridedMatrix{T})
251251
if is(A, B) && size(A,2)>=500
252252
_jl_syrk('N', A)
@@ -255,13 +255,13 @@ function abT{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T}
255255
end
256256
end
257257

258-
function aTbT{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T},
258+
function At_mul_Bt{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T},
259259
B::StridedMatrix{T})
260260
_jl_gemm('T', 'T', A, B)
261261
end
262262

263-
aCb{T<:Union(Float64,Float32)}(A::StridedMatrix{T}, B::StridedMatrix{T}) = aTb(A, B)
264-
function aCb{T<:Union(Complex128,Complex64)}(A::StridedMatrix{T},
263+
Ac_mul_B{T<:Union(Float64,Float32)}(A::StridedMatrix{T}, B::StridedMatrix{T}) = At_mul_B(A, B)
264+
function Ac_mul_B{T<:Union(Complex128,Complex64)}(A::StridedMatrix{T},
265265
B::StridedMatrix{T})
266266
if is(A, B) && size(A,1)>=500
267267
_jl_herk('C', A)
@@ -270,8 +270,8 @@ function aCb{T<:Union(Complex128,Complex64)}(A::StridedMatrix{T},
270270
end
271271
end
272272

273-
abC{T<:Union(Float64,Float32)}(A::StridedMatrix{T}, B::StridedMatrix{T}) = abT(A, B)
274-
function abC{T<:Union(Complex128,Complex64)}(A::StridedMatrix{T},
273+
A_mul_Bc{T<:Union(Float64,Float32)}(A::StridedMatrix{T}, B::StridedMatrix{T}) = A_mul_Bt(A, B)
274+
function A_mul_Bc{T<:Union(Complex128,Complex64)}(A::StridedMatrix{T},
275275
B::StridedMatrix{T})
276276
if is(A, B) && size(A,2)>=500
277277
_jl_herk('N', A)
@@ -280,7 +280,7 @@ function abC{T<:Union(Complex128,Complex64)}(A::StridedMatrix{T},
280280
end
281281
end
282282

283-
function aCbC{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T},
283+
function Ac_mul_Bc{T<:Union(Float64,Float32,Complex128,Complex64)}(A::StridedMatrix{T},
284284
B::StridedMatrix{T})
285285
_jl_gemm('C', 'C', A, B)
286286
end

base/linalg_dense.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# note that many functions have specific versions for Float/Complex arguments
44
# which use BLAS instead
55

6-
aCb(x::Vector, y::Vector) = [dot(x, y)]
7-
aTb{T<:Real}(x::Vector{T}, y::Vector{T}) = [dot(x, y)]
6+
Ac_mul_B(x::Vector, y::Vector) = [dot(x, y)]
7+
At_mul_B{T<:Real}(x::Vector{T}, y::Vector{T}) = [dot(x, y)]
88

99
function dot(x::Vector, y::Vector)
1010
s = zero(eltype(x))

base/operators.jl

+19-19
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,27 @@ mod1{T<:Real}(x::T, y::T) = y-mod(y-x,y)
9191
cmp{T<:Real}(x::T, y::T) = int(sign(x-y))
9292

9393
# transposed multiply
94-
aCb (a,b) = ctranspose(a)*b
95-
abC (a,b) = a*ctranspose(b)
96-
aCbC(a,b) = ctranspose(a)*ctranspose(b)
97-
aTb (a,b) = transpose(a)*b
98-
abT (a,b) = a*transpose(b)
99-
aTbT(a,b) = transpose(a)*transpose(b)
94+
Ac_mul_B (a,b) = ctranspose(a)*b
95+
A_mul_Bc (a,b) = a*ctranspose(b)
96+
Ac_mul_Bc(a,b) = ctranspose(a)*ctranspose(b)
97+
At_mul_B (a,b) = transpose(a)*b
98+
A_mul_Bt (a,b) = a*transpose(b)
99+
At_mul_Bt(a,b) = transpose(a)*transpose(b)
100100

101101
# transposed divide
102-
aC_rdiv_b (a,b) = ctranspose(a)/b
103-
a_rdiv_bC (a,b) = a/ctranspose(b)
104-
aC_rdiv_bC(a,b) = ctranspose(a)/ctranspose(b)
105-
aT_rdiv_b (a,b) = transpose(a)/b
106-
a_rdiv_bT (a,b) = a/transpose(b)
107-
aT_rdiv_bT(a,b) = transpose(a)/transpose(b)
108-
109-
aC_ldiv_b (a,b) = ctranspose(a)\b
110-
a_ldiv_bC (a,b) = a\ctranspose(b)
111-
aC_ldiv_bC(a,b) = ctranspose(a)\ctranspose(b)
112-
aT_ldiv_b (a,b) = transpose(a)\b
113-
a_ldiv_bT (a,b) = a\transpose(b)
114-
aT_ldiv_bT(a,b) = transpose(a)\transpose(b)
102+
Ac_rdiv_B (a,b) = ctranspose(a)/b
103+
A_rdiv_Bc (a,b) = a/ctranspose(b)
104+
Ac_rdiv_Bc(a,b) = ctranspose(a)/ctranspose(b)
105+
At_rdiv_B (a,b) = transpose(a)/b
106+
A_rdiv_Bt (a,b) = a/transpose(b)
107+
At_rdiv_Bt(a,b) = transpose(a)/transpose(b)
108+
109+
Ac_ldiv_B (a,b) = ctranspose(a)\b
110+
A_ldiv_Bc (a,b) = a\ctranspose(b)
111+
Ac_ldiv_Bc(a,b) = ctranspose(a)\ctranspose(b)
112+
At_ldiv_B (a,b) = transpose(a)\b
113+
A_ldiv_Bt (a,b) = a\transpose(b)
114+
At_ldiv_Bt(a,b) = transpose(a)\transpose(b)
115115

116116

117117
oftype{T}(::Type{T},c) = convert(T,c)

0 commit comments

Comments
 (0)