|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Wed Jun 03, 2015 3:42 pm Post subject: |
|
|
Thanks for the feedback. I have logged this for investigation. |
|
Back to top |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Thu Jun 04, 2015 6:08 am Post subject: |
|
|
Thanks. I have logged this also. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Tue May 24, 2016 12:39 pm Post subject: |
|
|
The MATMUL bug has now been fixed for the next release. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 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. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 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. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|