- Jun 16, 2004
- 1,034
- 0
- 0
Hi guys,
A very general question here. I'm trying to write an algorithm using matrices in Python/Numpy where I'm manipulating the values of cells surrounding a given cell (sorta similar to the Game of Life). My question is, is it better to create a single algorithm to deal with the values of surrounding cells and catch index out of range exceptions, or should I code a specific algorithm for each corner, and for the various sides of the matrix?
I understand that catching exceptions is "expensive" as far as computer time goes, but do you think it would matter in this type of instance? We're talking about matrices ranging from 90 x 140 to maybe 300 x 300.
My guess is that you'll say I should just create the general algorithm, but I'd just like the confirmation.
Thanks from the programing newbie....
A very general question here. I'm trying to write an algorithm using matrices in Python/Numpy where I'm manipulating the values of cells surrounding a given cell (sorta similar to the Game of Life). My question is, is it better to create a single algorithm to deal with the values of surrounding cells and catch index out of range exceptions, or should I code a specific algorithm for each corner, and for the various sides of the matrix?
I understand that catching exceptions is "expensive" as far as computer time goes, but do you think it would matter in this type of instance? We're talking about matrices ranging from 90 x 140 to maybe 300 x 300.
My guess is that you'll say I should just create the general algorithm, but I'd just like the confirmation.
Thanks from the programing newbie....
