Blitz logo

Blitz Support :

From: Julian C. Cummings (cummings_at_[hidden])
Date: 2004-09-16 15:43:47


Hi Patrick,

OK, I believe I have discovered the root of this problem and how to fix it.
The issue is the difference between the "data" pointers in MemoryBlock and
MemoryBlockReference (which is a base class for Array). The data pointer in
MemoryBlock points to the beginning of the usable portion of an allocated
block of memory. The data pointer in the class MemoryBlockReference points
to element (0,0,...,0) of an allocated Array. If you create a new
MemoryBlock from scratch and reference it, then these pointers are
identical. They would differ if you took a slice of an existing Array. The
MemoryBlock would be the same but the zeroth element could be in a different
place in the subarray than in the original Array. If you are creating a
MemoryBlockReference from an existing MemoryBlockReference, you should copy
the data pointer from the MemoryBlockReference, not from the MemoryBlock.
This is being done incorrectly in several places within <blitz/memblock.h>.

After repairing the memblock.h file, the interlace test works once again.
And we don't need to reintroduce the line I commented out in
<blitz/array/methods.cc>. I will make the necessary changes in the cvs
repository.

Regards, Julian C.

Dr. Julian C. Cummings
Staff Scientist, CACR/Caltech
(626) 395-2543
cummings_at_[hidden]
 

> -----Original Message-----
> From: blitz-support-bounces_at_[hidden]
> [mailto:blitz-support-bounces_at_[hidden]] On Behalf Of
> Patrick Guio
> Sent: Sunday, September 12, 2004 9:41 AM
> To: Julian Cummings
> Cc: 'Support list for Blitz++'
> Subject: [Blitz-support] interlaceArrays broken
>
>
>
>
> Hi Julian,
>
> I ran the testsuite recently and found that the
> testsuite/interlace.cpp
> is broken.
> I tracked back the problem and it looks like the
> "subarray.reference(tmp)"
> is not done correctly in the makeInterlacedArray() at line 81 in
> blitz/array/interlace.cc
> Reintroducing the commented line (at line 213) in
> blitz/array/methods.cc:
> data_ = const_cast<P_numtype*>(array.data_);
> fixes the problem for interlace.cpp.
> but as your comment suggests:
> // JCC: changeBlock() already resets the data_ pointer to
> zeroth element it should already be done already in the call
> to changeBlock() at line 332
> in blitz/memblock.h:
> data_ = block_->data() + offset;
> What do you think?
> Cheers, Patrick
>
>
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
>