Created
September 15, 2014 08:21
-
-
Save ZacLN/519bd7a503a1fd1b8d98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#G.n::Int64 | |
#G.d::Int64 | |
#G.q::Int64 | |
#G.grid::Array{Float64,G.n,G.d} | |
#G.lvl_s::Array{Float64,G.n,G.d} | |
#G.lvl_l::Array{Float64,G.q+1} indices partitioning 1:G.n | |
function basis_func(x::Float64,xij::Float64,mi::Float64) :inline | |
if (mi==1) | |
return 1.0 | |
elseif (abs(x-xij)<(1.0/(mi-1.0))) | |
return (1.0-(mi-1.0)*abs(x-xij)) | |
else | |
return 0.0 | |
end | |
end | |
function w_getj(G::sparse_grid,A::Vector{Float64}) | |
Aold = Array(Float64,G.n) | |
dA = Array(Float64,G.n) | |
w = Array(Float64,G.n) | |
@inbounds w[1] = A[1] | |
fill!(dA,w[1]) | |
Aold += A[1] | |
drange=collect(1:G.d) | |
for q in 1:G.q | |
iirange=collect(G.lvl_l[q]:G.lvl_l[q+1]-1) | |
for i = G.lvl_l[q]:G.lvl_l[q+1]-1 | |
@inbounds w[i] = A[i] - Aold[i] | |
end | |
for i in 1:G.n | |
temp = 0.0 | |
@inbounds dA[i] = 0.0 | |
# for ii in G.lvl_l[q]:G.lvl_l[q+1]-1 | |
for ii in iirange | |
temp2=1.0 | |
for d in drange | |
@inbounds temp2 *= basis_func(G.grid[i,d],G.grid[ii,d],G.lvl_s[ii,d]) | |
end | |
@inbounds temp += temp2*w[ii] | |
end | |
@inbounds dA[i] = temp | |
end | |
for i = 1:G.n | |
Aold[i] += dA[i] | |
end | |
end | |
return w | |
end | |
:($(Expr(:lambda, {:G,:A}, {{:dA,:w,symbol("#s291"),:Aold,:irange,:drange,symbol("#s290"),symbol("#s289"),symbol("#s288"),:q … :_var11,:_var12,:_var13,:_var14,:_var15,:_var16,:_var17,:_var18,:_var19,:_var20},{{:G,sparse_grid,0},{:A,Array{Float64,1},0},{:dA,Array{Float64,1},18},{:w,Array{Float64,1},18},{symbol("#s291"),Float64,18},{:Aold,Array{Float64,1},2},{:irange,Array{Int64,1},18},{:drange,Array{Int64,1},18},{symbol("#s290"),UnitRange{Int64},18},{symbol("#s289"),Int64,2} … {:_var11,Int64,18},{:_var12,Int64,18},{:_var13,Int64,18},{:_var14,Int64,18},{:_var15,Int64,18},{:_var16,Int64,18},{:_var17,Int64,18},{:_var18,Int64,18},{:_var19,Int64,18},{:_var20,Int64,18}},{}}, :(begin # In[4], line 3: | |
_var0 = (top(getfield))(G::sparse_grid,:n)::Int64 | |
Aold = (top(ccall))(:jl_alloc_array_1d,$(Expr(:call1, :(top(apply_type)), :Array, Float64, 1))::Type{Array{Float64,1}},$(Expr(:call1, :(top(tuple)), :Any, :Int))::(Type{Any},Type{Int64}),Array{Float64,1},0,_var0::Int64,0)::Array{Float64,1} # line 4: | |
_var1 = (top(getfield))(G::sparse_grid,:n)::Int64 | |
dA = (top(ccall))(:jl_alloc_array_1d,$(Expr(:call1, :(top(apply_type)), :Array, Float64, 1))::Type{Array{Float64,1}},$(Expr(:call1, :(top(tuple)), :Any, :Int))::(Type{Any},Type{Int64}),Array{Float64,1},0,_var1::Int64,0)::Array{Float64,1} # line 5: | |
_var2 = (top(getfield))(G::sparse_grid,:n)::Int64 | |
w = (top(ccall))(:jl_alloc_array_1d,$(Expr(:call1, :(top(apply_type)), :Array, Float64, 1))::Type{Array{Float64,1}},$(Expr(:call1, :(top(tuple)), :Any, :Int))::(Type{Any},Type{Int64}),Array{Float64,1},0,_var2::Int64,0)::Array{Float64,1} # line 8: | |
$(Expr(:boundscheck, false)) | |
#s291 = (top(arrayref))(A::Array{Float64,1},1)::Float64 | |
(top(arrayset))(w::Array{Float64,1},#s291::Float64,1)::Array{Float64,1} | |
$(Expr(:boundscheck, :((top(getfield))(Base,:pop)))) # line 9: | |
fill!(dA::Array{Float64,1},(top(arrayref))(w::Array{Float64,1},1)::Float64)::Array{Float64,1} # line 10: | |
_var3 = (top(arrayref))(A::Array{Float64,1},1)::Float64 | |
Aold = Aold::Array{Float64,1} .+ _var3::Float64::Array{Float64,1} # line 12: | |
_var4 = (top(getfield))(G::sparse_grid,:n)::Int64 | |
irange = collect(Int64,$(Expr(:new, UnitRange{Int64}, 1, :(((top(getfield))(Intrinsics,:select_value))((top(sle_int))(1,_var4::Int64)::Bool,_var4::Int64,(top(box))(Int64,(top(sub_int))(1,1))::Int64)::Int64)))::UnitRange{Int64})::Array{Int64,1} # line 13: | |
_var5 = (top(getfield))(G::sparse_grid,:d)::Int64 | |
drange = collect(Int64,$(Expr(:new, UnitRange{Int64}, 1, :(((top(getfield))(Intrinsics,:select_value))((top(sle_int))(1,_var5::Int64)::Bool,_var5::Int64,(top(box))(Int64,(top(sub_int))(1,1))::Int64)::Int64)))::UnitRange{Int64})::Array{Int64,1} # line 14: | |
_var6 = (top(getfield))(G::sparse_grid,:q)::Int64 | |
#s290 = $(Expr(:new, UnitRange{Int64}, 1, :(((top(getfield))(Intrinsics,:select_value))((top(sle_int))(1,_var6::Int64)::Bool,_var6::Int64,(top(box))(Int64,(top(sub_int))(1,1))::Int64)::Int64)))::UnitRange{Int64} | |
#s289 = (top(getfield))(#s290::UnitRange{Int64},:start)::Int64 | |
unless (top(box))(Bool,(top(not_int))(#s289::Int64 === (top(box))(Int64,(top(add_int))((top(getfield))(#s290::UnitRange{Int64},:stop)::Int64,1))::Int64::Bool))::Bool goto 1 | |
2: | |
_var13 = #s289::Int64 | |
_var14 = (top(box))(Int64,(top(add_int))(#s289::Int64,1))::Int64 | |
q = _var13::Int64 | |
#s289 = _var14::Int64 # line 15: | |
iirange = collect(colon(getindex((top(getfield))(G::sparse_grid,:lvl_l),q::Int64),getindex((top(getfield))(G::sparse_grid,:lvl_l),(top(box))(Int64,(top(add_int))(q::Int64,1))::Int64) - 1)) # line 18: | |
#s287 = colon(getindex((top(getfield))(G::sparse_grid,:lvl_l),q::Int64),getindex((top(getfield))(G::sparse_grid,:lvl_l),(top(box))(Int64,(top(add_int))(q::Int64,1))::Int64) - 1) | |
#s286 = (top(start))(#s287) | |
unless (top(!))((top(done))(#s287,#s286)) goto 5 | |
6: | |
#s285 = (top(next))(#s287,#s286) | |
#363#i = (top(tupleref))(#s285,1) | |
#s286 = (top(tupleref))(#s285,2) # line 19: | |
$(Expr(:boundscheck, false)) | |
#s284 = getindex(A::Array{Float64,1},#363#i) - getindex(Aold::Array{Float64,1},#363#i) | |
setindex!(w::Array{Float64,1},#s284,#363#i) | |
$(Expr(:boundscheck, :((top(getfield))(Base,:pop)))) | |
7: | |
unless (top(!))((top(!))((top(done))(#s287,#s286))) goto 6 | |
5: | |
4: # line 22: | |
#s283 = irange::Array{Int64,1} | |
#s282 = 1 | |
_var7 = (top(arraylen))(#s283::Array{Int64,1})::Int64 | |
unless (top(box))(Bool,(top(not_int))((top(slt_int))(_var7::Int64,#s282::Int64)::Bool))::Bool goto 9 | |
10: | |
_var15 = (top(arrayref))(#s283::Array{Int64,1},#s282::Int64)::Int64 | |
_var16 = (top(box))(Int64,(top(add_int))(#s282::Int64,1))::Int64 | |
#364#i = _var15::Int64 | |
#s282 = _var16::Int64 # line 23: | |
temp = 0.0 # line 24: | |
$(Expr(:boundscheck, false)) | |
(top(arrayset))(dA::Array{Float64,1},0.0,#364#i::Int64)::Array{Float64,1} | |
$(Expr(:boundscheck, :((top(getfield))(Base,:pop)))) # line 26: | |
#s280 = iirange | |
#s279 = (top(start))(#s280) | |
unless (top(!))((top(done))(#s280,#s279)) goto 13 | |
14: | |
#s278 = (top(next))(#s280,#s279) | |
ii = (top(tupleref))(#s278,1) | |
#s279 = (top(tupleref))(#s278,2) # line 27: | |
temp2 = 1.0 # line 29: | |
#s277 = drange::Array{Int64,1} | |
#s276 = 1 | |
_var8 = (top(arraylen))(#s277::Array{Int64,1})::Int64 | |
unless (top(box))(Bool,(top(not_int))((top(slt_int))(_var8::Int64,#s276::Int64)::Bool))::Bool goto 17 | |
18: | |
_var17 = (top(arrayref))(#s277::Array{Int64,1},#s276::Int64)::Int64 | |
_var18 = (top(box))(Int64,(top(add_int))(#s276::Int64,1))::Int64 | |
d = _var17::Int64 | |
#s276 = _var18::Int64 # line 30: | |
$(Expr(:boundscheck, false)) | |
_var9 = basis_func((top(arrayref))((top(getfield))(G::sparse_grid,:grid)::Array{Float64,N},#364#i::Int64,d::Int64)::Float64,getindex((top(getfield))(G::sparse_grid,:grid)::Array{Float64,N},ii,d::Int64),getindex((top(getfield))(G::sparse_grid,:lvl_s),ii,d::Int64))::Float64 | |
temp2 = (top(box))(Float64,(top(mul_float))(temp2::Float64,_var9::Float64))::Float64 | |
$(Expr(:boundscheck, :((top(getfield))(Base,:pop)))) | |
19: | |
_var10 = (top(arraylen))(#s277::Array{Int64,1})::Int64 | |
unless (top(box))(Bool,(top(not_int))((top(box))(Bool,(top(not_int))((top(slt_int))(_var10::Int64,#s276::Int64)::Bool))::Bool))::Bool goto 18 | |
17: | |
16: # line 32: | |
$(Expr(:boundscheck, false)) | |
temp = temp + temp2::Float64 * getindex(w::Array{Float64,1},ii) | |
$(Expr(:boundscheck, :((top(getfield))(Base,:pop)))) | |
15: | |
unless (top(!))((top(!))((top(done))(#s280,#s279))) goto 14 | |
13: | |
12: # line 34: | |
$(Expr(:boundscheck, false)) | |
setindex!(dA::Array{Float64,1},temp,#364#i::Int64) | |
$(Expr(:boundscheck, :((top(getfield))(Base,:pop)))) | |
11: | |
_var11 = (top(arraylen))(#s283::Array{Int64,1})::Int64 | |
unless (top(box))(Bool,(top(not_int))((top(box))(Bool,(top(not_int))((top(slt_int))(_var11::Int64,#s282::Int64)::Bool))::Bool))::Bool goto 10 | |
9: | |
8: # line 36: | |
_var12 = (top(getfield))(G::sparse_grid,:n)::Int64 | |
#s274 = $(Expr(:new, UnitRange{Int64}, 1, :(((top(getfield))(Intrinsics,:select_value))((top(sle_int))(1,_var12::Int64)::Bool,_var12::Int64,(top(box))(Int64,(top(sub_int))(1,1))::Int64)::Int64)))::UnitRange{Int64} | |
#s273 = (top(getfield))(#s274::UnitRange{Int64},:start)::Int64 | |
unless (top(box))(Bool,(top(not_int))(#s273::Int64 === (top(box))(Int64,(top(add_int))((top(getfield))(#s274::UnitRange{Int64},:stop)::Int64,1))::Int64::Bool))::Bool goto 21 | |
22: | |
_var19 = #s273::Int64 | |
_var20 = (top(box))(Int64,(top(add_int))(#s273::Int64,1))::Int64 | |
#365#i = _var19::Int64 | |
#s273 = _var20::Int64 # line 37: | |
#s271 = (top(box))(Float64,(top(add_float))((top(arrayref))(Aold::Array{Float64,1},#365#i::Int64)::Float64,(top(arrayref))(dA::Array{Float64,1},#365#i::Int64)::Float64))::Float64 | |
(top(arrayset))(Aold::Array{Float64,1},#s271::Float64,#365#i::Int64)::Array{Float64,1} | |
23: | |
unless (top(box))(Bool,(top(not_int))((top(box))(Bool,(top(not_int))(#s273::Int64 === (top(box))(Int64,(top(add_int))((top(getfield))(#s274::UnitRange{Int64},:stop)::Int64,1))::Int64::Bool))::Bool))::Bool goto 22 | |
21: | |
20: | |
3: | |
unless (top(box))(Bool,(top(not_int))((top(box))(Bool,(top(not_int))(#s289::Int64 === (top(box))(Int64,(top(add_int))((top(getfield))(#s290::UnitRange{Int64},:stop)::Int64,1))::Int64::Bool))::Bool))::Bool goto 2 | |
1: | |
0: # line 40: | |
return w::Array{Float64,1} | |
end::Array{Float64,1})))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment