![]() |
Blitz Support : |
From: Todd Veldhuizen (tveldhui_at_[hidden])
Date: 2003-11-20 09:18:19
Hi Shunji,
Making a tinyvector of arrays is probably not a great idea, because
the array handles are going to be passed around as values a lot..
It's hard to imagine this representation could be very efficient.
As you say, Array<TinyVector<float,3>,2> is probably the way to
go.
As to why the code below doesn't work: if you run it with BZ_DEBUG
you should get an error. Inside the constructor to TinyVector
you use, is the following code:
TinyVector(T_numtype x0, T_numtype x1)
{
data_[0] = x0;
data_[1] = x1;
}
data_[0] in your case would be an uninitialized 0x0 array, to which
is being assigned a 64x64 array -- this will cause an error.
Cheers,
Todd
On Thu, 20 Nov 2003, Shunji Satoh wrote:
> Dear all,
>
> I am now engaged in image processing using Blitz++
> and wrote a simple code:
> ----
> #include <blitz/tinyvec.h>
> #include <blitz/array.h>
>
> using namespace std;
> using namespace blitz;
>
> int main()
> {
> // a gray-scale 64x64 image
> Array<float,2> image(64,64);
>
> // a vector image initialzed by the 64x64 image.
> TinyVector< Array<float,2> ,2 > vectorImage(image, image);
>
> cout << vector[0].size() << endl; // it would be equal to 64*64 = 4096
> cout << vector[1].size() << endl; // it would be equal to 64*64 = 4096
> }
> ----
> I hope the code outputs "4096" and "4096",
> but the actual outputs were "0" and "0".
>
> As shown in the section 5.1.1 of the manual, another representation of a vector image
> Array<TinyVector<float,3>,2> vectorImage(64,64);
> works well.
>
> What is wrong of my code?
>
> # the version of g++ is 3.0.4,
> # OS is Debian GNU/Linux
>
> Shunji Satoh
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
>
-- Todd Veldhuizen / tveldhui_at_[hidden] / Indiana University Computer Science