Hi Factor team,
I've been using a ulong array type in my code for a while, and I noticed
that Joel's code [1] would benefit from a float-array type.
E.g.
TUPLE: float-array address length ;
C: <float-array> float-array
M: float-array length float-array-length ;
M: float-array nth-unsafe float-array-address float-nth ;
M: float-array set-nth-unsafe float-array-address set-float-nth ;
--------
and maybe:
: with-mapped-float-array ( fname quot -- )
>r dup file-length r>
[ [ mapped-file-address ] keep length 4 / <float-array>
] swap compose with-mapped-file ;
--------
... could make the faster version of Joel's code much cleaner:
: (sum-floats)
0 [ clip + 2 / ] reduce ;
: sum-floats
"/tmp/floats.bin" [ (sum-floats) ] with-mapped-float-array ;
I get the same times using this as with the faster version in Joel's
post. Do you think it's worthwhile me adding homogeneous arrays to the
factor library?
Cheers,
Phil
[1] http://www.wagerlabs.com/blog/2008/01/introducing-fac.html
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk