0001 function acceptMeas = validateMeasureDataDec(dec, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 if ~isfield(dec, 'measureData')
0062 error('elk:decomposition:wrongInput', ...
0063 'The decomposition does not contain measure data');
0064 end
0065
0066
0067 [measureNameList, detailed, zerotol, verbose] = mapOption(varargin, ...
0068 'measure', fieldnames(dec.measureData),...
0069 'detailed', 0, ...
0070 'zerotol', elkZerotol, ...
0071 'verbose', 1);
0072
0073
0074 if ~iscell(measureNameList)
0075 measureNameList = {measureNameList};
0076 end
0077
0078
0079
0080 coefficientTest = ones([length(measureNameList), ...
0081 dec.nPS]);
0082 vectorHcTest = coefficientTest;
0083 vectorLamTest = coefficientTest;
0084
0085
0086 for iMeasure = 1:length(measureNameList)
0087
0088 thisMeasure = dec.measureData.(measureNameList{iMeasure});
0089
0090
0091 for iSimplex = 1:dec.nPS
0092
0093 thisSimplex = dec.simplexPartition{iSimplex};
0094 referenceIndex = find(...
0095 dec.simplexToUnifiedVector == dec.simplexToUnifiedVector(iSimplex), ...
0096 1, 'first');
0097
0098 thisSampleLam = ones(1, dec.nC);
0099 thisSampleHc = thisSampleLam * dec.se(thisSimplex.seIndexVector, :);
0100
0101 if thisMeasure.isPar
0102
0103 for iPar = 1:length(thisMeasure.tensorSe)
0104
0105 thisError = thisMeasure.tensorHc{iPar}{iSimplex}(:) ...
0106 - thisMeasure.tensorHc{iPar}{referenceIndex}(:);
0107 thisTest = all(isZero(thisError, zerotol));
0108
0109 if thisTest == 0 && verbose
0110 disp(['[-] (T1) - Validation of [' thisMeasure.name ...
0111 ', ' num2str(iPar) ...
0112 '] failed: tensor of simplex partition ' ...
0113 num2str(referenceIndex) ' and ' num2str(iSimplex) ...
0114 ' do not match (max error: ' ...
0115 num2str(max(abs(thisError))) ').']);
0116 end
0117
0118 coefficientTest(iMeasure, iSimplex) = ...
0119 coefficientTest(iMeasure, iSimplex) & thisTest;
0120
0121
0122 referenceMeasure = thisMeasure.handleH(...
0123 dec.mappingReducedToFull*thisSampleHc', ...
0124 thisMeasure.par(iPar, :));
0125 hcMeasure = computeMeasureDec(dec, ...
0126 'hc', {iSimplex, thisSampleHc}, ...
0127 {thisMeasure.name, thisMeasure.par(iPar, :)}, ...
0128 zerotol, 1);
0129 lamMeasure = computeMeasureDec(dec, ...
0130 'se', {iSimplex, thisSampleLam}, ...
0131 {thisMeasure.name, thisMeasure.par(iPar, :)}, ...
0132 zerotol, 1);
0133
0134
0135 thisTest = isZero(hcMeasure - referenceMeasure, zerotol);
0136
0137 if thisTest == 0 && verbose
0138 disp(['[-] (T2) - Validation of [' thisMeasure.name ...
0139 ', ' num2str(iPar) ...
0140 '] failed: measure for hC-vector of partition ' ...
0141 num2str(iSimplex) ' is wrong. (max error: '...
0142 num2str(abs(max(hcMeasure(:) - referenceMeasure(:)))) ...
0143 ')']);
0144 end
0145
0146 vectorHcTest(iMeasure, iSimplex) = ...
0147 vectorHcTest(iMeasure, iSimplex) & thisTest;
0148
0149
0150 thisTest = isZero(lamMeasure - referenceMeasure, zerotol);
0151
0152 if thisTest == 0 && verbose
0153 disp(['[-] (T2) - Validation of [' thisMeasure.name ...
0154 ', ' num2str(iPar) ...
0155 '] failed: measure for lambda-vector of partition ' ...
0156 num2str(iSimplex) ' is wrong.']);
0157 end
0158
0159 vectorLamTest(iMeasure, iSimplex) = ...
0160 vectorLamTest(iMeasure, iSimplex) & thisTest;
0161 end
0162
0163 else
0164
0165 thisError = thisMeasure.tensorHc{iSimplex}(:) ...
0166 - thisMeasure.tensorHc{referenceIndex}(:);
0167 thisTest = all(isZero(thisError, zerotol));
0168
0169 if thisTest == 0 && verbose
0170 disp(['[-] (T1) - Validation of [' thisMeasure.name ...
0171 '] failed: tensor of simplex partition ' ...
0172 num2str(referenceIndex) ' and ' num2str(iSimplex) ...
0173 ' do not match (max error: ' ...
0174 num2str(max(abs(thisError))) ').']);
0175 end
0176
0177 coefficientTest(iMeasure, iSimplex) = ...
0178 coefficientTest(iMeasure, iSimplex) & thisTest;
0179
0180
0181 referenceMeasure = thisMeasure.handleH(...
0182 dec.mappingReducedToFull*thisSampleHc');
0183 hcMeasure = computeMeasureDec(dec, ...
0184 'hc', {iSimplex, thisSampleHc}, thisMeasure.name, ...
0185 zerotol, 1);
0186 lamMeasure = computeMeasureDec(dec, ...
0187 'se', {iSimplex, thisSampleLam}, thisMeasure.name, ...
0188 zerotol, 1);
0189
0190
0191 thisError = hcMeasure - referenceMeasure;
0192 thisTest = isZero(thisError, zerotol);
0193
0194 if thisTest == 0 && verbose
0195 disp(['[-] (T2) - Validation of [' thisMeasure.name ...
0196 '] failed: measure for hC-vector of partition ' ...
0197 num2str(iSimplex) ' is wrong. (max error: '...
0198 num2str(max(abs(thisError(:)))) ')']);
0199 end
0200
0201 vectorHcTest(iMeasure, iSimplex) = ...
0202 vectorHcTest(iMeasure, iSimplex) & thisTest;
0203
0204
0205 thisError = lamMeasure - referenceMeasure;
0206 thisTest = isZero(lamMeasure - referenceMeasure, zerotol);
0207
0208 if thisTest == 0 && verbose
0209 disp(['[-] (T2) - Validation of [' thisMeasure.name ...
0210 '] failed: measure for lambda-vector of partition ' ...
0211 num2str(iSimplex) ' is wrong. (max error: '...
0212 num2str(max(abs(thisError(:)))) ')']);
0213 end
0214
0215 vectorLamTest(iMeasure, iSimplex) = ...
0216 vectorLamTest(iMeasure, iSimplex) & thisTest;
0217
0218 end
0219
0220 end
0221
0222 dec.meas.(measureNameList{iMeasure}) = thisMeasure;
0223 end
0224
0225 if ~detailed
0226 acceptMeas = prod(prod([coefficientTest, vectorHcTest, vectorLamTest]));
0227 else
0228 acceptMeas = [coefficientTest; vectorHcTest; vectorLamTest];
0229 end