I recently decided to give a serious go to learning Rust. As my first non-toy project, I decided to port an old piece of code I'd been wanting to dust off anyway: k-d forests. The basic premise of it is to generate images with every possible 8-bit RGB color, by placing each color next to the most similarly-colored pixel placed so far.Continue reading Porting k-d forests to Rust
I recently released version 1.1.3 of
bfs, my breadth-first drop-in replacement for the UNIX
find command. The major change in this release is a refactor of the optimizer, so I figured it would be a good time to write up some of the details of its implementation.
Today is the release of version 1.0 of
bfs, a fully-compatible* drop-in replacement for the UNIX
find command. I thought this would be a good occasion to write more about its implementation. This post will talk about how I parse the command line. Continue reading bfs from the ground up, part 2: parsing
If you need to multiply some matrices together very quickly, usually it's best to use a highly optimized library like ATLAS. But sometimes adding such a dependency isn't worth it, if you're worried about portability, code size, etc. If you just need good performance, rather than the best possible performance, it can make sense to hand-roll your own matrix multiplication function. Continue reading A quick trick for faster naïve matrix multiplication
Continue reading bfs from the ground up, part 1: traversal
bfs is a tool I've been writing for about a year, with the goal of being a drop-in replacement for the UNIX
find command. This series of posts will be deep technical explorations of its implementation, starting from the lower levels all the way up to the user interface.
bfs is small (only about 3,500 lines of C code), which makes it possible to do a fairly complete analysis. But the codebase is fairly clean and highly optimized, which should make the analysis interesting.
In part 1, I outlined an algorithm for computing intersections between rays and axis-aligned bounding boxes. The idea to eliminate branches by relying on IEEE 754 floating point properties goes back to Brian Smits in , and the implementation was fleshed out by Amy Williams. et al. in .
It's surprisingly difficult to find a good code snippet for this on Google, so here's an efficient computation of integer powers in C, using binary exponentiation:
Clang is known for its great error messages, but I did manage to horribly confuse it: