[Coin-discuss] possible error in CoinPackedVector.hpp (fwd)

Sven de Vries devries at ma.tum.de
Sun Jun 6 12:58:31 EDT 2004


Hi,

I'm sorry to remind of this, but could anybody confirm this error and be
so kind to check in a fixed version? or does the function behave as
intended?

sincerely,
Sven


---------- Forwarded message ----------
Date: Wed, 26 May 2004 18:33:11 +0200 (MEST)
From: Sven de Vries <devries at ma.tum.de>
Reply-To: coin-discuss at www-124.southbury.usf.ibm.com
To: coin-discuss at www-124.southbury.usf.ibm.com
Subject: [Coin-discuss] possible error in CoinPackedVector.hpp

Hi,

we noticed the "feature" that when an empty and a nonempty
coinpackedvector are added, then the resulting vector is always the empty
vector.

looking at the source:

l360 CoinPackedVector.hpp

template <class BinaryFunction> void
binaryOp(CoinPackedVector& retVal,
	 const CoinPackedVectorBase& op1, const CoinPackedVectorBase& op2,
	 BinaryFunction bf)
{
   retVal.clear();
   const int s1 = op1.getNumElements();
   const int s2 = op2.getNumElements();
   if (s1 == 0 || s2 == 0)
      return;


...

it seems to me, that the last if-statement is the culprit (at least if
bf=addition).

for a second (thinking of bf= +) the following looked like a fix,
 if (s1 == 0){
	retVal=s2;
      return; }
 elseif (s2==0){
	retVal=s1;
	return;}

BUT this is only correct for bf= + and false if bf is multiplication.

Hence I think the only remedy is to remove this if-statement entirely.

sven
_______________________________________________
Coin-discuss mailing list
Coin-discuss at www-124.ibm.com
http://www-124.ibm.com/developerworks/oss/mailman/listinfo/coin-discuss



More information about the Coin-discuss mailing list