#NEWLINE# def c_he_tridiag_1( ctx , A , T ) : #NEWLINE# #INDENT# '\n    This routine forms the unitary matrix Q described in c_he_tridiag_0.\n\n    parameters:\n      A    (input/output) On input, A is the same matrix as delivered by\n           c_he_tridiag_0. On output, A is set to Q.\n\n      T    (input) On input, T is the same array as delivered by c_he_tridiag_0.\n\n    ' #NEWLINE# n = A . rows #NEWLINE# for i in xrange ( 0 , n ) : #NEWLINE# #INDENT# if ( A [ ( i , n ) ] != 0 ) : #NEWLINE# #INDENT# for j in xrange ( 0 , i ) : #NEWLINE# #INDENT# G = 0 #NEWLINE# for k in xrange ( 0 , i ) : #NEWLINE# #INDENT# G += ( ctx . conj ( A [ ( i , k ) ] ) * A [ ( k , j ) ] ) #NEWLINE# #UNINDENT# for k in xrange ( 0 , i ) : #NEWLINE# #INDENT# A [ ( k , j ) ] -= ( G * A [ ( k , i ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# A [ ( i , i ) ] = 1 #NEWLINE# for j in xrange ( 0 , i ) : #NEWLINE# #INDENT# A [ ( j , i ) ] = A [ ( i , j ) ] = 0 #NEWLINE# #UNINDENT# #UNINDENT# for i in xrange ( 0 , n ) : #NEWLINE# #INDENT# for k in xrange ( 0 , n ) : #NEWLINE# #INDENT# A [ ( i , k ) ] *= T [ k ]