Skip to content

Commit 6fdccbf

Browse files
committed
Update InvariantEnsembles.jl for latest ApproxFun and Julia 0.5
1 parent 6b4bae6 commit 6fdccbf

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/InvariantEnsembles.jl

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function orthonormalpolynomials(μ0,α::Vector,β::Vector,d)
3434
n=length(α)+1
3535

3636
p=Array(Fun{Chebyshev,Float64},n)
37-
p[1] = Fun([μ0],d)
37+
p[1] = Fun(d,[μ0])
3838
p[2] = multiplybyx(p[1])./β[1] - p[1].*α[1]./β[1]
3939
for k = 3:n
4040
p[k] = multiplybyx(p[k-1])./β[k-1] - p[k-1].*α[k-1]./β[k-1] - p[k-2].*β[k-2]./β[k-1]
@@ -71,12 +71,20 @@ end
7171

7272
## Ensembles
7373

74-
type InvariantEnsemble{D<:Interval}
74+
type 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)
7778
end
7879

79-
InvariantEnsemble(basis,d::Vector)=InvariantEnsemble(basis,Interval(d))
80+
InvariantEnsemble(basis::Matrix,d::Domain) =
81+
InvariantEnsemble{typeof(d)}(basis,d)
82+
83+
InvariantEnsemble(basis::Matrix,d::Vector) =
84+
InvariantEnsemble(basis,Interval(d[1],d[2]))
85+
86+
InvariantEnsemble(basis,d::Vector) =
87+
InvariantEnsemble(basis,Interval(d[1],d[2]))
8088

8189

8290
## n, where the invariant ensemble is n x n
@@ -115,7 +123,7 @@ end
115123
function adaptiveie(w,μ0,α,β,d)
116124
for logn = 4:20
117125
m=2^logn + 1
118-
pts=points(Interval(d),m)
126+
pts=points(Interval(d[1],d[2]),m)
119127
pv=orthonormalpolynomialsvalues(μ0,α,β,pts)
120128

121129
wv=w(pts)
@@ -127,7 +135,7 @@ function adaptiveie(w,μ0,α,β,d)
127135

128136
m=length(chop!(cfs,200*eps()))
129137

130-
pts=points(Interval(d),m)
138+
pts=points(Interval(d[1],d[2]),m)
131139
pv=orthonormalpolynomialsvalues(μ0,α,β,pts)
132140
wv=w(pts)
133141

@@ -190,7 +198,7 @@ end
190198

191199
## Construct the invariant ensemble kernel K_n(x,x)
192200
iekernel(q::Array{Float64,2},d)=iekernel(q,d,plan_chebyshevtransform(q[:,1]))
193-
function iekernel(q::Array{Float64,2},d,plan::Function)
201+
function iekernel(q::Array{Float64,2},d,plan)
194202
n=size(q)[1]
195203
m=size(q)[2]
196204
ret=zeros(n)
@@ -200,11 +208,11 @@ function iekernel(q::Array{Float64,2},d,plan::Function)
200208
end
201209
end
202210

203-
Fun(chebyshevtransform(ret,plan),d)
211+
Fun(d,plan*ret)
204212
end
205213

206214

207-
samplespectra(str::AbstractString,n::Integer,m::Integer)=samplespectra(InvariantEnsemble(str,n),m)
215+
samplespectra(str::AbstractString,n::Integer,m::Integer) = samplespectra(InvariantEnsemble(str,n),m)
208216

209217

210218
# Sample eigenvalues of invariant ensemble, m times
@@ -237,7 +245,7 @@ end
237245
## samplespectra is back end for eigvalrand
238246
samplespectra(q::Array{Float64,2},d)=samplespectra(q,d,plan_chebyshevtransform(q[:,1]),chebyshevpoints(size(q,1)))
239247

240-
function samplespectra(q::Array{Float64,2},d,plan::Function,pts)
248+
function samplespectra(q::Array{Float64,2},d,plan,pts)
241249
n = size(q,2)
242250
r=Array(Float64,n)
243251

@@ -247,7 +255,7 @@ function samplespectra(q::Array{Float64,2},d,plan::Function,pts)
247255
r[k] = samplecdf(normalizedcumsum!(iekernel(q,d,plan).coefficients/m))
248256
f=Float64[bary(q[:,j],pts,r[k]) for j = 1:m]
249257
r[k] = fromcanonical(d,r[k])
250-
Q=null(f')
258+
Q=nullspace(f')
251259
q=q*Q
252260
end
253261

@@ -273,7 +281,7 @@ function samplespectra{F<:Fun}(p::Array{F})
273281
r
274282
else
275283
f=map(q->q[r],p)
276-
Q=null(f')'
284+
Q=nullspace(f')'
277285
[r ;samplespectra(Q*p)]
278286
end
279287
end

0 commit comments

Comments
 (0)