On Wed, 21 Feb 2018, Sven Schreiber wrote:
Am 20.02.2018 um 17:11 schrieb Sven Schreiber:
> So Allin had the great idea to enable binary-mode transfer between Python
> and Gretl, and I tried it.
> Python / Numba pure calculation
> This took = 1.887286 sec.
> Python / Numba with binary transfer
> This took = 2.087111 sec.
I have now tried the same thing with Julia, and the number with the binary
transfer is essentially the same. The pure calculation seems a little bit
faster, with Julia around 1.4 secs.
The way I have implemented writing a binary matrix file for import into gretl
was pretty straightforward, maybe that's something for gretl_io.jl, too:
<julia>
out = SB(x,b,n) # the JITted function
(r,c) = size(out)
indotdir = <hardwired dotdir> * "SBtransf.bin"
f = open(indotdir, "w")
write(f, "gretl_binary_matrix") # mandatory by gretl
write(f, Int32(r))
write(f, Int32(c))
write(f, out)
close(f)
</julia>
Thanks for the idea. I've now extended native support for ".bin"
matrix files to our Julia interface. Test script:
<hansl>
set verbose off
matrix m = mnormal(1000, 800)
set stopwatch
mwrite(m, "tojl.mat", 1)
foreign language=julia
jm = gretl_loadmat("tojl.mat")
gretl_export(jm, "fromjl.mat")
end foreign
jl_m = mread("fromjl.mat", 1)
printf "plain text round-trip: %gs\n", $stopwatch
printf "max diff = %g\n", maxr(maxc(abs(m - jl_m)))
set stopwatch
mwrite(m, "tojl.bin", 1)
foreign language=julia
jm = gretl_loadmat("tojl.bin")
gretl_export(jm, "fromjl.bin")
end foreign
jl_m = mread("fromjl.bin", 1)
printf "binary round-trip: %gs\n", $stopwatch
printf "max diff = %g\n", maxr(maxc(abs(m - jl_m)))
</hansl>
Allin