1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) ????-2008 - INRIA - Serge Steer
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
9 // Returns 1 if the two real matrices computed and expected are close,
10 // i.e. if the relative distance between computed and expected is lesser than epsilon.
12 // computed, expected : the two matrices to compare
13 // epsilon : a small number
15 function flag = assert_close ( computed, expected, epsilon )
17 shift = norm(computed-expected);
19 shift = norm(computed-expected)/norm(expected);
21 if shift < epsilon then
26 if flag <> 1 then bugmes();quit;end
34 assert_close ( sld.dt , 0.1 , %eps );
36 expected = exp(sl.A*0.1);
37 assert_close ( computed , expected , %eps );
39 expected = sl.A\(sld.A-eye())*sl.B;
40 assert_close ( computed , expected , %eps );
42 a=[0.9,0,0.6,-1.4,-4.2;
45 -3.7,-0.5,2.4,-0.6,2.7;
56 sl=syslin('c',a,b,c,d);
58 assert_close ( sld.dt , 0.1 , %eps );
60 expected = expm(sl.A*0.1);
61 assert_close ( computed , expected , %eps );
63 expected = sl.A\(sld.A-eye())*sl.B;
64 assert_close ( computed , expected , 1.e3 * %eps );