![]() |
Blitz Support : |
From: Julian Cummings (cummings_at_[hidden])
Date: 2003-04-25 13:55:13
Hello Einar,
I think you may have misunderstood the blitz documentation on slicing
(section 2.4.4).
A combination of Range and integer operands with Array indexing produces
a slice,
and each *integer* operand reduces the Array rank by one. The partial
ordering feature,
which the current gcc compiler has, is required to use Range and integer
operands in
combination like this. If you didn't have partial ordering, you would
have to use a
Range argument with length 1 as you did in your example below. The
problem is,
that does not reduce the Array rank by one. You still have a 2d Array,
which you cannot
use to initialize a 1d Array. The solution is to replace your
"threeRange" argument with
the integer value 3.
Regards, Julian C.
Einar Otnes wrote:
> I have just installed blitz-20021003 on my computer with RH9.0 and it
> appears that my installation of Blitz does not support
> BZ_PARTIAL_ORDERING even if its defined in config.h. I'm not allowed
> to slice an array down a dimension like the code below. It won't compile.
> For compilation I use g++ -o main main.cpp
> -I/usr/local/Blitz++/gcc/include -L/usr/local/Blitz++/gcc/lib -lblitz
>
> If I change the dimension of junk1 from 1 to 2, everything works ok.
>
> If I recall correctly I haven't experienced these problems before with
> earlier versions of gcc, am I right?
>
> thanks, Einar Otnes
>
>
> #include <blitz/array.h>
> #include <iostream>
>
> using namespace std;
> using namespace blitz;
>
> int main()
> {
> Array<float,2> junk2(5,5);
> junk2 = 1.0f;
>
> Range threeRange = Range(3,3);
> Range allRange = Range::all();
>
> Array<float,1> junk1(junk2(allRange,threeRange));
>
> cerr << " junk2 = " << junk2 << endl;
> cerr << " junk1 = " << junk1 << endl;
>
> return EXIT_SUCCESS;
> }
>
>
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
-- Dr. Julian C. Cummings E-mail: cummings_at_[hidden] California Institute of Technology Phone: 626-395-2543 1200 E. California Blvd., Mail Code 158-79 Fax: 626-584-5917 Pasadena, CA 91125