Page 1 of 1

Question on function ZLANHE

PostPosted: Fri Aug 22, 2014 5:03 am
by mk0511
Hi,

Quick question on the above function; between the line 196 and 204, it looks to me that the workspace has not been initialised to zero before being used. Is this the correct behaviour ?

Regards
MK

Re: Question on function ZLANHE

PostPosted: Mon Jun 29, 2015 8:49 am
by akobotov
LAPACKers,

Please apply the fix from r1474 to ZLANHE and CLANHE as well. This will correct the mentioned issue.
As I see the issue is fixed for ?LANSY on the revision, but the fix is missed for ?LANHE.

Best regards,
Alexander

Re: Question on function ZLANHE

PostPosted: Mon Jun 29, 2015 9:56 am
by Julien Langou
Hi MK, Hi Alex,

The code reads as
Code: Select all
            DO 60 J = 1, N
               SUM = ZERO
               DO 50 I = 1, J - 1
                  ABSA = ABS( A( I, J ) )
                  SUM = SUM + ABSA
                  WORK( I ) = WORK( I ) + ABSA
   50          CONTINUE
               WORK( J ) = SUM + ABS( DBLE( A( J, J ) ) )
   60       CONTINUE


The outer j-loop runs from 1 to N and initialize WORK(J).
The inner i-loop runs from 1 to J-1 and uses (and updates) WORK(I).
As a consequence, whenever WORK(I) is used, it has already been initialized by the j-loop.

In exit of these two loops, WORK(J) will contain the sum of the absolute value of the column J of A.

At step J, the i-loop accumulated from A(1,J) to A(J-1,J) in SUM, the lines of codes are
Code: Select all
               SUM = ZERO
               DO 50 I = 1, J - 1
                  ABSA = ABS( A( I, J ) )
                  SUM = SUM + ABSA
   50          CONTINUE

then we add A(J,J) as well
Code: Select all
               WORK( J ) = SUM + ABS( DBLE( A( J, J ) ) )

(Note: this initializes WORK( J ).) We are missing A(J+1,J) to A(N,J). We access them in row J with A(J,J+1) to A(J,N) and add them with the i-loop with the line
Code: Select all
                  WORK( I ) = WORK( I ) + ABSA


Cheers,
Julien and Mathieu.

Re: Question on function ZLANHE

PostPosted: Tue Jun 30, 2015 4:56 am
by chereshnev
Hi,

I found revision with fixes of xlansy routines with the similar fix. But they contains the same loops in the case uplo = "U"
So WORK array has already been initialized without previous loop with zeroing and these changes can be safely reverted.

Revision: 1474
Author: julie
Date: 15 Feb 2014 4:13:20
Message:
Fix potential initiation issue in (c,d,s,z)lansy.f
Bug report sent from Elena Ivanova on Feb 2014

Array WORK is initialized with ZERO when 'L' and is not initialized when 'U'.
There can be some garbage in WORK. Move up the initialization of WORK before the line
IF( LSAME( UPLO, 'U' ) ) THEN.

Rearrange loop ordering numbers.
----
Modified : /lapack/trunk/SRC/clansy.f
Modified : /lapack/trunk/SRC/dlansy.f
Modified : /lapack/trunk/SRC/slansy.f
Modified : /lapack/trunk/SRC/zlansy.f

Re: Question on function ZLANHE

PostPosted: Tue Jun 30, 2015 7:42 am
by Julien Langou
Hi Eugene, you are correct. I just reverted to the previous version and consequently removed the changes made in rev 1474. Julien.