Van Snyder wrote:
> I've tried the following program with two compilers. I think they both
> get the "wrong" answers for P1 and P2. Neither one reports an error at
> compile- or run-time. I've reported to the vendors.
>
> Maybe it's my mistake.
>
> I think P1 should be
> 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44
> and P2 should be
> 1 5 9 13
> 2 6 10 14
> 3 7 11 15
> 4 8 12 16
>
> 1. What do you think the "right" answers are for P1 and P2?
> 2. Do you have a compiler that does what you (or I) expect?
>
> Best regards,
> Van Snyder
I've tried two compilers - the results are:
DEC Alpha wiht Digital Unix 4.0:
P1 => res(reshape(t2,(/16/))) =
11 21 31 41 12 22 32 42 13 23 33 43 14 24 34 44
P2 => res(reshape(t1,(/4,4/))) =
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
SHAPE(P1) = 16
SHAPE(P2) = 4 4
SGI Octane with IRIX 6.4:
P1 => res(reshape(t2,(/16/))) =
9 2 16 4 8 6*** 8 8 10*** 12 8 14*** 16
P2 => res(reshape(t1,(/4,4/))) =
9 8 8 8
2 6 10 14
-1*********
4 8 12 16
SHAPE(P1) = 16
SHAPE(P2) = 2*4
I think the DEC compiler does the right thing...
I'm of the opinion that Van made a litte mistake in defining the array T2.
The definition must be: T2(4,4) = reshape( (/ ((10*i+j,j=1,4),i=1,4) /),
(/4,4/) )
instead of: T2(4,4) = reshape( (/ ((10*i+j,i=1,4),j=1,4)
/), (/4,4/) )
The result is like the expected...
Best regards
Dominik
--
_______________________________________________________________________
Dominik Sadnik
Graz University of Technology phone : ++43 (0)316 873 7578
Institute for Hydraulic Fluidmachinery fax : ++43 (0)316 873 7577
A-8010 Graz, Kopernikusgasse 24/IV mobile: ++43 (0)676 36 50 430
mailto:[log in to unmask] http://www.hfm.tu-graz.ac.at
_______________________________________________________________________
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|