lederhosen: (Default)
[personal profile] lederhosen
Thought this might entertain the geeks here.

My co-worker Simon is working on something or other in MATLAB. As part of a long and complicated program, he needs to invert a vector X (i.e. swap entries from top to bottom).

It's not a complicated operation. I don't recall exactly how he did it, but I'd guess something like "for i = 1 to 0.5*size(X), swap entries 'i' and (size(X)+1-i)".

But when he ran it, X just wouldn't invert. He looked through the code, checked the bit where he inverts X, cleaned up a few things that shouldn't make any difference, and ran it again.

Still not inverting.

Looked through the code again. Checking, checking... yup, that should do it. But still not inverting.

When he finally figured out what the problem was, he asked me to take him outside and shoot him... see if you can guess, before peeking at the answer.

As a clue, the part of the program that was supposed to invert the vector wasn't, in itself, flawed.



The problem was that near the start of the program he'd very carefully written code to invert the vector.

Then, later on, he'd forgotten that he'd inverted it, and written code to invert it again.

When you invert a vector twice...

Date: 2003-11-30 10:54 pm (UTC)
From: [identity profile] silmaril.livejournal.com
*get piece of icecream in wrong tube, cough while attempting to laugh still*

And here I was thinking more simplistic thoughts like "freaky symmetric vector with odd-numbered elements"...

Date: 2003-12-01 03:14 am (UTC)
From: [identity profile] harliquinn.livejournal.com
Sounds like something I would have done!

Date: 2003-12-01 01:13 pm (UTC)
From: [identity profile] theonementat.livejournal.com
What's you vector Victor?

Date: 2003-12-01 04:08 pm (UTC)
From: [identity profile] turnberryknkn.livejournal.com
LOL!

That's just beautiful. :-)

Profile

lederhosen: (Default)
lederhosen

July 2017

S M T W T F S
      1
2345678
9101112131415
16171819202122
2324252627 2829
3031     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 28th, 2025 06:15 am
Powered by Dreamwidth Studios