#NEWLINE# def create_bandmat( self ) : #NEWLINE# #INDENT# 'Create the full matrix `self.fullmat` and\n           the corresponding band matrix `self.bandmat`.' #NEWLINE# N = 10 #NEWLINE# self . KL = 2 #NEWLINE# self . KU = 2 #NEWLINE# self . sym_mat = ( ( ( ( diag ( ( 1.0 * ones ( N ) ) ) + diag ( ( ( - 1.0 ) * ones ( ( N - 1 ) ) ) , ( - 1 ) ) ) + diag ( ( ( - 1.0 ) * ones ( ( N - 1 ) ) ) , 1 ) ) + diag ( ( ( - 2.0 ) * ones ( ( N - 2 ) ) ) , ( - 2 ) ) ) + diag ( ( ( - 2.0 ) * ones ( ( N - 2 ) ) ) , 2 ) ) #NEWLINE# self . herm_mat = ( ( ( ( diag ( ( ( - 1.0 ) * ones ( N ) ) ) + ( 1j * diag ( ( 1.0 * ones ( ( N - 1 ) ) ) , ( - 1 ) ) ) ) - ( 1j * diag ( ( 1.0 * ones ( ( N - 1 ) ) ) , 1 ) ) ) + diag ( ( ( - 2.0 ) * ones ( ( N - 2 ) ) ) , ( - 2 ) ) ) + diag ( ( ( - 2.0 ) * ones ( ( N - 2 ) ) ) , 2 ) ) #NEWLINE# self . real_mat = ( ( ( ( diag ( ( 1.0 * ones ( N ) ) ) + diag ( ( ( - 1.0 ) * ones ( ( N - 1 ) ) ) , ( - 1 ) ) ) + diag ( ( ( - 3.0 ) * ones ( ( N - 1 ) ) ) , 1 ) ) + diag ( ( 2.0 * ones ( ( N - 2 ) ) ) , ( - 2 ) ) ) + diag ( ( ( - 2.0 ) * ones ( ( N - 2 ) ) ) , 2 ) ) #NEWLINE# self . comp_mat = ( ( ( ( ( 1j * diag ( ( 1.0 * ones ( N ) ) ) ) + diag ( ( ( - 1.0 ) * ones ( ( N - 1 ) ) ) , ( - 1 ) ) ) + ( 1j * diag ( ( ( - 3.0 ) * ones ( ( N - 1 ) ) ) , 1 ) ) ) + diag ( ( 2.0 * ones ( ( N - 2 ) ) ) , ( - 2 ) ) ) + diag ( ( ( - 2.0 ) * ones ( ( N - 2 ) ) ) , 2 ) ) #NEWLINE# ( ew , ev ) = linalg . eig ( self . sym_mat ) #NEWLINE# ew = ew . real #NEWLINE# args = argsort ( ew ) #NEWLINE# self . w_sym_lin = ew [ args ] #NEWLINE# self . evec_sym_lin = ev [ : , args ] #NEWLINE# ( ew , ev ) = linalg . eig ( self . herm_mat ) #NEWLINE# ew = ew . real #NEWLINE# args = argsort ( ew ) #NEWLINE# self . w_herm_lin = ew [ args ] #NEWLINE# self . evec_herm_lin = ev [ : , args ] #NEWLINE# LDAB = ( self . KU + 1 ) #NEWLINE# self . bandmat_sym = zeros ( ( LDAB , N ) , dtype = float ) #NEWLINE# self . bandmat_herm = zeros ( ( LDAB , N ) , dtype = complex ) #NEWLINE# for i in xrange ( LDAB ) : #NEWLINE# #INDENT# self . bandmat_sym [ ( ( LDAB - i ) - 1 ) , i : N ] = diag ( self . sym_mat , i ) #NEWLINE# self . bandmat_herm [ ( ( LDAB - i ) - 1 ) , i : N ] = diag ( self . herm_mat , i ) #NEWLINE# #UNINDENT# LDAB = ( ( ( 2 * self . KL ) + self . KU ) + 1 ) #NEWLINE# self . bandmat_real = zeros ( ( LDAB , N ) , dtype = float ) #NEWLINE# self . bandmat_real [ ( 2 * self . KL ) , : ] = diag ( self . real_mat ) #NEWLINE# for i in xrange ( self . KL ) : #NEWLINE# #INDENT# self . bandmat_real [ ( ( ( 2 * self . KL ) - 1 ) - i ) , ( i + 1 ) : N ] = diag ( self . real_mat , ( i + 1 ) ) #NEWLINE# self . bandmat_real [ ( ( ( 2 * self . KL ) + 1 ) + i ) , 0 : ( ( N - 1 ) - i ) ] = diag ( self . real_mat , ( ( - i ) - 1 ) ) #NEWLINE# #UNINDENT# self . bandmat_comp = zeros ( ( LDAB , N ) , dtype = complex ) #NEWLINE# self . bandmat_comp [ ( 2 * self . KL ) , : ] = diag ( self . comp_mat ) #NEWLINE# for i in xrange ( self . KL ) : #NEWLINE# #INDENT# self . bandmat_comp [ ( ( ( 2 * self . KL ) - 1 ) - i ) , ( i + 1 ) : N ] = diag ( self . comp_mat , ( i + 1 ) ) #NEWLINE# self . bandmat_comp [ ( ( ( 2 * self . KL ) + 1 ) + i ) , 0 : ( ( N - 1 ) - i ) ] = diag ( self . comp_mat , ( ( - i ) - 1 ) ) #NEWLINE# #UNINDENT# self . b = ( 1.0 * arange ( N ) ) #NEWLINE# self . bc = ( self . b * ( 1 + 1j ) )