(j3.2006) If SIZE(B) > SIZE(A), what part of B does RESHAPE(B, SHAPE(A)) contain, if both A, B are rank N arrays ?
Robert Corbett
robert.corbett
Sun Dec 11 19:01:26 EST 2011
On 12/10/2011 6:31 AM, John Reid wrote:
>
>
> Toon Moene wrote:
>> On 12/09/2011 09:13 PM, Robert Corbett wrote:
>>
>>> The intrinsic RESHAPE does not do what you want. The code you
>>> presented can be simplified. Try
>>>
>>> A = B( : SIZE(A, 1) - LBOUND(B, 1) + 1, &
>>> : SIZE(A, 2) - LBOUND(B, 2) + 1, &
>>> : SIZE(A, 3) - LBOUND(B, 3) + 1, &
>>> : SIZE(A, 4) - LBOUND(B, 4) + 1)
>>>
>>> OSS Fortran will have an easier time generating code for the
>>> revised version. I suspect other compilers will as well.
>>
>> Thanks - and as a bonus, it gets rid of the auxiliary array ISHAPE
>> (which I wouldn't have needed if the SHAPE intrinsic had an optional DIM
>> argument).
>
>
> Haven't you got the signs wrong here? Don't you mean
>
> A = B( : LBOUND(B, 1) + SIZE(A, 1) - 1, &
> : LBOUND(B, 2) + SIZE(A, 2) - 1, &
> : LBOUND(B, 3) + SIZE(A, 3) - 1, &
> : LBOUND(B, 4) + SIZE(A, 4) - 1)
You are correct. My simplified code is equivalent to the
code that was originally presented. I should have checked
that the original code was correct.
Bob Corbett
More information about the J3
mailing list