Skip to content

Commit 16c414b

Browse files
committed
Merge pull request #20 from dlfivefifty/master
0.4 compatibility
2 parents b07d8c4 + c5b8fbe commit 16c414b

File tree

9 files changed

+101
-102
lines changed

9 files changed

+101
-102
lines changed

REQUIRE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
julia 0.3
1+
julia 0.3+
2+
Compat
23
Combinatorics
34
Docile
45
Distributions

demos/jacobigrowth2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#jacobigrowth2.jl
22

3-
using Distributions
3+
import Distributions
44
function jacobigrowth2(m1,m2,p,beta)
55
CJ=eye(p)
66
SJ=zeros(p, p)

src/FormalPowerSeries.jl

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type FormalPowerSeries{Coefficients}
2525
for i=1:length(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
28-
end
28+
end
2929
end
3030
FormalPowerSeries{Coefficients}(c)
3131
end
@@ -37,7 +37,7 @@ 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 :: Vector{Index})
40+
function tovector{T,Index<:Integer}(P::FormalPowerSeries{T}, n :: AbstractVector{Index})
4141
nn = length(n)
4242
c = zeros(nn)
4343
for (k,v) in P.c, i=1:nn
@@ -46,7 +46,7 @@ function tovector{T,Index<:Integer}(P::FormalPowerSeries{T}, n :: Vector{Index})
4646
c
4747
end
4848

49-
tovector(P::FormalPowerSeries, n::Integer)=tovector(P,[1:n])
49+
tovector(P::FormalPowerSeries, n::Integer)=tovector(P,1:n)
5050

5151

5252
# Basic housekeeping and properties
@@ -89,21 +89,21 @@ end
8989
function +{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
9090
c = Dict{BigInt, T}()
9191
for (k,v) in P.c
92-
haskey(c,k) ? (c[k]+=v) : (c[k]=v)
92+
haskey(c,k) ? (c[k]+=v) : (c[k]=v)
9393
end
9494
for (k,v) in Q.c
95-
haskey(c,k) ? (c[k]+=v) : (c[k]=v)
95+
haskey(c,k) ? (c[k]+=v) : (c[k]=v)
9696
end
9797
FormalPowerSeries{T}(c)
9898
end
9999

100100
function -{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
101101
c = Dict{BigInt, T}()
102102
for (k,v) in P.c
103-
c[k] = get(c,k,zero(T)) + v
103+
c[k] = get(c,k,zero(T)) + v
104104
end
105105
for (k,v) in Q.c
106-
c[k] = get(c,k,zero(T)) - v
106+
c[k] = get(c,k,zero(T)) - v
107107
end
108108
FormalPowerSeries{T}(c)
109109
end
@@ -132,7 +132,7 @@ end
132132
function CauchyProduct{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
133133
c = Dict{BigInt, T}()
134134
for (k1, v1) in P.c, (k2, v2) in Q.c
135-
c[k1+k2]=get(c, k1+k2, zero(T))+v1*v2
135+
c[k1+k2]=get(c, k1+k2, zero(T))+v1*v2
136136
end
137137
FormalPowerSeries{T}(c)
138138
end
@@ -196,10 +196,10 @@ end
196196
function reciprocal{T}(P::FormalPowerSeries{T}, n :: Integer)
197197
n<0 ? error(sprintf("Invalid inverse truncation length %d requested", n)) : true
198198

199-
a = tovector(P, [0:n-1]) #Extract original coefficients in vector
199+
a = tovector(P, 0:n-1) #Extract original coefficients in vector
200200
a[1]==0 ? (error("Inverse does not exist")) : true
201201
inv_a1 = T<:Number ? 1.0/a[1] : inv(a[1])
202-
202+
203203
b = zeros(n) #Inverse
204204
b[1] = inv_a1
205205
for k=2:n
@@ -208,7 +208,7 @@ function reciprocal{T}(P::FormalPowerSeries{T}, n :: Integer)
208208
FormalPowerSeries{T}(b)
209209
end
210210

211-
#Derivative of fps [H. Sec.1.4, p.18]
211+
#Derivative of fps [H. Sec.1.4, p.18]
212212
function derivative{T}(P::FormalPowerSeries{T})
213213
c = Dict{BigInt, T}()
214214
for (k,v) in P.c
@@ -238,7 +238,7 @@ function ^{T}(P::FormalPowerSeries{T}, n :: Integer)
238238
elseif n > 1
239239
#The straightforward recursive way
240240
return P^(n-1) * P
241-
#TODO implement the non-recursive formula
241+
#TODO implement the non-recursive formula
242242
elseif n==1
243243
return P
244244
else
@@ -251,13 +251,13 @@ end
251251
# Composition of fps [H, Sec.1.5, p.35]
252252
# This is the quick and dirty version
253253
function compose{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
254-
sum([v * Q^k for (k, v) in P.c])
254+
sum([v * Q^k for (k, v) in P.c])
255255
end
256256

257257

258258
#[H, p.45]
259259
function isalmostunit{T}(P::FormalPowerSeries{T})
260-
(haskey(P.c, 0) && P.c[0]!=0) ? (return false) :
260+
(haskey(P.c, 0) && P.c[0]!=0) ? (return false) :
261261
(haskey(P.c, 1) && P.c[1]!=0) ? (return true) : (return false)
262262
end
263263

@@ -269,7 +269,7 @@ end
269269
# and inverts it
270270
function reversion{T}(P::FormalPowerSeries{T}, n :: Integer)
271271
n>0 ? error("Need non-negative dimension") : nothing
272-
272+
273273
Q = P
274274
A = zeros(n, n)
275275
#Construct the matrix representation (1.9-1), p.55
@@ -304,4 +304,3 @@ type FormalLaurentSeries{Coefficients}
304304
c
305305
end
306306
end
307-

0 commit comments

Comments
 (0)