Skip to content

Commit d0f6171

Browse files
author
Sheehan Olver
committed
Drop 0.5 support, tests pass in 0.6 with no deprecation
1 parent ce740ec commit d0f6171

12 files changed

+62
-65
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ addons:
77
os:
88
- linux
99
julia:
10-
- 0.5
1110
- 0.6
1211
- nightly
1312
matrix:

REQUIRE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
julia 0.5
1+
julia 0.6
22
Combinatorics 0.2
33
Distributions 0.8.10
4-
OrdinaryDiffEq
4+
OrdinaryDiffEq 2.19.1
55
GSL 0.3.1
6-
Compat 0.9.2

src/FormalPowerSeries.jl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export FormalPowerSeries, fps, tovector, trim, isunit, isnonunit,
1717
#############################
1818

1919
# Definition [H, p.9] - we limit this to finitely many coefficients
20-
type FormalPowerSeries{Coefficients}
20+
mutable struct FormalPowerSeries{Coefficients}
2121
c :: Dict{BigInt, Coefficients}
22-
FormalPowerSeries{Coefficients}(c::Dict{BigInt, Coefficients}) = new(c)
23-
function FormalPowerSeries{Coefficients}(v::Vector{Coefficients})
22+
FormalPowerSeries{Coefficients}(c::Dict{BigInt, Coefficients}) where Coefficients = new(c)
23+
function FormalPowerSeries{Coefficients}(v::Vector{Coefficients}) where Coefficients
2424
c=Dict{BigInt, Coefficients}()
2525
for i in eachindex(v)
2626
if v[i] != 0
@@ -30,6 +30,9 @@ type FormalPowerSeries{Coefficients}
3030
FormalPowerSeries{Coefficients}(c)
3131
end
3232
end
33+
34+
FormalPowerSeries(v::Vector{T}) where T = FormalPowerSeries{T}(v)
35+
3336
#Convenient abbreviation for floats
3437
fps = FormalPowerSeries{Float64}
3538

