1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2009-2011 - DIGITEO - Michael Baudin
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises
5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1.
8// This file was originally licensed under the terms of the CeCILL v2.1,
9// and continues to be available under such terms.
10// For more information, see the COPYING file which you should have received
11// along with this program.
12// <-- CLI SHELL MODE -->
13//
14// val = optimget ( options , key )
15//
16op = optimset ();
17op = optimset(op,'TolX',1.e-12);
18val = optimget(op,'TolX');
19assert_checkequal ( val , 1.e-12 );
20//
21// val = optimget ( options , key , value ) with non-empty value
22//
23op = optimset ();
24op = optimset(op,'TolX',1.e-12);
25val = optimget(op,'TolX' , 1.e-5);
26assert_checkequal ( val , 1.e-12 );
27//
28// val = optimget ( options , key , value ) with empty value
29//
30op = optimset ();
31val = optimget(op,'TolX' , 1.e-5);
32assert_checkequal ( val , 1.e-5 );
33//
34// val = optimget ( options , key ) with ambiguous key
35//
36op = optimset ();
37op = optimset(op,'TolX',1.e-12);
38cmd = "optimget(op,''Tol'' )";
39assert_checkerror(cmd,"%s: Ambiguous property name %s matches several fields : %s",[],"optimget","Tol","TolFun TolX");
40//
41// Test with wrong number of arguments
42//
43op = optimset ();
44cmd = "optimget ( op )";
45assert_checkerror(cmd,"%s: Wrong number of arguments : %d expected while %d given",[],"optimget",2,1);
46//
47// Test with wrong number of arguments
48//
49op = optimset ();
50cmd = "optimget ( op , ""TolX"" , 1.e-12 , 1.e-13)";
51assert_checkerror(cmd,"%s: Wrong number of arguments : %d expected while %d given",[],"optimget",2,4);
52//
53// val = optimget ( options , key ) with leading characters only
54//
55op = optimset ();
56op = optimset ( op , 'MaxFunEvals' , 1000 );
57val = optimget ( op , 'MaxF' );
58assert_checkequal ( val , 1000 );
59//
60// val = optimget ( options , key , default )
61//
62default = optimset ( 'fminsearch' );
63op = optimset ();
64value = optimget(op,'TolX',default.TolX);
65assert_checkequal ( value , 1.e-4 );
66