comparison scripts/ode/private/odepkg_structure_check.m @ 20584:eb9e2d187ed2

maint: Use Octave coding conventions in scripts/ode/private dir. * AbsRel_Norm.m, fuzzy_compare.m, hermite_quartic_interpolation.m, integrate_adaptive.m, integrate_const.m, integrate_n_steps.m, kahan.m, ode_struct_value_check.m, odepkg_event_handle.m, odepkg_structure_check.m, runge_kutta_45_dorpri.m, starting_stepsize.m: Wrap long lines to < 80 chars. Use double quotes rather than single quotes where possible. Use ';' at end of keywords "return;" and "break;" Use '##" for stand-alone comments and '#' for end-of-line comments. Use two spaces after period before starting new sentence. Use '!' instead of '~' for logical negation. Use specific form of end (endif, endfor, etc.). Don't use line continuation marker '...' unless necessary.
author Rik <rik@octave.org>
date Sun, 04 Oct 2015 22:18:54 -0700
parents 25623ef2ff4f
children b7ac1e94266e
comparison
equal deleted inserted replaced
20583:d746695bf494 20584:eb9e2d187ed2
1 %# Copyright (C) 2006-2012, Thomas Treichl <treichl@users.sourceforge.net> 1 ## Copyright (C) 2006-2012, Thomas Treichl <treichl@users.sourceforge.net>
2 %# Copyright (C) 2013, Roberto Porcu' <roberto.porcu@polimi.it> 2 ## Copyright (C) 2013, Roberto Porcu' <roberto.porcu@polimi.it>
3 %# OdePkg - A package for solving ordinary differential equations and more 3 ## OdePkg - A package for solving ordinary differential equations and more
4 %# 4 ##
5 %# This program is free software; you can redistribute it and/or modify 5 ## This program is free software; you can redistribute it and/or modify
6 %# it under the terms of the GNU General Public License as published by 6 ## it under the terms of the GNU General Public License as published by
7 %# the Free Software Foundation; either version 2 of the License, or 7 ## the Free Software Foundation; either version 2 of the License, or
8 %# (at your option) any later version. 8 ## (at your option) any later version.
9 %# 9 ##
10 %# This program is distributed in the hope that it will be useful, 10 ## This program is distributed in the hope that it will be useful,
11 %# but WITHOUT ANY WARRANTY; without even the implied warranty of 11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 %# GNU General Public License for more details. 13 ## GNU General Public License for more details.
14 %# 14 ##
15 %# You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 %# along with this program; If not, see <http://www.gnu.org/licenses/>. 16 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
17 17
18 ## -*- texinfo -*- 18 ## -*- texinfo -*-
19 ## @deftypefn {Function File} {[@var{newstruct}] =} odepkg_structure_check (@var{oldstruct}, [@var{"solver"}]) 19 ## @deftypefn {Function File} {@var{newstruct} =} odepkg_structure_check (@var{oldstruct})
20 ## @deftypefnx {Function File} {@var{newstruct} =} odepkg_structure_check (@var{oldstruct}, @var{"solver"})
20 ## 21 ##
21 ## If this function is called with one input argument of type structure array 22 ## If this function is called with one input argument of type structure array
22 ## then check the field names and the field values of the OdePkg structure 23 ## then check the field names and the field values of the OdePkg structure
23 ## @var{oldstruct} and return the structure as @var{newstruct} if no error is 24 ## @var{oldstruct} and return the structure as @var{newstruct} if no error is
24 ## found. 25 ## found.
41 ## @end example 42 ## @end example
42 ## @end deftypefn 43 ## @end deftypefn
43 ## 44 ##
44 ## @seealso{odepkg} 45 ## @seealso{odepkg}
45 46
46 function [vret] = odepkg_structure_check (varargin) 47 function vret = odepkg_structure_check (varargin)
47 48
48 %# Check the number of input arguments 49 ## Check the number of input arguments
49 if (nargin == 0) 50 if (nargin == 0)
50 help ('odepkg_structure_check'); 51 help ("odepkg_structure_check");
51 error ('OdePkg:InvalidArgument', ... 52 error ("OdePkg:InvalidArgument",
52 'Number of input arguments must be greater than zero'); 53 "Number of input arguments must be greater than zero");
53 elseif (nargin > 2) 54 elseif (nargin > 2)
54 print_usage; 55 print_usage;
55 elseif (nargin == 1 && isstruct (varargin{1})) 56 elseif (nargin == 1 && isstruct (varargin{1}))
56 vret = varargin{1}; 57 vret = varargin{1};
57 vsol = ''; 58 vsol = "";
58 vfld = fieldnames (vret); 59 vfld = fieldnames (vret);
59 vlen = length (vfld); 60 vlen = length (vfld);
60 elseif (nargin == 2 && isstruct (varargin{1}) && ischar (varargin{2})) 61 elseif (nargin == 2 && isstruct (varargin{1}) && ischar (varargin{2}))
61 vret = varargin{1}; 62 vret = varargin{1};
62 vsol = varargin{2}; 63 vsol = varargin{2};
63 vfld = fieldnames (vret); 64 vfld = fieldnames (vret);
64 vlen = length (vfld); 65 vlen = length (vfld);
65 end 66 endif
66 67
67 for vcntarg = 1:vlen %# Run through the number of given structure field names 68 for vcntarg = 1:vlen # Run through the number of given structure field names
68 69
69 switch (vfld{vcntarg}) 70 switch (vfld{vcntarg})
70 71
71 case 'RelTol' 72 case "RelTol"
72 if (isempty (vret.(vfld{vcntarg})) || ... 73 if (isempty (vret.(vfld{vcntarg})) || ...
73 (isnumeric (vret.(vfld{vcntarg})) && ... 74 (isnumeric (vret.(vfld{vcntarg})) && ...
74 isreal (vret.(vfld{vcntarg})) && ... 75 isreal (vret.(vfld{vcntarg})) && ...
75 all (vret.(vfld{vcntarg}) > 0))) %# 'all' is a MatLab need 76 all (vret.(vfld{vcntarg}) > 0))) # "all" is a MatLab need
76 else 77 else
77 error ('OdePkg:InvalidParameter', ... 78 error ("OdePkg:InvalidParameter",
78 'Unknown parameter name "%s" or no valid parameter value', ... 79 'Unknown parameter name "%s" or no valid parameter value',
79 vfld{vcntarg}); 80 vfld{vcntarg});
80 end 81 endif
81 82
82 switch (vsol) 83 if (any (strcmp (vsol, {"ode23", "ode45", "ode54", "ode78",
83 case {'ode23', 'ode45', 'ode54', 'ode78', ... 84 "ode23d", "ode45d", "ode54d", "ode78d"})))
84 'ode23d', 'ode45d', 'ode54d', 'ode78d',} 85 if (! isscalar (vret.(vfld{vcntarg}))
85 if (~isscalar (vret.(vfld{vcntarg})) && ... 86 && ! isempty (vret.(vfld{vcntarg})))
86 ~isempty (vret.(vfld{vcntarg}))) 87 error ("OdePkg:InvalidParameter",
87 error ('OdePkg:InvalidParameter', ... 88 'Value of option "RelTol" must be a scalar');
88 'Value of option "RelTol" must be a scalar'); 89 endif
89 end 90 endif
90 otherwise 91
91 92 case "AbsTol"
92 end
93
94 case 'AbsTol'
95 if (isempty (vret.(vfld{vcntarg})) || ... 93 if (isempty (vret.(vfld{vcntarg})) || ...
96 (isnumeric (vret.(vfld{vcntarg})) && ... 94 (isnumeric (vret.(vfld{vcntarg})) && ...
97 isreal (vret.(vfld{vcntarg})) && ... 95 isreal (vret.(vfld{vcntarg})) && ...
98 all (vret.(vfld{vcntarg}) > 0))) 96 all (vret.(vfld{vcntarg}) > 0)))
99 else 97 else
100 error ('OdePkg:InvalidParameter', ... 98 error ("OdePkg:InvalidParameter",
101 'Unknown parameter name "%s" or no valid parameter value', ... 99 'Unknown parameter name "%s" or no valid parameter value',
102 vfld{vcntarg}); 100 vfld{vcntarg});
103 end 101 endif
104 102
105 case 'NormControl' 103 case "NormControl"
106 if (isempty (vret.(vfld{vcntarg})) || ... 104 if (isempty (vret.(vfld{vcntarg})) || ...
107 (strcmp (vret.(vfld{vcntarg}), 'on') || ... 105 (strcmp (vret.(vfld{vcntarg}), "on") || ...
108 strcmp (vret.(vfld{vcntarg}), 'off'))) 106 strcmp (vret.(vfld{vcntarg}), "off")))
109 else 107 else
110 error ('OdePkg:InvalidParameter', ... 108 error ("OdePkg:InvalidParameter",
111 'Unknown parameter name "%s" or no valid parameter value', ... 109 'Unknown parameter name "%s" or no valid parameter value',
112 vfld{vcntarg}); 110 vfld{vcntarg});
113 end 111 endif
114 112
115 case 'NonNegative' 113 case "NonNegative"
116 if (isempty (vret.(vfld{vcntarg})) || ... 114 if (isempty (vret.(vfld{vcntarg})) || ...
117 (isnumeric (vret.(vfld{vcntarg})) && isvector (vret.(vfld{vcntarg})))) 115 (isnumeric (vret.(vfld{vcntarg}))
118 else 116 && isvector (vret.(vfld{vcntarg}))))
119 error ('OdePkg:InvalidParameter', ... 117 else
120 'Unknown parameter name "%s" or no valid parameter value', ... 118 error ("OdePkg:InvalidParameter",
121 vfld{vcntarg}); 119 'Unknown parameter name "%s" or no valid parameter value',
122 end 120 vfld{vcntarg});
123 121 endif
124 case 'OutputFcn' 122
125 if (isempty (vret.(vfld{vcntarg})) || ... 123 case "OutputFcn"
126 isa (vret.(vfld{vcntarg}), 'function_handle')) 124 if (isempty (vret.(vfld{vcntarg})) || ...
127 else 125 isa (vret.(vfld{vcntarg}), "function_handle"))
128 error ('OdePkg:InvalidParameter', ... 126 else
129 'Unknown parameter name "%s" or no valid parameter value', ... 127 error ("OdePkg:InvalidParameter",
130 vfld{vcntarg}); 128 'Unknown parameter name "%s" or no valid parameter value',
131 end 129 vfld{vcntarg});
132 130 endif
133 case 'OutputSel' 131
132 case "OutputSel"
134 if (isempty (vret.(vfld{vcntarg})) || ... 133 if (isempty (vret.(vfld{vcntarg})) || ...
135 (isnumeric (vret.(vfld{vcntarg})) && isvector (vret.(vfld{vcntarg}))) || ... 134 (isnumeric (vret.(vfld{vcntarg}))
135 && isvector (vret.(vfld{vcntarg}))) || ...
136 isscalar (vret.(vfld{vcntarg}))) 136 isscalar (vret.(vfld{vcntarg})))
137 else 137 else
138 error ('OdePkg:InvalidParameter', ... 138 error ("OdePkg:InvalidParameter",
139 'Unknown parameter name "%s" or no valid parameter value', ... 139 'Unknown parameter name "%s" or no valid parameter value',
140 vfld{vcntarg}); 140 vfld{vcntarg});
141 end 141 endif
142 142
143 case 'OutputSave' 143 case "OutputSave"
144 if (isempty (vret.(vfld{vcntarg})) || ... 144 if (isempty (vret.(vfld{vcntarg})) || ...
145 (isscalar (vret.(vfld{vcntarg})) && ... 145 (isscalar (vret.(vfld{vcntarg})) && ...
146 mod (vret.(vfld{vcntarg}), 1) == 0 && ... 146 mod (vret.(vfld{vcntarg}), 1) == 0 && ...
147 vret.(vfld{vcntarg}) > 0) || ... 147 vret.(vfld{vcntarg}) > 0) || ...
148 vret.(vfld{vcntarg}) == Inf) 148 vret.(vfld{vcntarg}) == Inf)
149 else 149 else
150 error ('OdePkg:InvalidParameter', ... 150 error ("OdePkg:InvalidParameter",
151 'Unknown parameter name "%s" or no valid parameter value', ... 151 'Unknown parameter name "%s" or no valid parameter value',
152 vfld{vcntarg}); 152 vfld{vcntarg});
153 end 153 endif
154 154
155 case 'Refine' 155 case "Refine"
156 if (isempty (vret.(vfld{vcntarg})) || ... 156 if (isempty (vret.(vfld{vcntarg})) || ...
157 (isscalar (vret.(vfld{vcntarg})) && ... 157 (isscalar (vret.(vfld{vcntarg})) && ...
158 mod (vret.(vfld{vcntarg}), 1) == 0 && ... 158 mod (vret.(vfld{vcntarg}), 1) == 0 && ...
159 vret.(vfld{vcntarg}) >= 0 && ... 159 vret.(vfld{vcntarg}) >= 0 && ...
160 vret.(vfld{vcntarg}) <= 5)) 160 vret.(vfld{vcntarg}) <= 5))
161 else 161 else
162 error ('OdePkg:InvalidParameter', ... 162 error ("OdePkg:InvalidParameter",
163 'Unknown parameter name "%s" or no valid parameter value', ... 163 'Unknown parameter name "%s" or no valid parameter value',
164 vfld{vcntarg}); 164 vfld{vcntarg});
165 end 165 endif
166 166
167 case 'Stats' 167 case "Stats"
168 if (isempty (vret.(vfld{vcntarg})) || ... 168 if (isempty (vret.(vfld{vcntarg})) || ...
169 (strcmp (vret.(vfld{vcntarg}), 'on') || ... 169 (strcmp (vret.(vfld{vcntarg}), "on") || ...
170 strcmp (vret.(vfld{vcntarg}), 'off'))) 170 strcmp (vret.(vfld{vcntarg}), "off")))
171 else 171 else
172 error ('OdePkg:InvalidParameter', ... 172 error ("OdePkg:InvalidParameter",
173 'Unknown parameter name "%s" or no valid parameter value', ... 173 'Unknown parameter name "%s" or no valid parameter value',
174 vfld{vcntarg}); 174 vfld{vcntarg});
175 end 175 endif
176 176
177 case 'InitialStep' 177 case "InitialStep"
178 if (isempty (vret.(vfld{vcntarg})) || ... 178 if (isempty (vret.(vfld{vcntarg})) || ...
179 (isscalar (vret.(vfld{vcntarg})) && ... 179 (isscalar (vret.(vfld{vcntarg})) && ...
180 isreal (vret.(vfld{vcntarg})))) 180 isreal (vret.(vfld{vcntarg}))))
181 else 181 else
182 error ('OdePkg:InvalidParameter', ... 182 error ("OdePkg:InvalidParameter",
183 'Unknown parameter name "%s" or no valid parameter value', ... 183 'Unknown parameter name "%s" or no valid parameter value',
184 vfld{vcntarg}); 184 vfld{vcntarg});
185 end 185 endif
186 186
187 case 'MaxStep' 187 case "MaxStep"
188 if (isempty (vret.(vfld{vcntarg})) || ... 188 if (isempty (vret.(vfld{vcntarg})) || ...
189 (isscalar (vret.(vfld{vcntarg})) && ... 189 (isscalar (vret.(vfld{vcntarg})) && ...
190 vret.(vfld{vcntarg}) > 0) ) 190 vret.(vfld{vcntarg}) > 0) )
191 else 191 else
192 error ('OdePkg:InvalidParameter', ... 192 error ("OdePkg:InvalidParameter",
193 'Unknown parameter name "%s" or no valid parameter value', ... 193 'Unknown parameter name "%s" or no valid parameter value',
194 vfld{vcntarg}); 194 vfld{vcntarg});
195 end 195 endif
196 196
197 case 'Events' 197 case "Events"
198 if (isempty (vret.(vfld{vcntarg})) || ... 198 if (isempty (vret.(vfld{vcntarg})) || ...
199 isa (vret.(vfld{vcntarg}), 'function_handle')) 199 isa (vret.(vfld{vcntarg}), "function_handle"))
200 else 200 else
201 error ('OdePkg:InvalidParameter', ... 201 error ("OdePkg:InvalidParameter",
202 'Unknown parameter name "%s" or no valid parameter value', ... 202 'Unknown parameter name "%s" or no valid parameter value',
203 vfld{vcntarg}); 203 vfld{vcntarg});
204 end 204 endif
205 205
206 case 'Jacobian' 206 case "Jacobian"
207 if (isempty (vret.(vfld{vcntarg})) || ... 207 if (isempty (vret.(vfld{vcntarg})) || ...
208 isnumeric (vret.(vfld{vcntarg})) || ... 208 isnumeric (vret.(vfld{vcntarg})) || ...
209 isa (vret.(vfld{vcntarg}), 'function_handle') || ... 209 isa (vret.(vfld{vcntarg}), "function_handle") || ...
210 iscell (vret.(vfld{vcntarg}))) 210 iscell (vret.(vfld{vcntarg})))
211 else 211 else
212 error ('OdePkg:InvalidParameter', ... 212 error ("OdePkg:InvalidParameter",
213 'Unknown parameter name "%s" or no valid parameter value', ... 213 'Unknown parameter name "%s" or no valid parameter value',
214 vfld{vcntarg}); 214 vfld{vcntarg});
215 end 215 endif
216 216
217 case 'JPattern' 217 case "JPattern"
218 if (isempty (vret.(vfld{vcntarg})) || ... 218 if (isempty (vret.(vfld{vcntarg})) || ...
219 isvector (vret.(vfld{vcntarg})) || ... 219 isvector (vret.(vfld{vcntarg})) || ...
220 isnumeric (vret.(vfld{vcntarg}))) 220 isnumeric (vret.(vfld{vcntarg})))
221 else 221 else
222 error ('OdePkg:InvalidParameter', ... 222 error ("OdePkg:InvalidParameter",
223 'Unknown parameter name "%s" or no valid parameter value', ... 223 'Unknown parameter name "%s" or no valid parameter value',
224 vfld{vcntarg}); 224 vfld{vcntarg});
225 end 225 endif
226 226
227 case 'Vectorized' 227 case "Vectorized"
228 if (isempty (vret.(vfld{vcntarg})) || ... 228 if (isempty (vret.(vfld{vcntarg})) || ...
229 (strcmp (vret.(vfld{vcntarg}), 'on') || ... 229 (strcmp (vret.(vfld{vcntarg}), "on") || ...
230 strcmp (vret.(vfld{vcntarg}), 'off'))) 230 strcmp (vret.(vfld{vcntarg}), "off")))
231 else 231 else
232 error ('OdePkg:InvalidParameter', ... 232 error ("OdePkg:InvalidParameter",
233 'Unknown parameter name "%s" or no valid parameter value', ... 233 'Unknown parameter name "%s" or no valid parameter value',
234 vfld{vcntarg}); 234 vfld{vcntarg});
235 end 235 endif
236 236
237 case 'Mass' 237 case "Mass"
238 if (isempty (vret.(vfld{vcntarg})) || ... 238 if (isempty (vret.(vfld{vcntarg})) || ...
239 (isnumeric (vret.(vfld{vcntarg})) || ... 239 (isnumeric (vret.(vfld{vcntarg})) || ...
240 isa (vret.(vfld{vcntarg}), 'function_handle'))) 240 isa (vret.(vfld{vcntarg}), "function_handle")))
241 else 241 else
242 error ('OdePkg:InvalidParameter', ... 242 error ("OdePkg:InvalidParameter",
243 'Unknown parameter name "%s" or no valid parameter value', ... 243 'Unknown parameter name "%s" or no valid parameter value',
244 vfld{vcntarg}); 244 vfld{vcntarg});
245 end 245 endif
246 246
247 case 'MStateDependence' 247 case "MStateDependence"
248 if (isempty (vret.(vfld{vcntarg})) || ... 248 if (isempty (vret.(vfld{vcntarg})) || ...
249 (strcmp (vret.(vfld{vcntarg}), 'none') || ... 249 (strcmp (vret.(vfld{vcntarg}), "none") || ...
250 strcmp (vret.(vfld{vcntarg}), 'weak') || ... 250 strcmp (vret.(vfld{vcntarg}), "weak") || ...
251 strcmp (vret.(vfld{vcntarg}), 'strong'))) 251 strcmp (vret.(vfld{vcntarg}), "strong")))
252 else 252 else
253 error ('OdePkg:InvalidParameter', ... 253 error ("OdePkg:InvalidParameter",
254 'Unknown parameter name "%s" or no valid parameter value', ... 254 'Unknown parameter name "%s" or no valid parameter value',
255 vfld{vcntarg}); 255 vfld{vcntarg});
256 end 256 endif
257 257
258 case 'MvPattern' 258 case "MvPattern"
259 if (isempty (vret.(vfld{vcntarg})) || ... 259 if (isempty (vret.(vfld{vcntarg})) || ...
260 (isvector (vret.(vfld{vcntarg})) || ... 260 (isvector (vret.(vfld{vcntarg})) || ...
261 isnumeric (vret.(vfld{vcntarg})))) 261 isnumeric (vret.(vfld{vcntarg}))))
262 else 262 else
263 error ('OdePkg:InvalidParameter', ... 263 error ("OdePkg:InvalidParameter",
264 'Unknown parameter name "%s" or no valid parameter value', ... 264 'Unknown parameter name "%s" or no valid parameter value',
265 vfld{vcntarg}); 265 vfld{vcntarg});
266 end 266 endif
267 267
268 case 'MassSingular' 268 case "MassSingular"
269 if (isempty (vret.(vfld{vcntarg})) || ... 269 if (isempty (vret.(vfld{vcntarg})) || ...
270 (strcmp (vret.(vfld{vcntarg}), 'yes') || ... 270 (strcmp (vret.(vfld{vcntarg}), "yes") || ...
271 strcmp (vret.(vfld{vcntarg}), 'no') || ... 271 strcmp (vret.(vfld{vcntarg}), "no") || ...
272 strcmp (vret.(vfld{vcntarg}), 'maybe'))) 272 strcmp (vret.(vfld{vcntarg}), "maybe")))
273 else 273 else
274 error ('OdePkg:InvalidParameter', ... 274 error ("OdePkg:InvalidParameter",
275 'Unknown parameter name "%s" or no valid parameter value', ... 275 'Unknown parameter name "%s" or no valid parameter value',
276 vfld{vcntarg}); 276 vfld{vcntarg});
277 end 277 endif
278 278
279 case 'InitialSlope' 279 case "InitialSlope"
280 if (isempty (vret.(vfld{vcntarg})) || ... 280 if (isempty (vret.(vfld{vcntarg})) || ...
281 isvector (vret.(vfld{vcntarg}))) 281 isvector (vret.(vfld{vcntarg})))
282 else 282 else
283 error ('OdePkg:InvalidParameter', ... 283 error ("OdePkg:InvalidParameter",
284 'Unknown parameter name "%s" or no valid parameter value', ... 284 'Unknown parameter name "%s" or no valid parameter value',
285 vfld{vcntarg}); 285 vfld{vcntarg});
286 end 286 endif
287 287
288 case 'MaxOrder' 288 case "MaxOrder"
289 if (isempty (vret.(vfld{vcntarg})) || ... 289 if (isempty (vret.(vfld{vcntarg})) || ...
290 (mod (vret.(vfld{vcntarg}), 1) == 0 && ... 290 (mod (vret.(vfld{vcntarg}), 1) == 0 && ...
291 vret.(vfld{vcntarg}) > 0 && ... 291 vret.(vfld{vcntarg}) > 0 && ...
292 vret.(vfld{vcntarg}) < 8)) 292 vret.(vfld{vcntarg}) < 8))
293 else 293 else
294 error ('OdePkg:InvalidParameter', ... 294 error ("OdePkg:InvalidParameter",
295 'Unknown parameter name "%s" or no valid parameter value', ... 295 'Unknown parameter name "%s" or no valid parameter value',
296 vfld{vcntarg}); 296 vfld{vcntarg});
297 end 297 endif
298 298
299 case 'BDF' 299 case "BDF"
300 if (isempty (vret.(vfld{vcntarg})) || ... 300 if (isempty (vret.(vfld{vcntarg})) || ...
301 (strcmp (vret.(vfld{vcntarg}), 'on') || ... 301 (strcmp (vret.(vfld{vcntarg}), "on") || ...
302 strcmp (vret.(vfld{vcntarg}), 'off'))) 302 strcmp (vret.(vfld{vcntarg}), "off")))
303 else 303 else
304 error ('OdePkg:InvalidParameter', ... 304 error ("OdePkg:InvalidParameter",
305 'Unknown parameter name "%s" or no valid parameter value', ... 305 'Unknown parameter name "%s" or no valid parameter value',
306 vfld{vcntarg}); 306 vfld{vcntarg});
307 end 307 endif
308 308
309 case 'NewtonTol' 309 case "NewtonTol"
310 if (isempty (vret.(vfld{vcntarg})) || ... 310 if (isempty (vret.(vfld{vcntarg})) || ...
311 (isnumeric (vret.(vfld{vcntarg})) && ... 311 (isnumeric (vret.(vfld{vcntarg})) && ...
312 isreal (vret.(vfld{vcntarg})) && ... 312 isreal (vret.(vfld{vcntarg})) && ...
313 all (vret.(vfld{vcntarg}) > 0))) %# 'all' is a MatLab need 313 all (vret.(vfld{vcntarg}) > 0))) # "all" is a MatLab need
314 else 314 else
315 error ('OdePkg:InvalidParameter', ... 315 error ("OdePkg:InvalidParameter",
316 'Unknown parameter name "%s" or no valid parameter value', ... 316 'Unknown parameter name "%s" or no valid parameter value',
317 vfld{vcntarg}); 317 vfld{vcntarg});
318 end 318 endif
319 319
320 case 'MaxNewtonIterations' 320 case "MaxNewtonIterations"
321 if (isempty (vret.(vfld{vcntarg})) || ... 321 if (isempty (vret.(vfld{vcntarg})) || ...
322 (mod (vret.(vfld{vcntarg}), 1) == 0 && ... 322 (mod (vret.(vfld{vcntarg}), 1) == 0 && ...
323 vret.(vfld{vcntarg}) > 0)) 323 vret.(vfld{vcntarg}) > 0))
324 else 324 else
325 error ('OdePkg:InvalidParameter', ... 325 error ("OdePkg:InvalidParameter",
326 'Unknown parameter name "%s" or no valid parameter value', ... 326 'Unknown parameter name "%s" or no valid parameter value',
327 vfld{vcntarg}); 327 vfld{vcntarg});
328 end 328 endif
329 329
330 %# new fields added 330 ## new fields added
331 case 'Algorithm' 331 case "Algorithm"
332 if( isempty(vret.(vfld{vcntarg})) || ischar(vret.(vfld{vcntarg})) ) 332 if ( isempty(vret.(vfld{vcntarg})) || ischar(vret.(vfld{vcntarg})) )
333 else 333 else
334 error ('OdePkg:InvalidParameter', ... 334 error ("OdePkg:InvalidParameter",
335 'Unknown parameter name "%s" or no valid parameter value', ... 335 'Unknown parameter name "%s" or no valid parameter value',
336 vfld{vcntarg}); 336 vfld{vcntarg});
337 end 337 endif
338 338
339 case 'Choice' 339 case "Choice"
340 if( isempty(vret.(vfld{vcntarg})) || (isnumeric(vret.(vfld{vcntarg})) && (vret.(vfld{vcntarg})==1) || vret.(vfld{vcntarg})==2 ) ) 340 if ( isempty(vret.(vfld{vcntarg}))
341 else 341 || (isnumeric(vret.(vfld{vcntarg})) && (vret.(vfld{vcntarg})==1)
342 error ('OdePkg:InvalidParameter', ... 342 || vret.(vfld{vcntarg})==2 ) )
343 'Unknown parameter name "%s" or no valid parameter value', ... 343 else
344 vfld{vcntarg}); 344 error ("OdePkg:InvalidParameter",
345 end 345 'Unknown parameter name "%s" or no valid parameter value',
346 346 vfld{vcntarg});
347 case 'Eta' 347 endif
348 if( isempty(vret.(vfld{vcntarg})) || ( isreal(vret.(vfld{vcntarg})) && vret.(vfld{vcntarg})>=0 && vret.(vfld{vcntarg})<1) ) 348
349 else 349 case "Eta"
350 error ('OdePkg:InvalidParameter', ... 350 if ( isempty(vret.(vfld{vcntarg}))
351 'Unknown parameter name "%s" or no valid parameter value', ... 351 || ( isreal(vret.(vfld{vcntarg}))
352 vfld{vcntarg}); 352 && vret.(vfld{vcntarg})>=0 && vret.(vfld{vcntarg})<1) )
353 end 353 else
354 354 error ("OdePkg:InvalidParameter",
355 case 'Explicit' 355 'Unknown parameter name "%s" or no valid parameter value',
356 if( isempty(vret.(vfld{vcntarg})) || (ischar(vret.(vfld{vcntarg})) && (strcmp(vret.(vfld{vcntarg}),'yes') || strcmp(vret.(vfld{vcntarg}),'no'))) ) 356 vfld{vcntarg});
357 else 357 endif
358 error ('OdePkg:InvalidParameter', ... 358
359 'Unknown parameter name "%s" or no valid parameter value', ... 359 case "Explicit"
360 vfld{vcntarg}); 360 if ( isempty(vret.(vfld{vcntarg}))
361 end 361 || (ischar(vret.(vfld{vcntarg}))
362 362 && (strcmp(vret.(vfld{vcntarg}),"yes")
363 case 'InexactSolver' 363 || strcmp(vret.(vfld{vcntarg}),"no"))) )
364 if( isempty(vret.(vfld{vcntarg})) || ischar(vret.(vfld{vcntarg})) ) 364 else
365 else 365 error ("OdePkg:InvalidParameter",
366 error ('OdePkg:InvalidParameter', ... 366 'Unknown parameter name "%s" or no valid parameter value',
367 'Unknown parameter name "%s" or no valid parameter value', ... 367 vfld{vcntarg});
368 vfld{vcntarg}); 368 endif
369 end 369
370 370 case "InexactSolver"
371 case 'InitialSlope' 371 if ( isempty(vret.(vfld{vcntarg})) || ischar(vret.(vfld{vcntarg})) )
372 if( isempty(vret.(vfld{vcntarg})) || ( ischar(vret.(vfld{vcntarg})) || (isnumeric(vret.(vfld{vcntarg})) && (isvector(vret.(vfld{vcntarg})) || isreal(vret.(vfld{vcntarg}))))) ) 372 else
373 else 373 error ("OdePkg:InvalidParameter",
374 error ('OdePkg:InvalidParameter', ... 374 'Unknown parameter name "%s" or no valid parameter value',
375 'Unknown parameter name "%s" or no valid parameter value', ... 375 vfld{vcntarg});
376 vfld{vcntarg}); 376 endif
377 end 377
378 378 case "InitialSlope"
379 case 'JConstant' 379 if ( isempty(vret.(vfld{vcntarg}))
380 if( isempty(vret.(vfld{vcntarg})) || (ischar(vret.(vfld{vcntarg})) && (strcmp(vret.(vfld{vcntarg}),'yes') || strcmp(vret.(vfld{vcntarg}),'no'))) ) 380 || ( ischar(vret.(vfld{vcntarg}))
381 else 381 || (isnumeric(vret.(vfld{vcntarg}))
382 error ('OdePkg:InvalidParameter', ... 382 && (isvector(vret.(vfld{vcntarg}))
383 'Unknown parameter name "%s" or no valid parameter value', ... 383 || isreal(vret.(vfld{vcntarg}))))) )
384 vfld{vcntarg}); 384 else
385 end 385 error ("OdePkg:InvalidParameter",
386 386 'Unknown parameter name "%s" or no valid parameter value',
387 case 'MassConstant' 387 vfld{vcntarg});
388 if( isempty(vret.(vfld{vcntarg})) || (strcmp(vret.(vfld{vcntarg}),'on') || strcmp(vret.(vfld{vcntarg}),'off')) ) 388 endif
389 else 389
390 error ('OdePkg:InvalidParameter', ... 390 case "JConstant"
391 'Unknown parameter name "%s" or no valid parameter value', ... 391 if ( isempty(vret.(vfld{vcntarg}))
392 vfld{vcntarg}); 392 || (ischar(vret.(vfld{vcntarg}))
393 end 393 && (strcmp(vret.(vfld{vcntarg}),"yes")
394 394 || strcmp(vret.(vfld{vcntarg}),"no"))) )
395 case 'PolynomialDegree' 395 else
396 if( isempty(vret.(vfld{vcntarg})) || (isnumeric(vret.(vfld{vcntarg})) && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) ) 396 error ("OdePkg:InvalidParameter",
397 else 397 'Unknown parameter name "%s" or no valid parameter value',
398 error ('OdePkg:InvalidParameter', ... 398 vfld{vcntarg});
399 'Unknown parameter name "%s" or no valid parameter value', ... 399 endif
400 vfld{vcntarg}); 400
401 end 401 case "MassConstant"
402 402 if ( isempty(vret.(vfld{vcntarg}))
403 case 'QuadratureOrder' 403 || (strcmp(vret.(vfld{vcntarg}),"on")
404 if( isempty(vret.(vfld{vcntarg})) || (isnumeric(vret.(vfld{vcntarg})) && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) ) 404 || strcmp(vret.(vfld{vcntarg}),"off")) )
405 else 405 else
406 error ('OdePkg:InvalidParameter', ... 406 error ("OdePkg:InvalidParameter",
407 'Unknown parameter name "%s" or no valid parameter value', ... 407 'Unknown parameter name "%s" or no valid parameter value',
408 vfld{vcntarg}); 408 vfld{vcntarg});
409 end 409 endif
410 410
411 case 'Restart' 411 case "PolynomialDegree"
412 if( isempty(vret.(vfld{vcntarg})) || (isnumeric(vret.(vfld{vcntarg})) && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) ) 412 if ( isempty(vret.(vfld{vcntarg}))
413 else 413 || (isnumeric(vret.(vfld{vcntarg}))
414 error ('OdePkg:InvalidParameter', ... 414 && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) )
415 'Unknown parameter name "%s" or no valid parameter value', ... 415 else
416 vfld{vcntarg}); 416 error ("OdePkg:InvalidParameter",
417 end 417 'Unknown parameter name "%s" or no valid parameter value',
418 418 vfld{vcntarg});
419 case 'TimeStepNumber' 419 endif
420 if( isempty(vret.(vfld{vcntarg})) || (isnumeric(vret.(vfld{vcntarg})) && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) ) 420
421 else 421 case "QuadratureOrder"
422 error ('OdePkg:InvalidParameter', ... 422 if ( isempty(vret.(vfld{vcntarg}))
423 'Unknown parameter name "%s" or no valid parameter value', ... 423 || (isnumeric(vret.(vfld{vcntarg}))
424 vfld{vcntarg}); 424 && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) )
425 end 425 else
426 426 error ("OdePkg:InvalidParameter",
427 case 'TimeStepSize' 427 'Unknown parameter name "%s" or no valid parameter value',
428 if( isempty(vret.(vfld{vcntarg})) || ( isreal(vret.(vfld{vcntarg})) && vret.(vfld{vcntarg})!=0) ) 428 vfld{vcntarg});
429 else 429 endif
430 error ('OdePkg:InvalidParameter', ... 430
431 'Unknown parameter name "%s" or no valid parameter value', ... 431 case "Restart"
432 vfld{vcntarg}); 432 if ( isempty(vret.(vfld{vcntarg}))
433 end 433 || (isnumeric(vret.(vfld{vcntarg}))
434 434 && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) )
435 case 'UseJacobian' 435 else
436 if( isempty(vret.(vfld{vcntarg})) || (ischar(vret.(vfld{vcntarg})) && (strcmp(vret.(vfld{vcntarg}),'yes') || strcmp(vret.(vfld{vcntarg}),'no'))) ) 436 error ("OdePkg:InvalidParameter",
437 else 437 'Unknown parameter name "%s" or no valid parameter value',
438 error ('OdePkg:InvalidParameter', ... 438 vfld{vcntarg});
439 'Unknown parameter name "%s" or no valid parameter value', ... 439 endif
440 vfld{vcntarg}); 440
441 end 441 case "TimeStepNumber"
442 if ( isempty(vret.(vfld{vcntarg}))
443 || (isnumeric(vret.(vfld{vcntarg}))
444 && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) )
445 else
446 error ("OdePkg:InvalidParameter",
447 'Unknown parameter name "%s" or no valid parameter value',
448 vfld{vcntarg});
449 endif
450
451 case "TimeStepSize"
452 if ( isempty(vret.(vfld{vcntarg}))
453 || ( isreal(vret.(vfld{vcntarg})) && vret.(vfld{vcntarg})!=0) )
454 else
455 error ("OdePkg:InvalidParameter",
456 'Unknown parameter name "%s" or no valid parameter value',
457 vfld{vcntarg});
458 endif
459
460 case "UseJacobian"
461 if ( isempty(vret.(vfld{vcntarg}))
462 || (ischar(vret.(vfld{vcntarg}))
463 && (strcmp(vret.(vfld{vcntarg}),"yes")
464 || strcmp(vret.(vfld{vcntarg}),"no"))) )
465 else
466 error ("OdePkg:InvalidParameter",
467 'Unknown parameter name "%s" or no valid parameter value',
468 vfld{vcntarg});
469 endif
442 470
443 otherwise 471 otherwise
444 error ('OdePkg:InvalidParameter', ... 472 error ("OdePkg:InvalidParameter",
445 'Unknown parameter name "%s"', ... 473 'Unknown parameter name "%s"',
446 vfld{vcntarg}); 474 vfld{vcntarg});
447 475
448 end %# switch 476 endswitch
449 477
450 end %# for 478 endfor
479
480 endfunction
481
451 482
452 %!demo 483 %!demo
453 %! # Return the checked OdePkg options structure that is created by 484 %! # Return the checked OdePkg options structure that is created by
454 %! # the command odeset. 485 %! # the command odeset.
455 %! 486 %!
456 %! odepkg_structure_check (odeset); 487 %! odepkg_structure_check (odeset);
457 %! 488
458 %!demo 489 %!demo
459 %! # Create the OdePkg options structure A with odeset and check it 490 %! # Create the OdePkg options structure A with odeset and check it
460 %! # with odepkg_structure_check. This actually is unnecessary 491 %! # with odepkg_structure_check. This actually is unnecessary
461 %! # because odeset automtically calls odepkg_structure_check before 492 %! # because odeset automatically calls odepkg_structure_check before
462 %! # returning. 493 %! # returning.
463 %! 494 %!
464 %! A = odeset (); odepkg_structure_check (A); 495 %! A = odeset (); odepkg_structure_check (A);
465 496
466 %# Local Variables: ***
467 %# mode: octave ***
468 %# End: ***