[Lapackpp-devel] Re: bugs in reference counting in vd.{cc,h}?
Status: Beta
Brought to you by:
cstim
From: Christian S. <sti...@tu...> - 2005-09-13 09:09:22
|
Dear Brian, Brian White schrieb: > I may have another bug. I can't pinpoint exactly what the problem is, but > I can manifest it repeatedly and I can fix it. :) > > I've included a program called manifestMemProb.C, which is similar to the > last program I sent out. It creates two different views of a matrix (plus > the original) and modifies them. It does the same procedure on a > different matrix. Somehow, the second matrix is being corrupted, as you > can see in the file manifestMemProb.incorrect. No, there is not a bug. Instead, it seems you didn't understand the implications of the LaGenMatDouble constructor that you used. The LaGenMatDouble(int, int) constructor clearly states: "Matrix elements are NOT initialized!" (see http://lapackpp.sourceforge.net/html/classLaGenMatDouble.html#z41_1 ) -- and that is precisely what you see here. If you want an all-zero matrix, you need to do LaGenMatDouble A(10,10); A = 0.0; The reason for this is that the extra initialization (setting all elements to zero) can be an expensive operation (think of a 1e5x1e5 matrix), and it really depends on the application whether this is really needed. Therefore the standard constructor will only allocate the memory, but the values inside that memory can be anything. It is just pure coincidence that the first matrix in your test program happened to contain "almost" zeros. Lapackpp is explicitly intended for "high-performance linear algebra", and in that field you really need to think for yourself about which prerequisites you depend on and which you don't. The library will give you many choices, especially all the high-performance choices. Construction without initialization clearly is one of those choices. Christian |