Changeset 25222
- Timestamp:
- 07/06/20 20:09:46 (5 years ago)
- Location:
- issm/trunk-jpl/src/m/classes/qmu
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/qmu/histogram_bin_uncertain.m
r25097 r25222 1 1 %HISTOGRAM BIN UNCERTAIN class definition 2 2 % 3 % [hbu]=histogram_bin_uncertain(varargin) 3 % Usage: 4 % hbu=histogram_bin_uncertain('descriptor',descriptor,'pairs_per_variable',pairs_per_variable,... 5 % 'abscissas',abscissas,'counts',counts,'partition',partition) 6 % 7 % where hbu is the histogram_bin_uncertain object returned by the constructor, pairs_per_variable the 8 % size of the histogram, 'abscissas' and 'counts' describe the histogram itself. 9 % If the variable is distributed, then a partition vector can be supplied, which can be a 10 % partition vector over elements or vertices. In which case counts, 4 11 % 5 % where the required varargin are: 6 % descriptor (char, description, '') 7 % pairs_per_variable (double vector, []) 8 % abscissas (double vector, []) 9 % counts (int vector, []) 10 % 11 % NOTE: A call to the constructor with zero arguments will return a default 12 % instance; one argument of the class copies the instance; three or more 13 % arguments constructs a new instance from the arguments. 14 % 12 % Example: 13 % md.qmu.variables.giaid=histogram_bin_uncertain('descriptor','GiammeModelId','pairs_per_variable',3,... 14 % 'count',[.6 .4 0],''abscissas',[1 2 3]); 15 % md.qmu.variables.surfaceloadid=histogram_bin_uncertain(... 16 % 'descriptor','distributed_SurfaceloadModelId','pairs_per_variable',[2 3 4],... 17 % 'counts',{[1 0],[.6 .4 0],[.4 .4 .2 0]},... 18 % 'abscissas',{[1 2],[1 2 3],[1 2 3 4]},... 19 % 'partition',partition_vector); 20 15 21 classdef histogram_bin_uncertain 16 22 properties 17 23 descriptor=''; 18 pairs_per_variable= [];19 abscissas = [];24 pairs_per_variable={}; 25 abscissas = {}; 20 26 counts = []; 27 partition=[]; 21 28 end 22 29 methods 23 function [hbu]=histogram_bin_uncertain(varargin) % {{{ 24 switch nargin 25 case 0 % create a default object 26 case 1 % copy the object 27 if isa(varargin{1},'histogram_bin_uncertain') 28 hbu=varargin{1}; 29 else 30 error('Object ''%s'' is a ''%s'' class object, not ''%s''.',... 31 inputname(1),class(varargin{1}),'histogram_bin_uncertain'); 32 end 33 case {2,3} % not enough arguments 34 error('Construction of ''histogram_bin_uncertain'' class object requires at least %d inputs.',4) 35 case 4 % 36 % create the object from the input 37 hbu = histogram_bin_uncertain; 38 hbu.descriptor=varargin{1}; 39 hbu.pairs_per_variable=varargin{2}; 40 hbu.abscissas=varargin{3}; 41 hbu.counts=varargin{4}; 30 function self=histogram_bin_uncertain(varargin) % {{{ 31 32 %recover options: 33 options=pairoptions(varargin{:}); 42 34 43 otherwise 44 error('Construction of histogram_bin_uncertain class object requires either (1) no arguments, (2) a histogram_bin_uncertain instance to copy from, or (3) a descriptor and pairs per variable, abscissas, and counts lists'); 35 %initialize fields: 36 self.descriptor=getfieldvalue(options,'descriptor'); 37 self.pairs_per_variable=getfieldvalue(options,'pairs_per_variable'); 38 self.abscissas=getfieldvalue(options,'abscissas'); 39 self.counts=getfieldvalue(options,'counts'); 40 41 %if the variable is distributed, a partition vector should have been 42 %supplied, and that partition vector should have as many partitions 43 %as the pairs_per_variable, abscissas and counts arrays: 44 if self.isdistributed(), 45 self.partition=getfieldvalue(options,'partition'); 46 npart=qmupart2npart(self.partition); 47 if npart~=length(self.pairs_per_variable), 48 error(sprintf('histogram_bin_uncertain constructor: for the distributed variable %s the number of pairs_per_variable arrays (%i) should be equal to the number of partitions (%i)',self.descriptor,length(self.pairs_per_variable),npart)); 49 end 50 if npart~=length(self.abscissas), 51 error(sprintf('histogram_bin_uncertain constructor: for the distributed variable %s the number of abscissas arrays (%i) should be equal to the number of partitions (%i)',self.descriptor,length(self.abscissas),npart)); 52 end 53 if npart~=length(self.counts), 54 error(sprintf('histogram_bin_uncertain constructor: for the distributed variable %s the size of counts (%i) should be equal to the number of partitions (%i)',self.descriptor,length(self.counts),npart)); 55 end 45 56 end 46 57 end % }}} 47 58 function md=checkconsistency(self,md,solution,analyses) % {{{ 48 59 end % }}} 49 function []=disp(hbu) % {{{ 50 % display the object 51 disp(sprintf('\n')); 52 for i=1:numel(hbu) 53 disp(sprintf('class ''%s'' object ''%s%s'' = \n',... 54 class(hbu),inputname(1),string_dim(hbu,i))); 55 disp(sprintf(' descriptor: ''%s''' ,hbu(i).descriptor)); 56 disp(sprintf(' pairs_per_variable: %g' ,hbu(i).pairs_per_variable)); 57 disp(sprintf(' abscissas: %g' ,hbu(i).abscissas)); 58 disp(sprintf(' counts: %g' ,hbu(i).counts)); 59 end 60 end % }}} 60 function disp(self) % {{{ 61 disp(sprintf(' histogram_bin uncertain variable: ')); 62 fielddisplay(self,'descriptor','name tag'); 63 fielddisplay(self,'pairs_per_variable','number of bins in histogram'); 64 fielddisplay(self,'abscissas','abscissas for histogram'); 65 fielddisplay(self,'counts','probabilities for histogram'); 66 if ~isempty(self.partition), 67 fielddisplay(self,'partition','partition vector defining where sampling will occur'); 68 end 69 end 70 %}}} 61 71 %virtual functions needed by qmu processing algorithms: 62 72 %implemented: … … 88 98 upper=[]; 89 99 end % }}} 100 function [pairs_per_variable] =prop_pairs_per_variable(hbu) % {{{ 101 pairs_per_variable=[]; 102 for i=1:numel(hbu) 103 pairs_per_variable=[pairs_per_variable hbu(i).pairs_per_variable]; 104 end 105 end % }}} 90 106 function [abscissas]=prop_abscissas(hbu) % {{{ 91 107 abscissas=[]; 92 108 for i=1:numel(hbu) 93 abscissas=[abscissas hbu(i).abscissas ];109 abscissas=[abscissas hbu(i).abscissas']; 94 110 end 95 111 abscissas=allequal(abscissas,-Inf); 96 112 end % }}} 97 function [pairs_per_variable] =prop_pairs_per_variable(hbu) % {{{98 pairs_per_variable=zeros(1,numel(hbu));99 for i=1:numel(hbu)100 pairs_per_variable(i)=hbu(i).pairs_per_variable;101 end102 pairs_per_variable=allequal(pairs_per_variable,-Inf);103 end % }}}104 113 function [counts] =prop_counts(hbu) % {{{ 105 114 counts=[]; 106 115 for i=1:numel(hbu) 107 counts=[counts hbu(i).counts ];116 counts=[counts hbu(i).counts']; 108 117 end 109 118 counts=allequal(counts,-Inf); … … 128 137 end 129 138 end % }}} 139 function distributed=isdistributed(self) % {{{ 140 if strncmp(self.descriptor,'distributed_',12), 141 distributed=1; 142 else 143 distributed=0; 144 end 145 end % }}} 130 146 end 131 147 methods (Static) -
issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.m
r25097 r25222 161 161 end % }}} 162 162 %new methods: 163 function scaled=isscaled(self) % {{{ 163 function distributed=isdistributed(self) % {{{ 164 if strncmp(self.descriptor,'distributed_',12), 165 distributed=1; 166 else 167 distributed=0; 168 end 169 end % }}} 170 function scaled=isscaled(self) % {{{ 164 171 if strncmp(self.descriptor,'scaled_',7), 165 172 scaled=1; -
issm/trunk-jpl/src/m/classes/qmu/uniform_uncertain.m
r25105 r25222 164 164 end % }}} 165 165 %new methods: 166 function scaled=isscaled(self) % {{{ 166 function distributed=isdistributed(self) % {{{ 167 if strncmp(self.descriptor,'distributed_',12), 168 distributed=1; 169 else 170 distributed=0; 171 end 172 end % }}} 173 function scaled=isscaled(self) % {{{ 167 174 if strncmp(self.descriptor,'scaled_',7), 168 175 scaled=1;
Note:
See TracChangeset
for help on using the changeset viewer.