
I've just uploaded my matrix/vector library to the vault (math2-matrix-vector, under Math - Geometry). It's a library I was working on for a very long time a few years back, trying to find the computationally most efficient one possible. The reason I haven't shared it earlier is that I've come to believe that keeping it simple is better, but now I see that vector swizzling is being discussed, so... The library uses expression templates for all componentwise operations (so v1 = 2*v2 + v3 can be evaluated with no temporaries greater than a float), has support for SSE2 vector intrinsics, and supports some element reordering operations, including lvalue vector swizzling (v[zw] = vector<2>(1,2) works). Not all swizzlings are named, but if the one you happen to want is not provided then it is easy to create: const indexer<bits::index_swizzle<0,0,2,0> > xxzx; const indexer<bits::index_swizzle<3,2,1,0> > wzyx; vector<4> v1, v2(1,2,3,4); v1 = v2[xxzx]; // v1 = (1,1,3,1) v1[xxzx] = v2; // error - v1[xxzx] is not a lvalue due to aliasing v1[wzyx] = v2; // v1 = (4,3,2,1) Overall, I've found swizzling somewhat convenient, but far from necessary. Nearly every time I used it it was to isolate xyz in a 4-component vector. -- Daniel Wesslén