Skip to content

Commit e1491d7

Browse files
committed
Fixes for Julia 0.5
- FormalPowerSeries tests take into account indexing changes in 0.5 - blasfunc in 0.4 is now @blasfunc in 0.5 - replace 1:length(v) with eachindex(v) in for loops
1 parent c75e471 commit e1491d7

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

src/FormalPowerSeries.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type FormalPowerSeries{Coefficients}
2222
FormalPowerSeries{Coefficients}(c::Dict{BigInt, Coefficients}) = new(c)
2323
function FormalPowerSeries{Coefficients}(v::Vector{Coefficients})
2424
c=Dict{BigInt, Coefficients}()
25-
for i=1:length(v)
25+
for i in eachindex(v)
2626
if v[i] != 0
2727
c[i-1] = v[i] #Note this off by 1 - allows constant term c[0] to be set
2828
end
@@ -37,10 +37,10 @@ zero{T}(P::FormalPowerSeries{T}) = FormalPowerSeries(T[])
3737
one{T}(P::FormalPowerSeries{T}) = FormalPowerSeries(T[1])
3838

3939
#Return truncated vector with c[i] = P[n[i]]
40-
function tovector{T,Index<:Integer}(P::FormalPowerSeries{T}, n :: AbstractVector{Index})
40+
function tovector{T,Index<:Integer}(P::FormalPowerSeries{T}, n::AbstractVector{Index})
4141
nn = length(n)
4242
c = zeros(nn)
43-
for (k,v) in P.c, i=1:nn
43+
for (k,v) in P.c, i in eachindex(n)
4444
n[i]==k && (c[i]=v)
4545
end
4646
c

src/HaarMeasure.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,31 @@ end
6565
#Zyczkowski and Kus, Random unitary matrices, J. Phys. A: Math. Gen. 27,
6666
#4235–4245 (1994).
6767

68-
### Stewarts algorithm for n^2 orthogonal random matrix
6968
using Base.LinAlg: BlasInt
7069
for (s, elty) in (("dlarfg_", Float64),
7170
("zlarfg_", Complex128))
72-
@eval begin
73-
function larfg!(n::Int, α::Ptr{$elty}, x::Ptr{$elty}, incx::Int, τ::Ptr{$elty})
74-
ccall(($(Base.blasfunc(s)), Base.liblapack_name), Void,
75-
(Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}),
76-
&n, α, x, &incx, τ)
71+
if Base.VERSION < v"0.5-"
72+
@eval begin
73+
function larfg!(n::Int, α::Ptr{$elty}, x::Ptr{$elty}, incx::Int, τ::Ptr{$elty})
74+
ccall(($(Base.blasfunc(s)), Base.liblapack_name), Void,
75+
(Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}),
76+
&n, α, x, &incx, τ)
77+
end
78+
end
79+
else
80+
@eval begin
81+
function larfg!(n::Int, α::Ptr{$elty}, x::Ptr{$elty}, incx::Int, τ::Ptr{$elty})
82+
ccall(($(Base.@blasfunc(s)), Base.liblapack_name), Void,
83+
(Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}),
84+
&n, α, x, &incx, τ)
85+
end
7786
end
7887
end
7988
end
8089

90+
"""
91+
Stewarts algorithm for n^2 orthogonal random matrix
92+
"""
8193
function Stewart(::Type{Float64}, n)
8294
τ = Array(Float64, n)
8395
H = randn(n, n)

test/FormalPowerSeries.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using RandomMatrices
22
using Base.Test
33

4+
srand(4)
5+
46
# Excursions in formal power series (fps)
57
MaxSeriesSize=8
68
MaxRange = 20
@@ -49,7 +51,11 @@ end
4951
#of the original series
5052
#Force reciprocal to exist
5153
X.c[0] = 1
52-
discrepancy = (norm(inv(float(MatrixForm(X,c)))[1, :]'[:, 1] - tovector(reciprocal(X, c), 0:c-1)))
54+
discrepancy = if Base.VERSION < v"0.5-"
55+
(norm(inv(float(MatrixForm(X,c)))[1, :]'[:, 1] - tovector(reciprocal(X, c), 0:c-1)))
56+
else
57+
(norm(inv(float(MatrixForm(X,c)))[1, :][:, 1] - tovector(reciprocal(X, c), 0:c-1)))
58+
end
5359
tol = c*√eps()
5460
if discrepancy > tol
5561
error(string("Error ", discrepancy, " exceeds tolerance ", tol))

0 commit comments

Comments
 (0)