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