Hi Gregory, You are touching a slightly weird aspect of Gecode... The choice of int as opposed to unsigned int for the Matrix class is actually deliberate. This choice is not only done for Matrix but for many other datastructures that are defined by Gecode (for example, VarArray, ViewArray, etc). I know that the choice of unsigned int sounds more appealing but we have made the opposite decision and try to be as consistent with the choice of int rather than unsigned int.
There are two reasons. The first is simple and maybe is not even very convincing. The average loop written to iterate over arrays etc is typically an int and not an unsigned int. To avoid compiler warnings, Gecode follows in this. Then, the second reason (possibly not more convincing than the first one) is that integer variables take int values and very often array access is wrt a value included in the domain of an integer variable. Here we go. We tried to use unsigned int but it was in fact just too painful (lots of explicit casts in order to avoid warnings). Changing int to unsigned int and be consistent about that change would be a massive effort with little gain. I know. Sad but true. Cheers Christian -- Christian Schulte, web.ict.kth.se/~cschulte/ -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Gregory Crosswhite Sent: Friday, January 14, 2011 6:26 PM To: [email protected] Subject: [gecode-users] int vs. unsigned int for Matrix dimensions Hey everyone, Is there a reason why the Matrix class uses "int" for the type of its dimensions instead of "unsigned int"? If there isn't a reason not to use "unsigned int" for the type of the dimensions, then may I submit a patch or something to change it to use "unsigned int"? Thanks! Greg _______________________________________________ Gecode users mailing list [email protected] https://www.gecode.org/mailman/listinfo/gecode-users _______________________________________________ Gecode users mailing list [email protected] https://www.gecode.org/mailman/listinfo/gecode-users
