[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## efficiently modifying a 0-1 matrix for a fixed row sum

**From**: |
Mike B. |

**Subject**: |
efficiently modifying a 0-1 matrix for a fixed row sum |

**Date**: |
Mon, 6 Sep 2010 20:35:29 -0700 (PDT) |

Hi All,
I have a matrix of 0-1 elements which are randomly distributed.
I need to modify the matrix such that each row has exacly the same sum, for
example, assuming the target sum is 2 and the initial matrix is
0 1 0 (sum=0, too low)
1 1 1 (sum=3, too high)
one possible outcome is
1 1 0 (sum=2)
1 0 1 (sum=2)
Any way to avoid slow for loops?.
Thanks,
Mike.

**efficiently modifying a 0-1 matrix for a fixed row sum**,
*Mike B.* **<=**