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 48 49 50 51 52
|
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- ENGLISH IMPOSED -->
// <-- Non-regression test for bug 632 -->
//
// <-- Bugzilla URL -->
// http://bugzilla.scilab.org/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
// 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));
lsqrsolve: relative error between two consecutive iterates is at most xtol.
if norm(abc - [ 34. ; 12.849045 ; 14. ] ) > 0.1 then bugmes();quit;end
if norm(v) - 2.814D-13 > 0.1 then bugmes();quit;end
|