1 | %VERBOSE class definition
|
---|
2 | %
|
---|
3 | % Available verbosity levels:
|
---|
4 | % mprocessor : model processing
|
---|
5 | % module : modules
|
---|
6 | % solution : solution sequence
|
---|
7 | % solver : solver info (extensive)
|
---|
8 | % convergence : convergence criteria
|
---|
9 | % control : control method
|
---|
10 | % qmu : sensitivity analysis
|
---|
11 | % autodiff : AD analysis
|
---|
12 | %
|
---|
13 | % Usage:
|
---|
14 | % verbose=verbose();
|
---|
15 | % verbose=verbose(3);
|
---|
16 | % verbose=verbose('all');
|
---|
17 | % verbose=verbose('001100');
|
---|
18 | % verbose=verbose('module',true,'solver',false);
|
---|
19 |
|
---|
20 | %WARNING: some parts of this file are Synchronized with src/c/shared/Numerics/Verbosity.h
|
---|
21 | % Do not modify these sections. See src/c/shared/Numerics/README for more info
|
---|
22 |
|
---|
23 | classdef verbose
|
---|
24 | properties (SetAccess=public)
|
---|
25 | % {{{
|
---|
26 | %BEGINFIELDS
|
---|
27 | mprocessor=false;
|
---|
28 | module=false;
|
---|
29 | solution=false;
|
---|
30 | solver=false;
|
---|
31 | convergence=false;
|
---|
32 | control=false;
|
---|
33 | qmu=false;
|
---|
34 | autodiff=false;
|
---|
35 | %ENDFIELDS
|
---|
36 | % }}}
|
---|
37 | end
|
---|
38 | %}}}
|
---|
39 | methods
|
---|
40 | function verbose=verbose(varargin) % {{{
|
---|
41 |
|
---|
42 | switch(nargin),
|
---|
43 | case 0,
|
---|
44 | verbose.solution=true;
|
---|
45 | verbose.qmu=true;
|
---|
46 | verbose.control=true;
|
---|
47 | case 1,
|
---|
48 | binary=varargin{1};
|
---|
49 | if ischar(binary),
|
---|
50 | if strcmpi(binary,'all'),
|
---|
51 | binary=2^11-1; %all ones
|
---|
52 | verbose=BinaryToVerbose(verbose,binary);
|
---|
53 | verbose.solver=false; %Do not use by default
|
---|
54 | else
|
---|
55 | binary=bin2dec(binary);
|
---|
56 | verbose=BinaryToVerbose(verbose,binary);
|
---|
57 | end
|
---|
58 | elseif isnumeric(binary),
|
---|
59 | verbose=BinaryToVerbose(verbose,binary);
|
---|
60 | end
|
---|
61 | otherwise,
|
---|
62 | %Use options to initialize object
|
---|
63 | verbose=AssignObjectFields(pairoptions(varargin{:}),verbose);
|
---|
64 |
|
---|
65 | %Cast to logicals
|
---|
66 | listproperties=properties('verbose');
|
---|
67 | for i=1:numel(listproperties),
|
---|
68 | fieldname=listproperties{i};
|
---|
69 | fieldvalue=verbose.(fieldname);
|
---|
70 | if (islogical(fieldvalue) | isnumeric(fieldvalue)) & numel(fieldvalue)==1,
|
---|
71 | verbose.(fieldname)=logical(fieldvalue);
|
---|
72 | else
|
---|
73 | error('verbose supported field values are logicals only (true or false)');
|
---|
74 | end
|
---|
75 | end
|
---|
76 | end
|
---|
77 | end
|
---|
78 | %}}}
|
---|
79 | function binary=VerboseToBinary(verbose) % {{{
|
---|
80 |
|
---|
81 | %BEGINVERB2BIN
|
---|
82 | binary=0;
|
---|
83 | if (verbose.mprocessor), binary=bitor(binary,1); end
|
---|
84 | if (verbose.module), binary=bitor(binary,2); end
|
---|
85 | if (verbose.solution), binary=bitor(binary,4); end
|
---|
86 | if (verbose.solver), binary=bitor(binary,8); end
|
---|
87 | if (verbose.convergence), binary=bitor(binary,16); end
|
---|
88 | if (verbose.control), binary=bitor(binary,32); end
|
---|
89 | if (verbose.qmu), binary=bitor(binary,64); end
|
---|
90 | if (verbose.autodiff), binary=bitor(binary,128); end
|
---|
91 | %ENDVERB2BIN
|
---|
92 |
|
---|
93 | end
|
---|
94 | %}}}
|
---|
95 | function verbose=BinaryToVerbose(verbose,binary) % {{{
|
---|
96 |
|
---|
97 | %BEGINBIN2VERB
|
---|
98 | if bitand(binary,1), verbose.mprocessor=true; else verbose.mprocessor=false; end
|
---|
99 | if bitand(binary,2), verbose.module=true; else verbose.module=false; end
|
---|
100 | if bitand(binary,4), verbose.solution=true; else verbose.solution=false; end
|
---|
101 | if bitand(binary,8), verbose.solver=true; else verbose.solver=false; end
|
---|
102 | if bitand(binary,16), verbose.convergence=true; else verbose.convergence=false; end
|
---|
103 | if bitand(binary,32), verbose.control=true; else verbose.control=false; end
|
---|
104 | if bitand(binary,64), verbose.qmu=true; else verbose.qmu=false; end
|
---|
105 | if bitand(binary,128), verbose.autodiff=true; else verbose.autodiff=false; end
|
---|
106 | %ENDBIN2VERB
|
---|
107 |
|
---|
108 | end
|
---|
109 | %}}}
|
---|
110 | function md = checkconsistency(obj,md,solution,analyses) % {{{
|
---|
111 |
|
---|
112 | end % }}}
|
---|
113 | function disp(verbose) % {{{
|
---|
114 |
|
---|
115 | %BEGINDISP
|
---|
116 | disp(sprintf('class ''%s'' = ',class(verbose)));
|
---|
117 | disp(sprintf(' %15s : %s','mprocessor',mat2str(verbose.mprocessor)));
|
---|
118 | disp(sprintf(' %15s : %s','module',mat2str(verbose.module)));
|
---|
119 | disp(sprintf(' %15s : %s','solution',mat2str(verbose.solution)));
|
---|
120 | disp(sprintf(' %15s : %s','solver',mat2str(verbose.solver)));
|
---|
121 | disp(sprintf(' %15s : %s','convergence',mat2str(verbose.convergence)));
|
---|
122 | disp(sprintf(' %15s : %s','control',mat2str(verbose.control)));
|
---|
123 | disp(sprintf(' %15s : %s','qmu',mat2str(verbose.qmu)));
|
---|
124 | disp(sprintf(' %15s : %s','autodiff',mat2str(verbose.autodiff)));
|
---|
125 | %ENDDISP
|
---|
126 |
|
---|
127 | end
|
---|
128 | %}}}
|
---|
129 | function marshall(obj,md,fid) % {{{
|
---|
130 | WriteData(fid,'data',VerboseToBinary(obj),'enum',VerboseEnum(),'format','Integer');
|
---|
131 | end % }}}
|
---|
132 | end
|
---|
133 | end
|
---|