comparison testing/utp_1.1/utps/parfrac/utp_parfrac_resp.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents
children
comparison
equal deleted inserted replaced
43:bc767aaa99a8 44:409a22968d5e
1 % UTP_PARFRAC_RESP a set of UTPs for the parfrac/resp method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_parfrac_resp.m,v 1.6 2011/02/04 10:56:56 luigi Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The resp method of the parfrac class returns the complex response of a
11 % parfrac TF as an Analysis Object. For a command with no output variables
12 % plots the method the result into a diagram.
13 %
14 % </MethodDescription>
15
16 function results = utp_parfrac_resp(varargin)
17
18 % Check the inputs
19 if nargin == 0
20
21 % Some keywords
22 class = 'parfrac';
23 mthd = 'resp';
24
25 results = [];
26 disp('******************************************************');
27 disp(['**** Running UTPs for ' class '/' mthd]);
28 disp('******************************************************');
29
30 % Test PARFRAC objects
31 [pf1,pf2,pf3,pfv,pfm] = get_test_objects_parfrac;
32
33 % Exception list for the UTPs:
34 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
35
36 warning('This UTP needs a complete update');
37
38 % Run the tests
39 results = [results utp_01]; % getInfo call
40 results = [results utp_02]; % Vector input
41 results = [results utp_03]; % Matrix input
42 results = [results utp_04]; % List input
43 results = [results utp_05]; % Test with mixed input
44 results = [results utp_06]; % Test history is working
45 results = [results utp_07]; % Test the modify call works
46 results = [results utp_08]; % Test input data shape == output data shape
47 results = [results utp_09]; % Test output of the data
48 results = [results utp_10]; % Test with f = ao.y
49 results = [results utp_11]; % Test with f
50 results = [results utp_12]; % Test with f1, f2 and nf
51 results = [results utp_13]; % Test with f1, f2 and nf AND 'scale'
52
53 % Make surethat all figures are closed
54 close all;
55
56 disp('Done.');
57 disp('******************************************************');
58
59 elseif nargin == 1 % Check for UTP functions
60 if strcmp(varargin{1}, 'isutp')
61 results = 1;
62 else
63 results = 0;
64 end
65 else
66 error('### Incorrect inputs')
67 end
68
69 %% UTP_01
70
71 % <TestDescription>
72 %
73 % Tests that the getInfo call works for this method.
74 %
75 % </TestDescription>
76 function result = utp_01
77
78
79 % <SyntaxDescription>
80 %
81 % Test that the getInfo call works for no sets, all sets, and each set
82 % individually.
83 %
84 % </SyntaxDescription>
85
86 try
87 % <SyntaxCode>
88 % Call for no sets
89 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
90 % Call for all sets
91 io(2) = eval([class '.getInfo(''' mthd ''')']);
92 % Call for each set
93 for kk=1:numel(io(2).sets)
94 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
95 end
96 % </SyntaxCode>
97 stest = true;
98 catch err
99 disp(err.message)
100 stest = false;
101 end
102
103 % <AlgoDescription>
104 %
105 % 1) Check that getInfo call returned an minfo object in all cases.
106 % 2) Check that all plists have the correct parameters.
107 %
108 % </AlgoDescription>
109
110 atest = true;
111 if stest
112 % <AlgoCode>
113 % check we have minfo objects
114 if isa(io, 'minfo')
115 %%% SET 'None'
116 if ~isempty(io(1).sets), atest = false; end
117 if ~isempty(io(1).plists), atest = false; end
118 %%% Check all Sets
119 if ~any(strcmpi(io(2).sets, 'List')), atest = false; end
120 if ~any(strcmpi(io(2).sets, 'Range')), atest = false; end
121 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
122 %%%%%%%%%% SET 'List'
123 if io(3).plists.nparams ~= 2, atest = false; end
124 % Check key
125 if ~io(3).plists.isparam('f'), atest = false; end
126 if ~io(3).plists.isparam('bank'), atest = false; end
127 % Check default value
128 if ~isEmptyDouble(io(3).plists.find('f')), atest = false; end
129 if ~isequal(io(3).plists.find('bank'), 'none'), atest = false; end
130 % Check options
131 if ~isequal(io(3).plists.getOptionsForParam('f'), {[]}), atest = false; end
132 if ~isequal(io(3).plists.getOptionsForParam('bank'), {'none', 'serial', 'parallel'}), atest = false; end
133 %%%%%%%%%% SET 'Range'
134 if io(4).plists.nparams ~= 5, atest = false; end
135 % Check key
136 if ~io(4).plists.isparam('f1'), atest = false; end
137 if ~io(4).plists.isparam('f2'), atest = false; end
138 if ~io(4).plists.isparam('nf'), atest = false; end
139 if ~io(4).plists.isparam('scale'), atest = false; end
140 if ~io(4).plists.isparam('bank'), atest = false; end
141 % Check default value
142 if ~isEmptyDouble(io(4).plists.find('f1')), atest = false; end
143 if ~isEmptyDouble(io(4).plists.find('f2')), atest = false; end
144 if ~isequal(io(4).plists.find('nf'), 1000), atest = false; end
145 if ~isequal(io(4).plists.find('scale'), 'log'), atest = false; end
146 if ~isequal(io(4).plists.find('bank'), 'none'), atest = false; end
147 % Check options
148 if ~isequal(io(4).plists.getOptionsForParam('f1'), {[]}), atest = false; end
149 if ~isequal(io(4).plists.getOptionsForParam('f2'), {[]}), atest = false; end
150 if ~isequal(io(4).plists.getOptionsForParam('nf'), {1000}), atest = false; end
151 if ~isequal(io(4).plists.getOptionsForParam('scale'), {'lin', 'log'}), atest = false; end
152 if ~isequal(io(4).plists.getOptionsForParam('bank'), {'none', 'serial', 'parallel'}), atest = false; end
153 end
154 % </AlgoCode>
155 else
156 atest = false;
157 end
158
159 % Return a result structure
160 result = utp_prepare_result(atest, stest, dbstack, mfilename);
161 end % END UTP_01
162
163 %% UTP_02
164
165 % <TestDescription>
166 %
167 % Tests that the resp method works with a vector of PARFRAC objects as
168 % input.
169 %
170 % </TestDescription>
171 function result = utp_02
172
173 % <SyntaxDescription>
174 %
175 % Test that the resp method works for a vector of PARFRAC objects as
176 % input. Test the method with an output and with no output
177 % (a diagram must appear)
178 %
179 % </SyntaxDescription>
180
181 try
182 % <SyntaxCode>
183 % Make sure that all figures are closed.
184 close all;
185 resp(pfv);
186 out = resp(pfv);
187 % </SyntaxCode>
188 stest = true;
189 catch err
190 disp(err.message)
191 stest = false;
192 end
193
194 % <AlgoDescription>
195 %
196 % 1) Test the right number of lines in the diagram.
197 % 2) Check that the number of elements in 'out' is the same as in 'pfv'
198 % 3) Check that each output PARFRAC contains the correct data.
199 %
200 % </AlgoDescription>
201
202 atest = true;
203 TOL = 1e-13;
204 if stest
205 % <AlgoCode>
206 % Get the current figure.
207 fi = gcf;
208 % Get ALL axes including the legends.
209 ax = get(fi, 'Children');
210 % Select only the 'axes' with the lines
211 ax = ax(ismember(get(ax(:), 'Tag'), ''));
212 % Get the lines of both axes
213 lines = get(ax(:), 'Children');
214 % Check that the diagram have the same number of lines as the output
215 % object
216 if max(cellfun('size', lines, 1)) ~= numel(pfv), atest = false; end
217 % Check the number of output objects.
218 if ~isequal(size(out), size(pfv)), atest = false; end
219 % Check each output against the default values for f1, f2 and nf
220 for ii = 1:numel(out)
221 f1 = getlowerFreq(pfv(ii))/10;
222 f2 = getupperFreq(pfv(ii))*10;
223 nf = 1000;
224 if ~isa(out(ii), 'ao'), atest = false; end
225 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
226 if abs(out(ii).x(1) - f1) > TOL, atest = false; end
227 if abs(out(ii).x(end) - f2) > TOL, atest = false; end
228 if numel(out(ii).x) ~= nf, atest = false; end
229 % Compute response
230 pfparams.type = 'cont';
231 pfparams.freq = out(ii).x;
232 pfparams.res = pfv(ii).res;
233 pfparams.pol = pfv(ii).poles;
234 pfparams.pmul = pfv(ii).pmul;
235 pfparams.dterm = pfv(ii).dir;
236 pfr = utils.math.pfresp(pfparams);
237 rsp = pfr.resp;
238 if ~isequal(out(ii).y, reshape(rsp,size(out(ii).y))), atest = false; end
239 end
240 % </AlgoCode>
241 else
242 atest = false;
243 end
244
245 % Return a result structure
246 result = utp_prepare_result(atest, stest, dbstack, mfilename);
247 end % END UTP_02
248
249 %% UTP_03
250
251 % <TestDescription>
252 %
253 % Tests that the resp method works with a matrix of PARFRAC objects as
254 % input.
255 %
256 % </TestDescription>
257 function result = utp_03
258
259 % <SyntaxDescription>
260 %
261 % Tests that the resp method works with a matrix of PARFRAC objects as
262 % input. Test the method with an output and with no output
263 % (a diagram must appear)
264 %
265 % </SyntaxDescription>
266
267 try
268 % <SyntaxCode>
269 % Make sure that all figures are closed.
270 close all;
271 resp(pfm);
272 out = resp(pfm);
273 % </SyntaxCode>
274 stest = true;
275 catch err
276 disp(err.message)
277 stest = false;
278 end
279
280 % <AlgoDescription>
281 %
282 % 1) Test the right number of lines in the diagram.
283 % 2) Check that the number of elements in 'out' is the same as in 'pfm'
284 % 3) Check that each output PARFRAC contains the correct data.
285 %
286 % </AlgoDescription>
287
288 atest = true;
289 TOL = 1e-13;
290 if stest
291 % <AlgoCode>
292 % Get the current figure.
293 fi = gcf;
294 % Get ALL axes including the legends.
295 ax = get(fi, 'Children');
296 % Select only the 'axes' with the lines
297 ax = ax(ismember(get(ax(:), 'Tag'), ''));
298 % Get the lines of both axes
299 lines = get(ax(:), 'Children');
300 % Check that the diagram have the same number of lines as the output
301 % object
302 if max(cellfun('size', lines, 1)) ~= numel(pfm), atest = false; end
303 % Check the number of output objects.
304 if ~isequal(size(out), size(pfm)), atest = false; end
305 % Check each output against the default values for f1, f2 and nf
306 for ii = 1:numel(out)
307 f1 = getlowerFreq(pfm(ii))/10;
308 f2 = getupperFreq(pfm(ii))*10;
309 nf = 1000;
310 if ~isa(out(ii), 'ao'), atest = false; end
311 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
312 if abs(out(ii).x(1) - f1) > TOL, atest = false; end
313 if abs(out(ii).x(end) - f2) > TOL, atest = false; end
314 if numel(out(ii).x) ~= nf, atest = false; end
315 % Compute response
316 pfparams.type = 'cont';
317 pfparams.freq = out(ii).x;
318 pfparams.res = pfm(ii).res;
319 pfparams.pol = pfm(ii).poles;
320 pfparams.pmul = pfm(ii).pmul;
321 pfparams.dterm = pfm(ii).dir;
322 pfr = utils.math.pfresp(pfparams);
323 rsp = pfr.resp;
324 if ~isequal(out(ii).y, reshape(rsp,size(out(ii).y))), atest = false; end
325 end
326 % </AlgoCode>
327 else
328 atest = false;
329 end
330
331 % Return a result structure
332 result = utp_prepare_result(atest, stest, dbstack, mfilename);
333 end % END UTP_03
334
335 %% UTP_04
336
337 % <TestDescription>
338 %
339 % Tests that the resp method works with a list of PARFRAC objects as
340 % input.
341 %
342 % </TestDescription>
343 function result = utp_04
344
345 % <SyntaxDescription>
346 %
347 % Tests that the resp method works with a list of PARFRAC objects as
348 % input. Test the method with an output and with no output
349 % (a diagram must appear)
350 %
351 % </SyntaxDescription>
352
353 try
354 % <SyntaxCode>
355 % Make sure that all figures are closed.
356 close all;
357 resp(pf1, pf2, pf3);
358 out = resp(pf1, pf2, pf3);
359 % </SyntaxCode>
360 stest = true;
361 catch err
362 disp(err.message)
363 stest = false;
364 end
365
366 % <AlgoDescription>
367 %
368 % 1) Test the right number of lines in the diagram.
369 % 2) Check that the number of elements in 'out' is the same as in 'rain'
370 % 3) Check that each output PARFRAC contains the correct data.
371 %
372 % </AlgoDescription>
373
374 atest = true;
375 TOL = 1e-13;
376 rain = [pf1, pf2, pf3];
377 if stest
378 % <AlgoCode>
379 % Get the current figure.
380 fi = gcf;
381 % Get ALL axes including the legends.
382 ax = get(fi, 'Children');
383 % Select only the 'axes' with the lines
384 ax = ax(ismember(get(ax(:), 'Tag'), ''));
385 % Get the lines of both axes
386 lines = get(ax(:), 'Children');
387 % Check that the diagram have the same number of lines as the output
388 % object
389 if max(cellfun('size', lines, 1)) ~= numel(rain), atest = false; end
390 % Check the number of output objects.
391 if ~isequal(size(out), size(rain)), atest = false; end
392 % Check each output against the default values for f1, f2 and nf
393 for ii = 1:numel(out)
394 f1 = getlowerFreq(rain(ii))/10;
395 f2 = getupperFreq(rain(ii))*10;
396 nf = 1000;
397 if ~isa(out(ii), 'ao'), atest = false; end
398 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
399 if abs(out(ii).x(1) - f1) > TOL, atest = false; end
400 if abs(out(ii).x(end) - f2) > TOL, atest = false; end
401 if numel(out(ii).x) ~= nf, atest = false; end
402 % Compute response
403 pfparams.type = 'cont';
404 pfparams.freq = out(ii).x;
405 pfparams.res = rain(ii).res;
406 pfparams.pol = rain(ii).poles;
407 pfparams.pmul = rain(ii).pmul;
408 pfparams.dterm = rain(ii).dir;
409 pfr = utils.math.pfresp(pfparams);
410 rsp = pfr.resp;
411 if ~isequal(out(ii).y, reshape(rsp,size(out(ii).y))), atest = false; end
412 end
413 % </AlgoCode>
414 else
415 atest = false;
416 end
417
418 % Return a result structure
419 result = utp_prepare_result(atest, stest, dbstack, mfilename);
420 end % END UTP_04
421
422 %% UTP_05
423
424 % <TestDescription>
425 %
426 % Tests that the resp method works with a mix of different shaped
427 % PARFRAC objects as input.
428 %
429 % </TestDescription>
430 function result = utp_05
431
432 % <SyntaxDescription>
433 %
434 % Tests that the resp method works with a mix of different shaped
435 % PARFRAC objects as input. Test the method with an output and with no
436 % output (a diagram must appear)
437 %
438 % </SyntaxDescription>
439
440 try
441 % <SyntaxCode>
442 % Make sure that all figures are closed.
443 close all;
444 resp(pf1, pfm, pfv);
445 out = resp(pf1, pfm, pfv);
446 % </SyntaxCode>
447 stest = true;
448 catch err
449 disp(err.message)
450 stest = false;
451 end
452
453 % <AlgoDescription>
454 %
455 % 1) Test the right number of lines in the diagram.
456 % 2) Check that the number of elements in 'out' is the same as in 'rain'
457 % 3) Check that each output PARFRAC contains the correct data.
458 %
459 % </AlgoDescription>
460
461 atest = true;
462 TOL = 1e-13;
463 rain = [pf1, reshape(pfm, 1, []), reshape(pfv, 1, [])];
464 if stest
465 % <AlgoCode>
466 % Get the current figure.
467 fi = gcf;
468 % Get ALL axes including the legends.
469 ax = get(fi, 'Children');
470 % Select only the 'axes' with the lines
471 ax = ax(ismember(get(ax(:), 'Tag'), ''));
472 % Get the lines of both axes
473 lines = get(ax(:), 'Children');
474 % Check that the diagram have the same number of lines as the output
475 % object
476 if max(cellfun('size', lines, 1)) ~= numel(rain), atest = false; end
477 % Check the number of output objects.
478 if ~isequal(size(out), size(rain)), atest = false; end
479 % Check each output against the default values for f1, f2 and nf
480 for ii = 1:numel(out)
481 f1 = getlowerFreq(rain(ii))/10;
482 f2 = getupperFreq(rain(ii))*10;
483 nf = 1000;
484 if ~isa(out(ii), 'ao'), atest = false; end
485 if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
486 if abs(out(ii).x(1) - f1) > TOL, atest = false; end
487 if abs(out(ii).x(end) - f2) > TOL, atest = false; end
488 if numel(out(ii).x) ~= nf, atest = false; end
489 % Compute response
490 pfparams.type = 'cont';
491 pfparams.freq = out(ii).x;
492 pfparams.res = rain(ii).res;
493 pfparams.pol = rain(ii).poles;
494 pfparams.pmul = rain(ii).pmul;
495 pfparams.dterm = rain(ii).dir;
496 pfr = utils.math.pfresp(pfparams);
497 rsp = pfr.resp;
498 if ~isequal(out(ii).y, reshape(rsp,size(out(ii).y))), atest = false; end
499 end
500 % </AlgoCode>
501 else
502 atest = false;
503 end
504
505 % Return a result structure
506 result = utp_prepare_result(atest, stest, dbstack, mfilename);
507 end % END UTP_05
508
509 %% UTP_06
510
511 % <TestDescription>
512 %
513 % Tests that the resp method properly applies history.
514 %
515 % </TestDescription>
516 function result = utp_06
517
518 % <SyntaxDescription>
519 %
520 % Test that the result of applying the resp method can be processed back.
521 %
522 % </SyntaxDescription>
523
524 try
525 % <SyntaxCode>
526 close all;
527 resp(pf1);
528 out = resp(pf1);
529 mout = rebuild(out);
530 % </SyntaxCode>
531 stest = true;
532 catch err
533 disp(err.message)
534 stest = false;
535 end
536
537 % <AlgoDescription>
538 %
539 % 1) Check that the last entry in the history of 'out' corresponds to
540 % 'resp'.
541 % 2) Check that re-built object is the same object as the input.
542 %
543 % </AlgoDescription>
544
545 atest = true;
546 if stest
547 % <AlgoCode>
548 % Get the current figure.
549 fi = gcf;
550 % Get ALL axes including the legends.
551 ax = get(fi, 'Children');
552 % Select only the 'axes' with the lines
553 ax = ax(ismember(get(ax(:), 'Tag'), ''));
554 % Get the lines of both axes
555 lines = get(ax(:), 'Children');
556 x = get(lines{1}, 'XData');
557 y1 = get(lines{1}, 'YData');
558 y2 = get(lines{2}, 'YData');
559 if ~isequal(x, out.x.'), atest = false; end
560 if ~isequal(y2, abs(out.y)'), atest = false; end
561 if ~isequal(y1, utils.math.phase(out.y)'), atest = false; end
562 % Check the last step in the history of 'out'
563 if ~strcmp(out.hist.methodInfo.mname, 'resp'), atest = false; end
564 % Run 'test.m' and check the result
565 if ~eq(mout, out, ple2), atest = false; end
566 % </AlgoCode>
567 else
568 atest = false;
569 end
570
571 % Return a result structure
572 result = utp_prepare_result(atest, stest, dbstack, mfilename);
573 end % END UTP_06
574
575 %% UTP_07
576
577 % <TestDescription>
578 %
579 % Tests that modify command plots the response into a diagram.
580 %
581 % </TestDescription>
582 function result = utp_07
583
584 % <SyntaxDescription>
585 %
586 % Tests that modify command plots the response into a diagram.
587 %
588 % </SyntaxDescription>
589
590 try
591 % <SyntaxCode>
592 close all;
593 pf1.resp();
594 % </SyntaxCode>
595 stest = true;
596 catch err
597 disp(err.message)
598 stest = false;
599 end
600
601 % <AlgoDescription>
602 %
603 % 1) Check the response diagram.
604 %
605 % </AlgoDescription>
606
607 atest = true;
608 TOL = 1e-13;
609 if stest
610 % <AlgoCode>
611 % Get the current figure.
612 fi = gcf;
613 % Get ALL axes including the legends.
614 ax = get(fi, 'Children');
615 % Select only the 'axes' with the lines
616 ax = ax(ismember(get(ax(:), 'Tag'), ''));
617 % Get the lines of both axes
618 lines = get(ax(:), 'Children');
619 x = get(lines{1}, 'XData');
620 f1 = getlowerFreq(pf1)/10;
621 f2 = getupperFreq(pf1)*10;
622 nf = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
623 if abs(x(1) - f1) > TOL, atest = false; end
624 if abs(x(end) - f2) > TOL, atest = false; end
625 if numel(x) ~= nf, atest = false; end
626 % </AlgoCode>
627 else
628 atest = false;
629 end
630
631 % Return a result structure
632 result = utp_prepare_result(atest, stest, dbstack, mfilename);
633 end % END UTP_07
634
635 %% UTP_08
636
637 % <TestDescription>
638 %
639 % Test the shape of the output.
640 %
641 % </TestDescription>
642 function result = utp_08
643
644 % <SyntaxDescription>
645 %
646 % Test that the output AO of the resp method keeps the shape of the used
647 % input f vector.
648 %
649 % </SyntaxDescription>
650
651 try
652 % <SyntaxCode>
653 arow = ao(1:123, linspace(.1, 5, 123));
654 acol = arow.';
655 f = linspace(.1, 5, 123);
656 out1 = resp(pf2, arow);
657 out2 = resp(pf2, acol);
658 out3 = resp(pf2, f);
659 % </SyntaxCode>
660 stest = true;
661 catch err
662 disp(err.message)
663 stest = false;
664 end
665
666 % <AlgoDescription>
667 %
668 % 1) Check that the shape of the data doesn't change.
669 %
670 % </AlgoDescription>
671
672 atest = true;
673 if stest
674 % <AlgoCode>
675 % Check the shape of the output data
676 if size(out1.data.y,1) ~= 1, atest = false; end
677 if size(out1.data.y,2) == 1, atest = false; end
678 if size(out2.data.y,1) == 1, atest = false; end
679 if size(out2.data.y,2) ~= 1, atest = false; end
680 if size(out3.data.y,1) ~= 1, atest = false; end
681 if size(out3.data.y,2) == 1, atest = false; end
682 % </AlgoCode>
683 else
684 atest = false;
685 end
686
687 % Return a result structure
688 result = utp_prepare_result(atest, stest, dbstack, mfilename);
689 end % END UTP_08
690
691 %% UTP_09
692
693 % <TestDescription>
694 %
695 % Check that the resp method pass back the output objects to a list of
696 % output variables or to a single variable.
697 %
698 % </TestDescription>
699 function result = utp_09
700
701 % <SyntaxDescription>
702 %
703 % Call the method with a list of output variables and with a single
704 % output variable. Additionaly check that the rebuild method works on
705 % the output.
706 %
707 % </SyntaxDescription>
708
709 try
710 % <SyntaxCode>
711 [o1, o2] = resp(pf1, pf1);
712 o3 = resp(pf1, pf1);
713 mout1 = rebuild(o1);
714 mout2 = rebuild(o2);
715 mout3 = rebuild(o3);
716 % </SyntaxCode>
717 stest = true;
718 catch err
719 disp(err.message)
720 stest = false;
721 end
722
723 % <AlgoDescription>
724 %
725 % 1) Check that the output contains the right number of objects
726 % 2) Check that the 'rebuild' method produces the same object as 'out'.
727 %
728 % </AlgoDescription>
729
730 atest = true;
731 if stest
732 % <AlgoCode>
733 % Check the number of outputs
734 if numel(o1) ~=1, atest = false; end
735 if numel(o2) ~=1, atest = false; end
736 if numel(o3) ~=2, atest = false; end
737 % Check the rebuilding of the object
738 if ~eq(o1, mout1, ple2), atest = false; end
739 if ~eq(o2, mout2, ple2), atest = false; end
740 if ~eq(o3, mout3, ple2), atest = false; end
741 % </AlgoCode>
742 else
743 atest = false;
744 end
745
746 % Return a result structure
747 result = utp_prepare_result(atest, stest, dbstack, mfilename);
748 end % END UTP_09
749
750 %% UTP_10
751
752 % <TestDescription>
753 %
754 % Check that the resp method uses the x-data of an input AO for f-vector.
755 %
756 % </TestDescription>
757 function result = utp_10
758
759 % <SyntaxDescription>
760 %
761 % Call the method with different method to pass an AO in.
762 %
763 % </SyntaxDescription>
764
765 try
766 % <SyntaxCode>
767 f1 = .1;
768 f2 = 5;
769 nf = 123;
770 axy = ao(linspace(f1, f2, nf), randn(nf,1));
771 afs = ao(linspace(f1, f2, nf), randn(nf,1), plist('type', 'fsdata'));
772 out1 = resp(pf3, axy);
773 out2 = resp(pf3, afs);
774 out3 = resp(pf3, plist('f', axy));
775 out4 = resp(pf3, plist('f', afs));
776
777 mout1 = rebuild(out1);
778 mout2 = rebuild(out2);
779 mout3 = rebuild(out3);
780 mout4 = rebuild(out4);
781 % </SyntaxCode>
782 stest = true;
783 catch err
784 disp(err.message)
785 stest = false;
786 end
787
788 % <AlgoDescription>
789 %
790 % 1) Check the output
791 % 2) Check that the 'rebuild' method produces the same object as 'out'.
792 %
793 % </AlgoDescription>
794
795 atest = true;
796 if stest
797 % <AlgoCode>
798 % Check the output
799 if ~isa(out1, 'ao'), atest = false; end
800 if ~isa(out2, 'ao'), atest = false; end
801 if ~isa(out3, 'ao'), atest = false; end
802 if ~isa(out4, 'ao'), atest = false; end
803 if out1.x(1) ~= f1, atest = false; end
804 if out1.x(end) ~= f2, atest = false; end
805 if numel(out1.x) ~= nf, atest = false; end
806 if out2.x(1) ~= f1, atest = false; end
807 if out2.x(end) ~= f2, atest = false; end
808 if numel(out2.x) ~= nf, atest = false; end
809 if out3.x(1) ~= f1, atest = false; end
810 if out3.x(end) ~= f2, atest = false; end
811 if numel(out3.x) ~= nf, atest = false; end
812 if out4.x(1) ~= f1, atest = false; end
813 if out4.x(end) ~= f2, atest = false; end
814 if numel(out4.x) ~= nf, atest = false; end
815 % Check the rebuilding of the object
816 if ~eq(out1, mout1, ple2), atest = false; end
817 if ~eq(out2, mout2, ple2), atest = false; end
818 if ~eq(out3, mout3, ple2), atest = false; end
819 if ~eq(out4, mout4, ple2), atest = false; end
820 % </AlgoCode>
821 else
822 atest = false;
823 end
824
825 % Return a result structure
826 result = utp_prepare_result(atest, stest, dbstack, mfilename);
827 end % END UTP_10
828
829 %% UTP_11
830
831 % <TestDescription>
832 %
833 % Check that the resp method uses the specified f-vector to compute the
834 % response.
835 %
836 % </TestDescription>
837 function result = utp_11
838
839 % <SyntaxDescription>
840 %
841 % Call the method with different method to pass an f-vector in.
842 %
843 % </SyntaxDescription>
844
845 try
846 % <SyntaxCode>
847 f1 = .1;
848 f2 = 5;
849 nf = 100;
850 f = linspace(f1, f2, nf);
851 out1 = resp(pf3, f);
852 out2 = resp(pf3, plist('f', f));
853
854 mout1 = rebuild(out1);
855 mout2 = rebuild(out2);
856 % </SyntaxCode>
857 stest = true;
858 catch err
859 disp(err.message)
860 stest = false;
861 end
862
863 % <AlgoDescription>
864 %
865 % 1) Check the output
866 % 2) Check that the 'rebuild' method produces the same object as 'out'.
867 %
868 % </AlgoDescription>
869
870 atest = true;
871 if stest
872 % <AlgoCode>
873 % Check the output
874 if ~isa(out1, 'ao'), atest = false; end
875 if ~isa(out2, 'ao'), atest = false; end
876 if out1.x(1) ~= f1, atest = false; end
877 if out1.x(end) ~= f2, atest = false; end
878 if numel(out1.x) ~= nf, atest = false; end
879 if out2.x(1) ~= f1, atest = false; end
880 if out2.x(end) ~= f2, atest = false; end
881 if numel(out2.x) ~= nf, atest = false; end
882 % Check the rebuilding of the object
883 if ~eq(out1, mout1, ple2), atest = false; end
884 if ~eq(out2, mout2, ple2), atest = false; end
885 % </AlgoCode>
886 else
887 atest = false;
888 end
889
890 % Return a result structure
891 result = utp_prepare_result(atest, stest, dbstack, mfilename);
892 end % END UTP_11
893
894 %% UTP_12
895
896 % <TestDescription>
897 %
898 % Check that the resp method uses the specified f1, f2, and nf to compute the response.
899 %
900 % </TestDescription>
901 function result = utp_12
902
903 % <SyntaxDescription>
904 %
905 % Call the method with different method to pass f1, f2, and nf in.
906 %
907 % </SyntaxDescription>
908
909 try
910 % <SyntaxCode>
911 f1 = .1;
912 f2 = 5;
913 nf = 100;
914 nf2 = 123;
915 out1 = resp(pf3, f1, f2);
916 out2 = resp(pf3, f1, f2, nf);
917 out3 = resp(pf3, plist('f1', f1, 'f2', f2, 'nf', nf));
918 out4 = resp(pf3, plist('f1', f1, 'nf', nf2));
919 out5 = resp(pf3, plist('f2', f2));
920
921 mout1 = rebuild(out1);
922 mout2 = rebuild(out2);
923 mout3 = rebuild(out3);
924 mout4 = rebuild(out4);
925 mout5 = rebuild(out5);
926 % </SyntaxCode>
927 stest = true;
928 catch err
929 disp(err.message)
930 stest = false;
931 end
932
933 % <AlgoDescription>
934 %
935 % 1) Check the output
936 % 2) Check that the 'rebuild' method produces the same object as 'out'.
937 %
938 % </AlgoDescription>
939
940 atest = true;
941 T = 10e-12;
942 if stest
943 % <AlgoCode>
944 % Check the output
945 f1d = getlowerFreq(pf3)/10;
946 f2d = getupperFreq(pf3)*10;
947 nfd = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
948 if ~isa(out1, 'ao'), atest = false; end
949 if ~isa(out2, 'ao'), atest = false; end
950 if ~isa(out3, 'ao'), atest = false; end
951 if ~isa(out4, 'ao'), atest = false; end
952 if ~isa(out5, 'ao'), atest = false; end
953 if out1.x(1) ~= f1, atest = false; end
954 if abs(out1.x(end)-f2)>T, atest = false; end
955 if numel(out1.x) ~= nfd, atest = false; end % Default values
956 if out2.x(1) ~= f1, atest = false; end
957 if abs(out2.x(end)-f2)>T, atest = false; end
958 if numel(out2.x) ~= nf, atest = false; end
959 if out3.x(1) ~= f1, atest = false; end
960 if abs(out3.x(end)-f2)>T, atest = false; end
961 if numel(out3.x) ~= nf, atest = false; end
962 if out4.x(1) ~= f1, atest = false; end
963 if abs(out4.x(end) - f2d) > T, atest = false; end % Default values
964 if numel(out4.x) ~= nf2, atest = false; end
965 if abs(out5.x(1) -f1d)>T, atest = false; end % Default values
966 if abs(out5.x(end)-f2)>T, atest = false; end
967 if numel(out5.x) ~= nfd, atest = false; end % Default values
968 % Check the rebuilding of the object
969 if ~eq(out1, mout1, ple2), atest = false; end
970 if ~eq(out2, mout2, ple2), atest = false; end
971 if ~eq(out3, mout3, ple2), atest = false; end
972 if ~eq(out4, mout4, ple2), atest = false; end
973 if ~eq(out5, mout5, ple2), atest = false; end
974 % </AlgoCode>
975 else
976 atest = false;
977 end
978
979 % Return a result structure
980 result = utp_prepare_result(atest, stest, dbstack, mfilename);
981 end % END UTP_12
982
983 %% UTP_13
984
985 % <TestDescription>
986 %
987 % Check that the resp method uses the specified f1, f2, and nf to compute
988 % the response.
989 %
990 % </TestDescription>
991 function result = utp_13
992
993 % <SyntaxDescription>
994 %
995 % Call the method with different method to pass f1, f2, and nf in.
996 %
997 % </SyntaxDescription>
998
999 try
1000 % <SyntaxCode>
1001 f1 = .1;
1002 f2 = 5;
1003 nf = 123;
1004 out1 = resp(pf3, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'lin'));
1005 out2 = resp(pf3, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'log'));
1006 out3 = resp(pf3, plist('scale', 'lin'));
1007 out4 = resp(pf3, plist('scale', 'log'));
1008
1009 mout1 = rebuild(out1);
1010 mout2 = rebuild(out2);
1011 mout3 = rebuild(out3);
1012 mout4 = rebuild(out4);
1013 % </SyntaxCode>
1014 stest = true;
1015 catch err
1016 disp(err.message)
1017 stest = false;
1018 end
1019
1020 % <AlgoDescription>
1021 %
1022 % 1) Check the output
1023 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1024 %
1025 % </AlgoDescription>
1026
1027 atest = true;
1028 if stest
1029 % <AlgoCode>
1030 % Check the output
1031 f1d = getlowerFreq(pf3)/10;
1032 f2d = getupperFreq(pf3)*10;
1033 nfd = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
1034 if ~isa(out1, 'ao'), atest = false; end
1035 if ~isa(out2, 'ao'), atest = false; end
1036 if ~isa(out3, 'ao'), atest = false; end
1037 if ~isa(out4, 'ao'), atest = false; end
1038 xlin1 = linspace(f1, f2, nf);
1039 xlin2 = linspace(f1d, f2d, nfd);
1040 xlog1 = logspace(log10(f1), log10(f2), nf);
1041 xlog2 = logspace(log10(f1d), log10(f2d), nfd);
1042 if ~isequal(xlin1, out1.x'), atest = false; end
1043 if ~isequal(xlin2, out3.x'), atest = false; end
1044 if ~isequal(xlog1, out2.x'), atest = false; end
1045 if ~isequal(xlog2, out4.x'), atest = false; end
1046
1047 % Check the rebuilding of the object
1048 if ~eq(out1, mout1, ple2), atest = false; end
1049 if ~eq(out2, mout2, ple2), atest = false; end
1050 if ~eq(out3, mout3, ple2), atest = false; end
1051 if ~eq(out4, mout4, ple2), atest = false; end
1052 % </AlgoCode>
1053 else
1054 atest = false;
1055 end
1056
1057 % Return a result structure
1058 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1059 end % END UTP_13
1060
1061 end