March 02, 2006

Bloody MMD...

Y'know, there are days I realize I should just give up trying to avoid clever things I don't want to do and just do them and get it over with.

This is one of those days. I'm working basic math into the tornado engine this afternoon. Nothing fancy, scalars only, but I've got four basic data types: 4 and 8 byte integers, 8 byte floats, and bignums. (Currently bignums are punted to the GNU MP library, but that'll go away in a while because of licensing issues) Results are the largest data type, so an Int4+Int8 produces an Int8, and an Int4+Float8 gives a Float8. (Yes, I know, there are issues of dropping bits with floats so it's not quite the same, but if you've got one float in the math already you've pretty much guaranteed things are fuzzy)

So I'm poking around in the files here and start throwing the code in. Data types all have to be figured out at runtime, since I don't want to annotate the bytecode enough to make sure that compilers aren't lying about the code that's produced (and I'm not comfortable designing an annotation system that's secure in the face of people trying to be evil), which means... well, it means switch statements. Lots of 'em. Or if ladders, but pretty much the same difference. And that's just nasty.

I really didn't want to put in MMD. I'd decided not to, actually, because of the basic type system that tornado has. (Not even any objects here) But even in the face of just a handful of types, it's easier to bite the bullet and go MMD. Which I didn't want to do.

Dammit, this sucks. (Even if it is ultimately handy) It'll probably be a lot more interesting when it comes time to dealing with the vectors, though.

Posted by Dan at March 2, 2006 04:11 PM | TrackBack (0)

Can I ask how you implement MMD? I read a paper (which I cannot find right now) about compressing mmd-matrices using poles. Their goal was to achive a O(N) lookup for N parameter functions.

While reading the paper I really wondered if one could use a simple hash algorithm like e.g.

and extend it to use ints instead of chars to allow for more than 256 classes. Then you could have a simple hash table instead of pole-detection and other compression techniques, and it would be O(N) as well..?

I am new to this but read your "musings" which show that you know a lot about this. This is why I am interested.


Posted by: tom at March 13, 2006 01:35 AM