KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DPCM.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
17 class DPCM {
112  public: /* ( Constant ) */
113 
114  static const .cell PropClasses = {"'critical','important','alglimit','scaling','optional','data','experimental','verbose'"};
128  static const .char PropClassesLink = "matlab:help DPCM";
140  public: /* ( Static ) */ /* ( Constant ) */
141 
142 
143  static function getDPCMReport(DPCMobj,levels) {
144  if nargin < 2
145  levels = DPCM.PropClasses;
146  elseif ischar(levels)
147  levels = [levels];
148  end
149  msg = DPCM.runDPCM(DPCMobj, levels);
150  DPCM.printReport(msg, levels);
151  }
169  static function getDPCMSummary(DPCMobj,levels) {
170  if nargin < 2
171  levels = DPCM.PropClasses;
172  elseif ischar(levels)
173  levels = [levels];
174  end
175  [~, stats] = DPCM.runDPCM(DPCMobj, levels);
176  DPCM.printSummary(stats, levels);
177  }
192  static function criticalsCheck(DPCMobj) {
193  levels = DPCM.PropClasses(1);
194  [msg, stats] = DPCM.runDPCM(DPCMobj, levels);
195  if stats(1,1) > 0
196  if ~isempty(DPCMobj.WorkspaceVariableName)
197  link = sprintf(" <a href='matlab:DPCM.getDPCMReport(%s, "" critical "" )'>critical properties</a> ",DPCMobj.WorkspaceVariableName);
198  else
199  link = " critical properties ";
200  DPCM.printReport(msg, levels);
201  end
202  DPCM.print(" red ",[" RESULTS QUESTIONABLE: %d of %d " link " are still at their default value.\n "],...
203  stats(1,1),stats(2,1));
204  end
205  }
217  private: /* ( Static ) */ /* ( Constant ) */
218 
219 
220  static function printSummary(stats,levels) {
221  total = sum(stats,2);
222  total(3) = total(1)/total(2)*100;
223 
224  col = [total(3)/100 1-total(3)/100 0];
225  DPCM.print(col," Total unchanged properties: %d of %d (%2.2f%%%%)\n ",total);
226  for lidx = 1:length(levels)
227  col = [stats(3,lidx)/100 1-stats(3,lidx)/100 0];
228  lvidx = find(strcmp(levels[lidx],DPCM.PropClasses),1);
229  DPCM.print(col, " Unchanged "" %s "" : %d of %d (%2.2f%%%%)\n ",levels[lidx],stats(:,lvidx));
230  end
231  }
239  static function printReport(msg,levels) {
240  for idx = 1:length(levels)
241  m = msg.(levels[idx]);
242  if ~isempty(m)
243  DPCM.print([.5 .5 0]," Messages for property class %s:\n ",levels[idx]);
244  fprintf(" %s\n ",m[:]);
245  fprintf(" \n ");
246  end
247  end
248  }
256  static function print(varargin) {
257  if ~isempty(which(" cprintf "))
258  cprintf(varargin[:]);
259  else
260  fprintf(2,varargin[2:end]);
261  end
262  }
270  static function [msg , pstats ] = runDPCM(DPCMobj,levels) {
271  counts = struct;
272  notchanged = struct;
273  messages = struct;
274  for lidx=1:length(levels)
275  counts.(levels[lidx]) = 0;
276  messages.(levels[lidx]) = [];
277  end
278  notchanged = counts;
279 
280  /* % Run recursive check */
281  if isfield(DPCMobj," Name ") || isprop(DPCMobj," Name ")
282  n = DPCMobj.Name;
283  else
284  tmp = metaclass(DPCMobj);
285  n = tmp.Name;
286  end
287  recurCheck(DPCMobj, Dictionary, n);
288 
289  /* Store collected messages */
290  msg = messages;
291 
292  /* Some total stats now
293  *c = [struct2array(notchanged); struct2array(counts)]; */
294  c = cell2mat([struct2cell(notchanged) struct2cell(counts)])^t;
295  c(3,:) = round(10000 * c(1,:) ./ c(2,:))/100;
296  c(3,isnan(c(3,:))) = 0;
297  pstats = c;
298 
299  function recurCheck(DPCMobj, done, lvl)
300  mc = metaclass(DPCMobj);
301  done(DPCMobj.ID) = true;
302 
303  /* % Link name preparations */
304  objlink = editLink(mc.Name);
305 
306  /* % Check the local properties */
307  pc = DPCMobj.PropertiesChanged;
308  for pidx = 1:length(mc.Properties)
309  p = mc.Properties[pidx];
310  if strcmp(p.GetAccess," public ") && ~p.Constant && ~p.Transient && strcmp(p.SetAccess," public ") /* ~strcmp(p.SetAccess,'private') */
311 
312  key = [p.DefiningClass.Name " . " p.Name];
313  if pc.containsKey(key)
314  p = pc(key);
315  /* Ignore if property level is not wanted */
316  if any(strcmp(p.Level,levels))
317  counts.(p.Level) = counts.(p.Level) + 1;
318  if ~p.Changed
319  notchanged.(p.Level) = notchanged.(p.Level) + 1;
320  if ~any(strcmp(p.Level," data "))
321  hlp = messages.(p.Level);
322  /* if strcmp(mc.Name,p.) */
323  hlp[end+1] = sprintf(" %s is still unchanged!\nProperty brief: %s\nPropclass tag description:\n%s\n ",...
324  [lvl " [ " objlink " ] -> " p.Name],p.Short,p.Text);/* #ok */
325 
326  messages.(p.Level) = hlp;
327  end
328  end
329  end
330  elseif ~p.SetObservable && ~pc.containsKey([p.DefiningClass.Name " . " p.Name])
331 /* link2 = editLink(p.DefiningClass.Name);
332  * fprintf('Attention: Property %s of class %s is not <a href="matlab:docsearch SetObservable">SetObservable</a> but a candidate for a user-definable public property!\nFor more details see <a href="%s">Property classes and levels</a>\n\n',p.Name,link2,DPCM.PropClassesLink); */
333  end
334  pobj = DPCMobj.(p.Name);
335  /* Recursively register subobject's properties */
336  if isa(pobj, " DPCMObject ") && isempty(done(pobj.ID))
337  recurCheck(pobj, done, [lvl " [ " objlink " ] -> " p.Name]);
338  end
339  end
340  end
341  end
342 
343  function l = editLink(classname)
344  dotpos = strfind(classname," . ");
345  if ~isempty(dotpos)
346  lname = classname(dotpos(end)+1:end);
347  else
348  lname = classname;
349  end
350  l = sprintf(" <a href='matlab:edit %s'>%s</a> ",classname,lname);
351  end
352  }
366 };
367 
static function getDPCMReport(DPCMobj, levels)
Prints a detailed report about the properties at each level which have not been changed from their de...
Definition: DPCM.m:143
static const .char PropClassesLink
Change this value to a more expressive one, i.e. a link to your software documentation which includes...
Definition: DPCM.m:128
DPCMObject: Base object for any class participating in the DPCM system.
Definition: DPCMObject.m:17
DPCM: Default property change monitoring for MatLab class properties.
Definition: DPCM.m:17
A variable number of input arguments.
static function getDPCMSummary(DPCMobj, levels)
Prints a summary about the properties of different levels which have not been changed from their defa...
Definition: DPCM.m:169
A basic dictionary of key/value pairs for small to medium amounts of data.
Definition: Dictionary.m:17
static const .cell PropClasses
The known property classes.
Definition: DPCM.m:114
function count = cprintf(style, format, varargin)
CPRINTF displays styled formatted text in the Command Window.
Definition: cprintf.m:17
static function criticalsCheck(DPCMobj)
This is a shorthand method that runs the DPCM but only for critical properties.
Definition: DPCM.m:192