summaryrefslogtreecommitdiffstats
path: root/tests/nonRegression/bug632.sci
blob: 467712a09db3e1cf53957e6d7bf98d21ad1a44df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// <-- Non-regression test for bug 632 -->
//
// <-- Bugzilla URL -->
// http://www.scilab.org/cgi-bin/bugzilla_bug_II/show_bug.cgi?id=632
//
// <-- Short Description -->
//    The function "lsqrsolve" makes the the whole Scilab crash.
//    It even does it with the example cited in the Scilab 
//    documentation:
//
//    // Data fitting problem
//    // 1 build the data
//    a=34;b=12;c=14;
//    deff('y=FF(x)','y=a*(x-b)+c*x.*x');
//    X=(0:.1:3)';Y=FF(X)+100*(rand()-.5);
//
//    //solve
//    function e=f1(abc,m)
//      a=abc(1);b=abc(2),c=abc(3),
//      e=Y-(a*(X-b)+c*X.*X);
//    endfunction
//    [abc,v]=lsqrsolve([10;10;10],f1,size(X,1));
//    abc
//    norm(v)


// Data fitting problem
// 1 build the data
//exec("632.sce");  

// this test will fail if scilab crashes
a=34;b=12;c=14;
deff('y=FF(x)','y=a*(x-b)+c*x.*x');
X=(0:.1:3)';Y=FF(X)+100*(rand()-.5);

//solve

function e=f1(abc,m)
	a=abc(1);b=abc(2),c=abc(3),
	e=Y-(a*(X-b)+c*X.*X);
endfunction

[abc,v]=lsqrsolve([10;10;10],f1,size(X,1));
abc
norm(v)

affich_result(%T,632);