1 %======================================================================
2 % Test
function for the MEX file zgetPartialInv.
3 % Copyright (C) 2009-2015 Peter Rakyta, Ph.D.
5 % This program is free software: you can redistribute it and/or modify
6 % it under the terms of the GNU General Public License as published by
7 % the Free Software Foundation, either version 3 of the License, or
8 % (at your option) any later version.
10 % This program is distributed in the hope that it will be useful,
11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 % GNU General Public License
for more details.
15 % You should have received a copy of the GNU General Public License
16 % along with
this program. If not, see http:
20 filename = mfilename(
'fullpath');
21 [directory, fncname] = fileparts( filename );
22 fncname = fncname(1:end-length(
'_test'));
23 filename = fullfile( directory, [fncname,
'.', mexext] );
26 %% creating the
test Hamiltonian
39 CreateH.CreateScatterH();
41 Hscatter = CreateH.Read(
'Hscatter');
42 CreateH.Clear(
'Hscatter');
44 display(
'***************************************************************************')
45 display(['The size of the
test matrix is :', num2str(size(Hscatter,1)), 'x', num2str(size(Hscatter,1))])
47 %% Calculeting the surface Green
function 49 % reordering the matrix coupling the surface
sites to the right-lower corner of the matrix
50 M = CreateH.Read('M');
51 surface_sites = false(size(Hscatter,1),1);
52 surface_sites(1:M) = true;
53 surface_sites(end-M+1:end) = true;
55 Hscatter = [ Hscatter(~surface_sites, ~surface_sites), Hscatter(~surface_sites, surface_sites);
56 Hscatter(surface_sites, ~surface_sites), Hscatter(surface_sites, surface_sites) ];
58 % adding Complex Eenrgy
59 Hscatter = speye(size(Hscatter))*0.5*1i - Hscatter;
61 % Test using the mdivide method
63 display('Calculating the surface Green
function with the mldivide operator:')
65 evec = sparse( size(Hscatter,1)-2*M+1:size(Hscatter,1), 1:2*M, 1, size(Hscatter,1), 2*M);
67 G = G(end-2*M+1:end, :);
71 % Test using the partialInv method
73 display('Calculating the surface Green
function with the zgetPartialInv utility:')
76 GpartialInv = zgetPartialInv( Hscatter, 2*M );
79 warning([fncname, ' failed to run. Deleting the compiled MEX file.']);
81 disp( err.identifier )
87 error_num = norm( G-GpartialInv);
89 display('***************************************************************************')
90 disp(['Test of ', fncname, ' passed.'])
92 warning(['Test of ', fncname, ' failed with an error ', num2str(error_num), '. Deleting the compiled MEX file.'])
Lattice_Type
String describing the preprogrammed lattice type. See the documentation of lattice types for details.
function test(arg1, arg2)
Brief description of the function.
Structure Opt contains the basic computational parameters used in EQuUs.
function zgetPartialInv_test()
Structure param contains data structures describing the physical parameters of the scattering center ...
scatter_param scatter
An instance of the structure scatter_param containing the physical parameters for the scattering regi...
Structure sites contains data to identify the individual sites in a matrix.
Class containing physical parameters of a scattering center defined on a square lattice.
function structures(name)
A class to create and store Hamiltonian of the scattering region.