Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
dggev_test.m
Go to the documentation of this file.
1 %======================================================================
2 % Test function for the MEX file dggev generated from the LAPACKE package.
3 % (See: http://www.netlib.org/lapack/explore-html/de/d27/lapacke__dggev_8c.html for details)
4 % Copyright (C) 2009-2015 Peter Rakyta, Ph.D.
5 %
6 % This program is free software: you can redistribute it and/or modify
7 % it under the terms of the GNU General Public License as published by
8 % the Free Software Foundation, either version 3 of the License, or
9 % (at your option) any later version.
10 %
11 % This program is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 % GNU General Public License for more details.
15 %
16 % You should have received a copy of the GNU General Public License
17 % along with this program. If not, see http://www.gnu.org/licenses/.
18 function dggev_test()
19 
20  % test matrices
21  dim = 40;
22  A = rand(dim);
23  B = rand(dim);
24 
25 
26  filename = mfilename('fullpath');
27  [directory, fncname] = fileparts( filename );
28  fncname = fncname(1:end-length('_test'));
29  filename = fullfile( directory, [fncname, '.', mexext] );
30 
31 
32  % Call the newly compiled function.
33  try
34  [ALPHAR, ALPHAI,BETA,lvec,rvec] = feval(fncname, A, B);
35  catch err
36  warning([fncname, ' failed to run. Deleting the compiled MEX file.']);
37  delete(filename);
38  disp( err.identifier )
39  disp( err.message )
40  pause(3)
41  return
42  end
43 
44  %test the calculated eigenvalues
45  eig_values = eig(A,B);
46 
47  error_num = norm( abs(sort(eig_values, 'ascend')) - abs(sort((ALPHAR+1i*ALPHAI)./BETA, 'ascend')) );
48  if error_num < 1e-10
49  display('***************************************************************************')
50  disp(['Test of ', fncname, ' passed.'])
51  else
52  warning(['Test of ', fncname, ' failed with an error ', num2str(error_num), '. Deleting the compiled MEX file.'])
53  %delete(filename);
54  return
55  end
56 
57 
58 end
function dggev_test()
function test(arg1, arg2)
Brief description of the function.