From d65032f83b8ae474fdea542baadc3dc21f32b33f Mon Sep 17 00:00:00 2001 From: amitjamadagni Date: Fri, 11 Dec 2015 14:55:23 +0800 Subject: [PATCH 1/2] Use of FastAnonymous.jl for ODE solvers. --- REQUIRE | 1 + src/QuDynamics.jl | 1 + src/propodesolvers.jl | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index 02af2de..d14e867 100644 --- a/REQUIRE +++ b/REQUIRE @@ -2,3 +2,4 @@ julia 0.3 Compat Docile ODE 0.2.1 +FastAnonymous diff --git a/src/QuDynamics.jl b/src/QuDynamics.jl index a668def..5da7617 100644 --- a/src/QuDynamics.jl +++ b/src/QuDynamics.jl @@ -4,6 +4,7 @@ module QuDynamics using ODE using Expokit using ExpmV + using FastAnonymous VERSION < v"0.4-" && using Docile include("quequations.jl") include("propmachinery.jl") diff --git a/src/propodesolvers.jl b/src/propodesolvers.jl index 4664ccb..9ee98b4 100644 --- a/src/propodesolvers.jl +++ b/src/propodesolvers.jl @@ -31,7 +31,8 @@ for (qu_ode_type,ode_solver) in type_to_method_ode dims = size(current_qustate) # Convert the current_qustate to complex as it might result in a Inexact Error. After complex is in QuBase.jl (PR #38) # we could just do a complex(vec(current_qustate)) avoiding the coeffs(coeffs(vec(current_qustate))). - next_state = $ode_solver((t,y)-> -im*coeffs(op)*y, complex(coeffs(vec(current_qustate))), [current_t, t], points=:specified, + f = @anon (t,y)-> -im*coeffs(op)*y + next_state = $ode_solver(f, complex(coeffs(vec(current_qustate))), [current_t, t], points=:specified, reltol = get(prob.options, :reltol, 1.0e-5), abstol = get(prob.options, :abstol, 1.0e-8))[2][end] CQST = QuBase.similar_type(current_qustate) return CQST(reshape(next_state, dims), bases(current_qustate)) From e748cd01928041b9f5b6bbbb7be4531622fb51a5 Mon Sep 17 00:00:00 2001 From: amitjamadagni Date: Sun, 13 Dec 2015 21:55:17 +0800 Subject: [PATCH 2/2] Use of scale! --- src/propodesolvers.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/propodesolvers.jl b/src/propodesolvers.jl index 9ee98b4..03719bb 100644 --- a/src/propodesolvers.jl +++ b/src/propodesolvers.jl @@ -31,7 +31,7 @@ for (qu_ode_type,ode_solver) in type_to_method_ode dims = size(current_qustate) # Convert the current_qustate to complex as it might result in a Inexact Error. After complex is in QuBase.jl (PR #38) # we could just do a complex(vec(current_qustate)) avoiding the coeffs(coeffs(vec(current_qustate))). - f = @anon (t,y)-> -im*coeffs(op)*y + f = @anon (t,y)-> scale!(coeffs(op)*y, -im) next_state = $ode_solver(f, complex(coeffs(vec(current_qustate))), [current_t, t], points=:specified, reltol = get(prob.options, :reltol, 1.0e-5), abstol = get(prob.options, :abstol, 1.0e-8))[2][end] CQST = QuBase.similar_type(current_qustate)