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.