[CoinUtils] CoinPackedMatrix and default extraGap (propose change to zero)

Lou Hafer lou at cs.sfu.ca
Sat Jan 22 14:55:48 EST 2011


Folks,

	The default constructor for CoinPackedMatrix will use .25 for extraMajor
and extraGap.  If one uses the default constructor to initialise a
column-ordered matrix and then later uses, for example, reverseOrderedCopyOf to
make a row-ordered matrix, the row-ordered matrix will have extra space in each
major vector.

	Unfortunately, this will break code that uses the following loop
construct (to traverse major vector i)

	for (CoinBigIndex kk = majStart[i] ; kk < majStart[i+1] ; kk++)

More generally, any code that uses majStart[i+1]-majStart[i] to calculate the
length of a major vector.

	Why am I mentioning this?  Because I've been working on CglProbing and
fell over this bug last evening.  The above construct is common.  My guess is
that this problem also exists in other chunks of COIN code and is an accident
waiting to happen.

	If you look over the constructors for CoinPackedMatrix, of the ones that
do not have explicit gap parameters, only the default constructor sets nonzero
values for the gaps.  I'm proposing to change this so that the default
constructor also sets zero gaps.

	This isn't a fix for code that assumes no gaps (the only way to fix the
code is to find it and rewrite it) but it will remove a trap for the unwary.

	Opinions?  If I hear no objections by the 29th, I'm going to make this
change so that the constructor behaviour is uniform.

							Lou



More information about the CoinUtils mailing list