[Coin-discuss] problem with CoinPackedMatrix

Cynthia Phillips caphill at sandia.gov
Thu Nov 29 11:10:10 EST 2007


In just taking a quick look, the default constructor for a CoinPackedMatrix
creates a column-major matrix and adds, by default, some extra space for the
columns to grow when you resize (setDimensions).  The zero you see is
probably the extra (unused) element in that first column.  Probably
A.getElements()[2] is equal to 5,  since the default extra space is 25% (and
COIN uses the ceiling for sizing).

    - Cindy


On 11/29/07 8:22 AM, "Michal Kaut" <mail at michalkaut.net> wrote:

> Hello,
> 
> I need to add elements to CoinPackedMatrix one by one and while doing
> so, I encountered the following problem:
> -------------------------------------------------
> CoinPackedMatrix A;
> A.setDimensions(2, 3);
> A.modifyCoefficient(1, 1, 3);
> A.modifyCoefficient(1, 2, 5);
> cout << "A(1,1) = " << A.getCoefficient(1, 1) << endl;
> cout << "A(1,2) = " << A.getCoefficient(1, 2) << endl;
> cout << "A has " << A.getNumElements() << " elements:";
> for (int el=0; el<A.getNumElements(); el++)
>      cout << " " << A.getElements()[el];
> cout << endl;
> -------------------------------------------------
> results in:
> A(1,1) = 3
> A(1,2) = 5
> A has 2 elements: 3 0
> 
> In other words, there seems to be a problem with the element_ member.
> Is this a bug, or just my misunderstanding of things?
> 
> Thanks a lot in advance.
> 
> 
> Regards,
> Michal Kaut
> 
> 
> PS: I originally posted this to coinutils at list.coin-or.org, but then I
> noticed that it is the first post since August. Is that forum obsolete?
> (Even the CoinUtils web page has a link to this forum, not coinutils@)
> _______________________________________________
> Coin-discuss mailing list
> Coin-discuss at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/coin-discuss
> 





More information about the Coin-discuss mailing list