forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MATMUL bug

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Jun 03, 2015 2:14 pm    Post subject: MATMUL bug Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Jun 03, 2015 3:42 pm    Post subject: Reply with quote

Thanks for the feedback. I have logged this for investigation.
Back to top
View user's profile Send private message AIM Address
AntonioGJerez



Joined: 01 Jun 2015
Posts: 9
Location: Spain

PostPosted: Thu Jun 04, 2015 12:39 am    Post subject: real*8 to complex Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Jun 04, 2015 6:08 am    Post subject: Reply with quote

Thanks. I have logged this also.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Tue May 24, 2016 12:39 pm    Post subject: Reply with quote

The MATMUL bug has now been fixed for the next release.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Tue May 24, 2016 2:01 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Tue Mar 12, 2019 11:01 am    Post subject: Reply with quote

The two bugs illustrated in AntonioGJerez's code have been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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