Bad mood

Posted in University life at 9:06 pm by ducky

I’m in a bad mood. I’m really struggling with an assignment to factor large integers.

Problem #1: it’s a boring problem. It’s been done a million times before, so I’m not contributing a bit to the state of knowledge.

Problem #2: It’s really nit-picky stuff, rife with opportunities to make off-by-one errors.  I miss Smalltalk, where it was almost impossible to make off-by-one errors.

Problem #3: The stuff I have to do is boring. In order to deal with large integers you have to use a more complex data structure. That means that there are suddenly a huge number of simple things that you can’t do simply any more. Instead of

int x = 2;
int foo;
foo = x + 3;
cout << foo;

you have to say

mpz_t x;
mpz_t foo;
mpz_set_ui(x, 2);
mpz_add_ui (foo, x, 3);
cout << mpz_get_str (NULL, 10, foo);

Now, I understand perfectly well why it has to look like that, but boy, it sure isn't pleasant. Furthermore, this class is on parallel algorithms, NOT on big numbers. I do need to be able to pack and unpack big numbers to send them around the network to different computers, but knowing how to do mpz_inits doesn't seem to be particularly important in the grand scheme of things.

Problem #4 -- and this might be the biggest problem -- is that I've been too stupid to dump this and do something else. It shouldn't be this hard, and it is. I should stop and move on.

Leave a Comment

Comment moderation is enabled. Your comment may take some time to appear.