admin管理员组文章数量:1287511
The Common Lisp standard includes bit arrays and logical operations on them, such as bit-ior
, bit-and
,...
What the standard does not seem to offer is logical shifting of bit arrays.
Of course, this could be done manually with a simple loop and sbit
, but that would not be very efficient.
Looking into the sbcl source code (vm-tran.lisp), on how the other logical bit operations are implemented, the next possible way to implement it would be to mimicri the techniques, used there.
Last not least, there also seems to be a simd instruction, which allows simultaneous shifting (with carry) of 64 bit unsigned integers. This would either call for some vop hackery or to factor the problem out into a foreign library.
So, right now, I am at a cross roads, either trying to implement the function bit-logical-shift
within common lisp, or to write myself a shared library and use it via ffi. Which, of course would also open a small can of worms (would need to use simple-finalizer and trivial-garbage for the opaque pointer to the self-made bit arrays...)
I cannot believe, that I am the first, facing this problem and maybe someone here can share their experience, how they solved it.
本文标签: common lispEfficient logical shift for bit arraysStack Overflow
版权声明:本文标题:common lisp - Efficient logical shift for bit arrays? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741256471a2366770.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论