in reply to Re^5: Can I speed this up? (repetitively scanning ranges in a large array)
in thread Can I speed this up? (repetitively scanning ranges in a large array)

Of course I can use the modulo operator (and I sure do). Anyway, this is a matter of taste. I originally used something like you suggested but later found it more convenient to have $genome$i always refer to genomic position $i, regardless if the genome is linear or circular (I have both kinds).

I don't think I pay any performance price and it's more straightforward for me to be consistent with the biological conventions.

  • Comment on Re^6: Can I speed this up? (repetitively scanning ranges in a large array)

Replies are listed 'Best First'.
Re^7: Can I speed this up? (repetitively scanning ranges in a large array)
by ikegami (Patriarch) on Nov 03, 2010 at 19:07 UTC

    Of course I can use the modulo operator (and I sure do).

    I suppose you're right. It'll just look like

    (x - 1) % size + 1
    instead of
    x % size

    I don't think I pay any performance price

    Well, there are more ops, but the real cost is the complexity and clarity due to working with off-by-one numbers (first element of genome in second element of array).