1//<-- CLI SHELL MODE -->
2// =============================================================================
3// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4// Copyright (C) ????-2008 - INRIA
5//
6//  This file is distributed under the same license as the Scilab package.
7// =============================================================================
8function r=Err(x),r=norm(x,1),endfunction
9rand('normal')
10
11//==========================================================================
12//==============================     hess     ==============================
13//==========================================================================
14
15//Empty matrix
16if hess([])<>[] then pause,end
17[U,H]=hess([]);
18if U<>[]|H<>[] then pause,end
19
20if execstr('hess(rand(2,5))','errcatch')==0 then pause,end
21if execstr('[U,H]=hess(rand(2,5))','errcatch')==0 then pause,end
22if execstr('hess(rand(2,5)+%i)','errcatch')==0 then pause,end
23if execstr('[U,H]=hess(rand(2,5)+%i)','errcatch')==0 then pause,end
24
25//Small dimension
26//Real case
27A=rand(5,5);
28H=hess(A);
29[U,H1]=hess(A);
30if Err(H-H1)>200*%eps then pause,end
31if Err(U'*U-eye()) >200*%eps then pause,end
32if Err(U'*A*U-H1)  >200*%eps then pause,end
33//complex case
34A=rand(5,5)+%i*rand(5,5);
35H=hess(A);
36[U,H1]=hess(A);
37if Err(H-H1)>200*%eps then pause,end
38if Err(U'*U-eye()) >200*%eps then pause,end
39if Err(U'*A*U-H1)  >200*%eps then pause,end
40//Large dimension
41A=rand(20,20);
42H=hess(A);
43[U,H1]=hess(A);
44if Err(H-H1)>200*%eps then pause,end
45if Err(U'*U-eye()) >1000*%eps then pause,end
46if Err(U'*A*U-H1)  >1000*%eps then pause,end
47//complex case
48A=rand(20,20)+%i*rand(20,20);
49H=hess(A);
50[U,H1]=hess(A);
51if Err(H-H1)>1000*%eps then pause,end
52if Err(U'*U-eye()) >1000*%eps then pause,end
53if Err(U'*A*U-H1)  >1000*%eps then pause,end
54
55