* Bug #9196 fixed - The threshold level for conditioning in backslash was too
[scilab.git] / scilab / modules / linear_algebra / tests / nonreg_tests / bug_9196.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
4 // Copyright (C) 2013 - MichaĆ«l Baudin
5 //
6 //  This file is distributed under the same license as the Scilab package.
7 // =============================================================================
8
9 // <-- CLI SHELL MODE -->
10
11 // <-- Non-regression test for bug 9196 -->
12 //
13 // <-- Bugzilla URL -->
14 // http://bugzilla.scilab.org/show_bug.cgi?id=9196
15 //
16 // <-- Short Description -->
17 //    The threshold level for conditioning in backslash is too small.
18 // =============================================================================
19
20 n=9;
21 A = testmatrix("hilb",n);
22 b=ones(n,1);
23 xexpected=[7129/2520
24            4861/2520
25            42131/27720
26            35201/27720
27            395243/360360
28            348911/360360
29            62575/72072
30            113567/144144
31            1768477/2450448];
32 x=A\b;
33 assert_checkalmostequal(x, xexpected);
34
35
36 Ac=complex(A,zeros(A));
37 bc=complex(b,zeros(b));
38 xc = Ac\bc;
39 xcexpected=complex(xexpected,zeros(xexpected));
40 assert_checkalmostequal(xc, xexpected);
41
42 b=(1:n)';
43 xexpected=[9;
44            17819/2520;
45            82609/13860;
46            47959/9240;
47            415567/90090;
48            299737/72072;
49            45533/12012;
50            71761/20592;
51            988277/306306];
52 x=A\b;
53 assert_checkalmostequal(x, xexpected);
54 Ac=complex(A,zeros(A));
55 bc=complex(b,zeros(b));
56 xc = Ac\bc;
57 xcexpected=complex(xexpected,zeros(xexpected));
58 assert_checkalmostequal(xc, xexpected);
59
60 b=[1;-1;1;-1;1;-1;1;-1;1];
61 xexpected=[1879/2520;
62            893/2520;
63            6557/27720;
64            4993/27720;
65            52901/360360;
66            44911/360360;
67            39173/360360;
68            69659/720720;
69            1068047/12252240];
70 x=A\b;
71 assert_checkalmostequal(x, xexpected);
72 Ac=complex(A,zeros(A));
73 bc=complex(b,zeros(b));
74 xc = Ac\bc;
75 xcexpected=complex(xexpected,zeros(xexpected));
76 assert_checkalmostequal(xc, xexpected);