author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年02月13日 22:59:17 +0100 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年02月13日 22:59:17 +0100 |
commit | 24329844c93d7d92d9fee38d6a6e9070d7085568 (patch) | |
tree | 579cb3948c50f529b40b0b588201ce993fc92232 | |
parent | 47d0e0665ee3216df890f7d4b5582b157eba8bd2 (diff) | |
download | gsl-shell-ode-vec.tar.gz |
-rw-r--r-- | templates/rk8pd-vec.lua.in | 33 |
diff --git a/templates/rk8pd-vec.lua.in b/templates/rk8pd-vec.lua.in index cb2078e5..744fb491 100644 --- a/templates/rk8pd-vec.lua.in +++ b/templates/rk8pd-vec.lua.in @@ -177,17 +177,16 @@ end # y_err_only = (a_dydt == 0) -local function copy(dst, src) - gsl.cblas_dcopy($(N), src, 1, dst, 1) -end +# function COPY(DST, SRC) +# local fmt = 'gsl.cblas_dcopy(%d, %s.data, 1, %s.data, 1)' +# return string.format(fmt, N, SRC, DST) +# end -local function axpy(alpha, x, y) - gsl.cblas_daxpy($(N), alpha, x, 1, y, 1) -end -local function view(m, i) - return m.data + m.tda * i -end +# function AXPY(ALPHA, X, Y) +# local fmt = 'gsl.cblas_daxpy(%d, %s, %s, 1, %s, 1)' +# return string.format(fmt, N, ALPHA, X, Y) +# end local function zero(x) for i = 0, $(N-1) do x[i] = 0 end @@ -202,21 +201,21 @@ local function rk8pd_vec_evolve(s, f, t1) # end local y = s.ytmp1 - copy(k1.data, s_dydt.data) + $(COPY('k1', 's_dydt')) if t + h > t1 then h = t1 - t end while h > 0 do - copy(y.data, s_y.data) + $(COPY('y', 's_y')) local rmax = 0 do local ytmp = s.ytmp2 # for S = 2, 13 do - copy(ytmp.data, y.data) + $(COPY('ytmp', 'y')) # for J = 1, S-1 do - axpy(h * $(B[S][J]), k$(J).data, ytmp.data) + $(AXPY('h * '..B[S][J], 'k'..J..'.data', 'ytmp'..'.data')) # end f(t + $(ah[S-1]) * h, ytmp, k$(S)) # end @@ -224,9 +223,9 @@ local function rk8pd_vec_evolve(s, f, t1) local ksum8 = s.ksum8.data zero(ksum8) # for S = 1, 13 do - axpy($(Abar[S]), k$(S).data, ksum8) + $(AXPY(Abar[S], 'k'..S..'.data', 'ksum8')) # end - axpy(h, ksum8, y.data) + $(AXPY('h', 'ksum8', 'y.data')) # if not y_err_only then f(t + h, y, s_dydt) @@ -262,7 +261,7 @@ local function rk8pd_vec_evolve(s, f, t1) f(t + h, y, s_dydt) # end - copy(s_y.data, y.data) + $(COPY('s_y', 'y')) s.t = t + h s.h = hadj @@ -286,7 +285,7 @@ local function ode_vec_new() end local function ode_vec_init(s, t0, h0, f, y) - copy(s.y.data, y.data) + $(COPY('s.y', 'y')) f(t0, y, s.dydt) s.t = t0 s.h = h0 |