forums.silverfrost.com
Welcome to the Silverfrost forums

Author Message
mecej4

Joined: 31 Oct 2006
Posts: 1875

Posted: Wed Jun 03, 2015 2:14 pm    Post subject: MATMUL bug

This is a simplified version of a bug reported by AntonioGJerez in http://forums.silverfrost.com/viewtopic.php?p=18250#18250 . FTN95 7.10 gives wrong results when MATMUL is invoked with a single-precision complex argument and a double-precision real argument. Here is an example in which MATMUL is used to evaluate the outer product of vectors B and C, where B is represented as a 2 X 1 double-precision matrix and C as a 1 X 2 single-precision complex matrix. The bug does not occur if B is made single-precision.
 Code: program MatmulBug implicit none double precision B(2,1) complex C(1,2) ! B=dble(reshape((/1.,2./),(/2,1/))) C=cmplx(reshape((/1.,3./),(/1,2/))) ! write(*,*)'B = ',B write(*,*)'C = ',C write(*,*)'B X C = ',matmul(B,C) end program

FTN95 gives the product as (in usual Fortran 2-D array order) [(0,1.875), (0,3.75), (0,2.125), (0,4.25)], instead of the correct result, [(1,0), (2,0), (3,0), (6,0)].

[P.S., 15 June 2015: This bug is also present in FTN95-7.20]

Last edited by mecej4 on Mon Jun 15, 2015 11:01 pm; edited 4 times in total
PaulLaidler

Joined: 21 Feb 2005
Posts: 7874
Location: Salford, UK

 Posted: Wed Jun 03, 2015 3:42 pm    Post subject: Thanks for the feedback. I have logged this for investigation.
AntonioGJerez

Joined: 01 Jun 2015
Posts: 9
Location: Spain

 Posted: Thu Jun 04, 2015 12:39 am    Post subject: real*8 to complex Hello, This is another simple example of conversion from real*8 to complex that doesn´t work (and no warning or error is displayed) regards program bug3 COMPLEX A(4,4) REAL*8 B(4,4) PRINT*,'This runs ok' B=RESHAPE((/1.d0,0.d0,0.d0,0.d0, 0.d0,1.d0,0.d0,0.d0,0.d0,0.d0,1.d0,0.d0, 0.d0,0.d0,0.d0,1.d0/),(/4,4/)) print*,B print*,CMPLX(B) PRINT* PRINT*,'This doesn´t run ok' print*,CMPLX(RESHAPE((/1.d0,0.d0,0.d0,0.d0, 0.d0,1.d0,0.d0,0.d0,0.d0,0.d0,1.d0,0.d0, 0.d0,0.d0,0.d0,1.d0/),(/4,4/))) PRINT* PRINT*,'This doesn´t run ok' A=CMPLX(RESHAPE((/1.d0,0.d0,0.d0,0.d0, 0.d0,1.d0,0.d0,0.d0,0.d0,0.d0,1.d0,0.d0, 0.d0,0.d0,0.d0,1.d0/),(/4,4/))) print*,A end program
PaulLaidler

Joined: 21 Feb 2005
Posts: 7874
Location: Salford, UK

 Posted: Thu Jun 04, 2015 6:08 am    Post subject: Thanks. I have logged this also.
PaulLaidler

Joined: 21 Feb 2005
Posts: 7874
Location: Salford, UK

 Posted: Tue May 24, 2016 12:39 pm    Post subject: The MATMUL bug has now been fixed for the next release.
PaulLaidler

Joined: 21 Feb 2005
Posts: 7874
Location: Salford, UK

Posted: Tue May 24, 2016 2:01 pm    Post subject:

Using CMPLX on a RESHAPEd REAL array does not work at the moment.
Pending a fix you could write...

 Code: COMPLEX A(4,4) A=RESHAPE((/1.0,..../),(/4,4/))

That is, remove the call to CMPLX and allow the type conversion to take place across the assignment.
PaulLaidler

Joined: 21 Feb 2005
Posts: 7874
Location: Salford, UK

 Posted: Tue Mar 12, 2019 11:01 am    Post subject: The two bugs illustrated in AntonioGJerez's code have been fixed for the next release of FTN95.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT + 1 Hour Page 1 of 1