Saturday, December 15, 2007

std::transform

I've heard people talking about the std::transform functions for ages, but I didn't really get around to exploring them until recently. What they bring to the table is a compact yet powerful way of performing a batch operations on stl containers, much like matlab's matrix math routines but with way more potential. You can perform common vector arithmetic such as addition, subtraction etc. but also select certain components of a container, such as the routine below that in one single line prints all the hash values of a std::map. Furthermore, by writing your code in std::transform notation you're very likely unleashing a higher degree of optimization potential in your compilers, both current and future ones. For example, the Intel compiler (I'm running 9.1 atm) immediately starts spewing out "LOOP WAS AUTO-PARALLELIZED" all over the place, which generally hasn't been too common a sight for me in the past.

Now for a couple examples, copied straight from http://www.sgi.com/tech/stl/ :

Print all of a map's keys.
int main()
{
map M;
M[1] = 0.3;
M[47] = 0.8;
M[33] = 0.1;

transform(M.begin(), M.end(), ostream_iterator(cout, " "),
select1st<map::value_type>());
// The output is 1 33 47.
}
Each element in V3 will be the difference of the corresponding elements in V1 and V2
const int N = 1000;
vector V1(N);
vector V2(N);
vector V3(N);

iota(V1.begin(), V1.end(), 1);
fill(V2.begin(), V2.end(), 75);

assert(V2.size() >= V1.size() && V3.size() >= V1.size());
transform(V1.begin(), V1.end(), V2.begin(), V3.begin(),
minus());

Friday, December 14, 2007

The stuff of legend

So I haven't posted anything in the longest of times but today I just have to break this unintentional silence; my co-worker Nafees (bin Zafar) just walked into our cubicle with the biggest smile on his face, eyes gleaming. In his hand was a letter from the Academy of Motion Picture Arts and Sciences. It turns out he, Doug Roble and Ryo Sakaguchi have scored a Scientific & Technical Achievement Award for our internal fluid simulator FSIM! For those of you who don't know, it was one of the first fluid simulators ever to be used in a feature film - check out the flooding of Bruinen in "The Lord of the Rings: The Fellowship of the Ring" (it's the one where the ringwraiths get their asses wooped out in the river). While FSIM has seen substantial improvements over the years it remains based on their original work, and this award serves to emphasize how groundbreaking that was. So although many of these guys seldom or never turn to alcohol for comfort or joy, I just might have to get hammered tonight in their honor. Celebration!

Tuesday, September 04, 2007

readelf

Yet again abusing my blog to store random software development notes,
readelf is a linux command that dumps information about ELF-format object files (e.g. .so libraries). Just pipe it into a temp file using e.g.

readelf ~/maya/2008.cg/plugins/HairDynamics.so > out

and search for the unfiltered symbol you want to examine using your favorite text editor/grepper. This will produce a line similar to:

r19: 00000000 0 NOTYPE GLOBAL DEFAULT UND _ZN2My5Library10FileWriter4

which in this case means the particular My::Library::FileWriter is UNDefined. Highly useful when messing around with link/runtime shared object errors.

Sunday, August 19, 2007

Quote of the year

"Too often, we lose sight of life's simple pleasures. Remember, when someone annoys you it takes 42 muscles in your face to frown BUT, it only takes 4 muscles to extend your arm and bitch-slap the motherfucker upside the head." - picked up from a Walter Mosley novel

Thursday, August 09, 2007

The SIGGRAPH buzzword of the year...

... has to be "rotation invariant" or some other term pertaining to minimal-distortion mesh editing. Over the last couple of days I have seen more bunnies and armadillos being bent, stretched and twisted than during my entire life. Makes perfect sense, what with all the high-resolution shape acquisition gear that's getting increasingly available.

Some highly cool stuff includes the real-time shape and texture capturing system (just insert whatever into the green cube and voila: it shows up on the display and interacts with the environment), as well as some new promising hybrid display technology (imagine readily calibratable LCDs...).

The most frustrating bit has to be the "300" team that refused to reveal the secret behind their huge fluid sim grids. They just showed some impressive results and proceeded to refuse answering questions about how they got around the serious memory issues involved in cramming that size system through a CG solver. Yeah, parallel this and parallel that; the important part is still heavily obfuscated, totally against the SIGGRAPH purpose (and spirit). Boo.