@@ -138,7 +141,8 @@ function CauchyProduct{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
138141
end
139142

140143
#Hadamard product [H, p.10] - the elementwise product
141-
.*{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T}) = HadamardProduct(P, Q)
144+
broadcast(::typeof(*), P::FormalPowerSeries{T}, Q::FormalPowerSeries{T}) where T =
145+
HadamardProduct(P, Q)
142146
function HadamardProduct{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
143147
c = Dict{BigInt, T}()
144148
for (k,v) in P.c
@@ -193,7 +197,7 @@ end
193197
#TODO implement the FFT-based algorithm of one of the following
194198
# doi:10.1109/TAC.1984.1103499
195199
# https://cs.uwaterloo.ca/~glabahn/Papers/tamir-george-1.pdf
196-
function reciprocal{T}(P::FormalPowerSeries{T}, n::Integer)
200+
function reciprocal(P::FormalPowerSeries, n::Integer)
197201
n<0 && error(sprintf("Invalid inverse truncation length %d requested", n))
198202

199203
a = tovector(P, 0:n-1) #Extract original coefficients in vector
@@ -205,11 +209,11 @@ function reciprocal{T}(P::FormalPowerSeries{T}, n::Integer)
205209
for k=2:n
206210
b[k] = -inv_a1 * sum([b[k+1-i] * a[i] for i=2:k])
207211
end
208-
FormalPowerSeries{T}(b)
212+
FormalPowerSeries(b)
209213
end
210214

211215
#Derivative of fps [H. Sec.1.4, p.18]
212-
function derivative{T}(P::FormalPowerSeries{T})
216+
function derivative(P::FormalPowerSeries{T}) where T
213217
c = Dict{BigInt, T}()
214218
for (k,v) in P.c
215219
if k != 0 && v != 0
@@ -220,7 +224,7 @@ function derivative{T}(P::FormalPowerSeries{T})
220224
end
221225

222226
#[H, Sec.1.4, p.18]
223-
function isconstant{T}(P::FormalPowerSeries{T})
227+
function isconstant(P::FormalPowerSeries)
224228
for (k,v) in P.c
225229
if k!=0 && v!=0
226230
return false
@@ -232,7 +236,7 @@ end
232236

233237

234238
# Power of fps [H, Sec.1.5, p.35]
235-
function ^{T}(P::FormalPowerSeries{T}, n :: Integer)
239+
function ^(P::FormalPowerSeries{T}, n::Integer) where T
236240
if n == 0
237241
return FormalPowerSeries{T}([one(T)])
238242
elseif n > 1
@@ -293,10 +297,10 @@ inv(P::FormalPowerSeries, n::Integer) = reversion(P, n)
293297
# [H., Sec. 1.8, p. 51] #
294298
###############################
295299

296-
type FormalLaurentSeries{Coefficients}
300+
mutable struct FormalLaurentSeries{Coefficients}
297301
c :: Dict{BigInt, Coefficients}
298-
FormalLaurentSeries{Coefficients}(c::Dict{BigInt, Coefficients}) = new(c)
299-
function FormalLaurentSeries{Coefficients}(v::Vector{Coefficients})
302+
FormalLaurentSeries{Coefficients}(c::Dict{BigInt, Coefficients}) where Coefficients = new(c)
303+
function FormalLaurentSeries{Coefficients}(v::Vector{Coefficients}) where Coefficients
300304
c = new(c)
301305
for i=1:length(v)
302306
c[i] = v[i]

src/GaussianEnsembles.jl

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ Example of usage:
3232
3333
β = 2 #β = 1, 2, 4 generates real, complex and quaternionic matrices respectively.
3434
d = Wigner{β} #same as GaussianHermite{β}
35-
35+
3636
n = 20 #Generate square matrices of this size
3737
3838
S = rand(d, n) #Generate a 20x20 symmetric Wigner matrix
3939
T = tridrand(d, n) #Generate the symmetric tridiagonal form
4040
v = eigvalrand(d, n) #Generate a sample of eigenvalues
4141
"""
42-
immutable GaussianHermite{β} <: ContinuousMatrixDistribution end
42+
struct GaussianHermite{β} <: ContinuousMatrixDistribution end
4343
GaussianHermite(β) = GaussianHermite{β}()
4444

4545
"""
4646
Synonym for GaussianHermite{β}
4747
"""
48-
typealias Wigner{β} GaussianHermite{β}
48+
const Wigner{β} = GaussianHermite{β}
4949

5050
rand{β}(d::Type{Wigner{β}}, dims...) = rand(d(), dims...)
5151

@@ -70,7 +70,7 @@ function rand(d::Wigner{4}, n::Int)
7070
return Hermitian((A + A') / normalization)
7171
end
7272

73-
rand{β}(d::Wigner{β}, n::Int) =
73+
rand{β}(d::Wigner{β}, n::Int) =
7474
throw(ValueError("Cannot sample random matrix of size $n x $n for β="))
7575

7676
function rand{β}(d::Wigner{β}, dims...)
@@ -85,7 +85,7 @@ end
8585
Generates a nxn symmetric tridiagonal Wigner matrix
8686
8787
Unlike for `rand(Wigner{β}, n)`, which is restricted to β=1,2 or 4,
88-
`trirand(Wigner{β}, n)` will generate a
88+
`trirand(Wigner{β}, n)` will generate a
8989
9090
The β=∞ case is defined in Edelman, Persson and Sutton, 2012
9191
"""
@@ -143,13 +143,13 @@ end
143143
# Laguerre ensemble #
144144
#####################
145145

146-
type GaussianLaguerre <: ContinuousMatrixDistribution
146+
mutable struct GaussianLaguerre <: ContinuousMatrixDistribution
147147
beta::Real
148148
a::Real
149149
end
150-
typealias Wishart GaussianLaguerre
150+
const Wishart = GaussianLaguerre
151+
151152

152-
153153
#Generates a NxN Hermitian Wishart matrix
154154
#TODO Check - the eigenvalue distribution looks funky
155155
#TODO The appropriate matrix size should be calculated from a and one matrix dimension
@@ -215,13 +215,13 @@ end
215215
# Jacobi ensemble #
216216
###################
217217

218-
#Generates a NxN self-dual MANOVA matrix
219-
type GaussianJacobi <: ContinuousMatrixDistribution
218+
#Generates a NxN self-dual MANOVA matrix
219+
mutable struct GaussianJacobi <: ContinuousMatrixDistribution
220220
beta::Real
221221
a::Real
222222
b::Real
223223
end
224-
typealias MANOVA GaussianJacobi
224+
const MANOVA = GaussianJacobi
225225

226226
function rand(d::GaussianJacobi, m::Integer)
227227
w1 = Wishart(m, int(2.0*d.a/d.beta), d.beta)
@@ -267,7 +267,7 @@ function sprand(d::GaussianJacobi, n::Integer, a::Real, b::Real)
267267
for i=1:n
268268
CoordI[i], CoordJ[i] = i, i
269269
Values[i] = i==1 ? c[n] : c[n+1-i] * sp[n+1-i]
270-
end
270+
end
271271
for i=1:n
272272
CoordI[n+i], CoordJ[n+i] = i, n+i
273273
Values[n+i] = i==n ? s[1] : s[n+1-i] * sp[n-i]
@@ -297,7 +297,7 @@ function sprand(d::GaussianJacobi, n::Integer, a::Real, b::Real)
297297
CoordI[7n-3+i], CoordJ[7n-3+i] = n+i,i+1
298298
Values[7n-3+i] = -s[n-i]*cp[n-i]
299299
end
300-
300+
301301
return sparse(CoordI, CoordJ, Values)
302302
end
303303

@@ -307,7 +307,7 @@ function eigvalrand(d::GaussianJacobi, n::Integer)
307307
c, s, cp, sp = SampleCSValues(n, d.a, d.b, d.beta)
308308
dv = [i==1 ? c[n] : c[n+1-i] * sp[n+1-i] for i=1:n]
309309
ev = [-s[n+1-i]*cp[n-i] for i=1:n-1]
310-
310+
311311
##TODO: understand why dv and ev are returned as Array{Any,1}
312312
M = Bidiagonal(convert(Array{Float64,1},dv), convert(Array{Float64,1},ev), false)
313313
return svdvals(M)
@@ -339,4 +339,3 @@ function eigvaljpdf{Eigenvalue<:Number}(d::GaussianJacobi, lambda::Vector{Eigenv
339339

340340
return c * VandermondeDeterminant(lambda, beta) * Prod * exp(-Energy)
341341
end
342-

src/Ginibre.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Base.rand
55
#This ensemble lives in GL(N, F), the set of all invertible N x N matrices
66
#over the field F
77
#For beta=1,2,4, F=R, C, H respectively
8-
immutable Ginibre <: ContinuousMatrixDistribution
8+
struct Ginibre <: ContinuousMatrixDistribution
99
beta::Float64
1010
N::Integer
1111
end
@@ -32,7 +32,7 @@ function jpdf{z<:Complex}(Z::AbstractMatrix{z})
3232
end
3333

3434
#Dyson Circular orthogonal, unitary and symplectic ensembles
35-
immutable CircularOrthogonal
35+
struct CircularOrthogonal
3636
N :: Int64
3737
end
3838

@@ -41,13 +41,13 @@ function rand(M::CircularOrthogonal)
4141
U * U'
4242
end
4343

44-
immutable CircularUnitary
44+
struct CircularUnitary
4545
N :: Int64
4646
end
4747

4848
rand(M::CircularUnitary) = rand(Ginibre(2, M.N))
4949

50-
immutable CircularSymplectic
50+
struct CircularSymplectic
5151
N :: Int64
5252
end
5353

src/Haar.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export permutations_in_Sn, compose, cycle_structure, data, part, #Functions work
22
partition, Haar, expectation, WeingartenUnitary
33

44

5-
typealias partition Vector{Int}
5+
const partition = Vector{Int}
66
#Functions working with partitions and permutations
77
# TODO Migrate these functions to Catalan
88

@@ -24,7 +24,7 @@ end
2424

2525
function permutations_in_Sn(n::Integer)
2626
P = permutation_calloc(n)
27-
while true
27+
while true
2828
produce(P)
2929
try permutation_next(P) catch break end
3030
end
@@ -65,7 +65,7 @@ data(P::Ptr{gsl_permutation}) = [convert(Int64, x)+1 for x in
6565
pointer_to_array(permutation_data(P), (convert(Int64, permutation_size(P)) ,))]
6666

6767

68-
type Haar <: ContinuousMatrixDistribution
68+
mutable struct Haar <: ContinuousMatrixDistribution
6969
beta::Real
7070
end
7171

@@ -88,10 +88,10 @@ function expectation(X::Expr)
8888
if X.head != :call
8989
error(string("Unexpected type of expression: ", X.head))
9090
end
91-
91+
9292
n = length(X.args) - 1
9393
if n < 1 return eval(X) end #nothing to do Haar-wise
94-
94+
9595
if X.args[1] != :*
9696
error("Unexpected expression, only products supported")
9797
end
@@ -144,7 +144,7 @@ function expectation(X::Expr)
144144
sigma_inv=permutation_inverse(sigma)
145145
#Compose the permutations
146146
perm=compose(sigma_inv, tau)
147-
147+
148148
#Compute cycle structure, i.e. lengths of each cycle in the cycle
149149
#factorization of the permutatation
150150
cyclestruct = cycle_structure(perm)
@@ -245,7 +245,7 @@ function expectation(X::Expr)
245245
ExprBlob, start_idx, end_idx = ExprChunk
246246
print(ExprChunk, " => ")
247247
if start_idx == end_idx #Have a cycle; this is a trace
248-
ex= length(ExprBlob)==1 ? :(trace($(ExprBlob[1]))) :
248+
ex= length(ExprBlob)==1 ? :(trace($(ExprBlob[1]))) :
249249
Expr(:call, :trace, Expr(:call, :*, ExprBlob...))
250250
else #Not a cycle, regular chain of multiplications
251251
ex= length(ExprBlob)==1 ? ExprBlob[1] :
@@ -288,4 +288,3 @@ function WeingartenUnitary(P::partition)
288288
end
289289
thesum
290290
end
291-

src/InvariantEnsembles.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,20 @@ end
7171

7272
## Ensembles
7373

74-
type InvariantEnsemble{D}
74+
mutable struct InvariantEnsemble{D}
7575
basis::Array{Float64,2} # the m x n array of the first n weighted OPs evaluated at m Chebyshev points
7676
domain::D # the sub domain of the real line
77-
InvariantEnsemble(b,d) = new(b,d)
77+
InvariantEnsemble{D}(b,d) where D = new(b,d)
7878
end
7979

8080
InvariantEnsemble(basis::Matrix,d::Domain) =
8181
InvariantEnsemble{typeof(d)}(basis,d)
8282

8383
InvariantEnsemble(basis::Matrix,d::Vector) =
84-
InvariantEnsemble(basis,Interval(d[1],d[2]))
84+
InvariantEnsemble(basis,Segment(d[1],d[2]))
8585

8686
InvariantEnsemble(basis,d::Vector) =
87-
InvariantEnsemble(basis,Interval(d[1],d[2]))
87+
InvariantEnsemble(basis,Segment(d[1],d[2]))
8888

8989

9090
## n, where the invariant ensemble is n x n
@@ -123,7 +123,7 @@ end
123123
function adaptiveie(w,μ0,α,β,d)
124124
for logn = 4:20
125125
m=2^logn + 1
126-
pts=points(Interval(d[1],d[2]),m)
126+
pts=points(Segment(d[1],d[2]),m)
127127
pv=orthonormalpolynomialsvalues(μ0,α,β,pts)
128128

129129
wv=w(pts)
@@ -135,7 +135,7 @@ function adaptiveie(w,μ0,α,β,d)
135135

136136
m=length(chop!(cfs,200*eps()))
137137

138-
pts=points(Interval(d[1],d[2]),m)
138+
pts=points(Segment(d[1],d[2]),m)
139139
pv=orthonormalpolynomialsvalues(μ0,α,β,pts)
140140
wv=w(pts)
141141

src/RandomMatrices.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module RandomMatrices
22

33
using Combinatorics
4-
using Compat
54
using GSL
65
using OrdinaryDiffEq
76
using DiffEqBase # This line is only needed on v0.5, and comes free from OrdinaryDiffEq on v0.6
@@ -20,7 +19,7 @@ export bidrand, #Generate random bidiagonal matrix
2019
cumulant, freecumulant, cf, mgf,
2120
cdf, pdf, entropy, insupport, mean, median, modes, kurtosis, skewness, std, var, moment
2221

23-
typealias Dim2 Tuple{Int, Int} #Dimensions of a rectangular matrix
22+
const Dim2 = Tuple{Int, Int} #Dimensions of a rectangular matrix
2423

2524
#Classical Gaussian matrix ensembles
2625
include("GaussianEnsembles.jl")

src/StochasticProcess.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
import Base: start, next, done
44
export AiryProcess, BrownianProcess, WhiteNoiseProcess, next!
55

6-
abstract StochasticProcess{T<:Real}
6+
abstract type StochasticProcess{T<:Real} end
77

8-
immutable WhiteNoiseProcess{T<:Real} <: StochasticProcess{T}
8+
struct WhiteNoiseProcess{T<:Real} <: StochasticProcess{T}
99
dt::T
1010
end
1111

12-
immutable BrownianProcess{T<:Real} <: StochasticProcess{T}
12+
struct BrownianProcess{T<:Real} <: StochasticProcess{T}
1313
dt::T
1414
end
1515

16-
immutable AiryProcess{S<:Real, T<:Real} <: StochasticProcess{T}
16+
struct AiryProcess{S<:Real, T<:Real} <: StochasticProcess{T}
1717
dt::T
1818
beta::S
1919
end
@@ -67,5 +67,3 @@ function next{T}(p::AiryProcess{T}, S::SymTridiagonal{T})
6767

6868
(eigmax(S), S)
6969
end
70-
71-

0 commit comments

Comments
 (0)