validateMeasureDataDec

PURPOSE ^

validates the measure data in a decomposition structure

SYNOPSIS ^

function acceptMeas = validateMeasureDataDec(dec, varargin)

DESCRIPTION ^

 validates the measure data in a decomposition structure

 Syntax: acceptMeas = validateMeasureDataDec(dec)

 The measure data in dec is validated according to the following tests:
   (T1) The coefficient tensors for all simplex partitions that belong to
          the same unified partition must be equal. A failure here
          indicates either a failure in the conversion, a failure in
          the triangulation of the unified partitions or any prior step of
          the decomposition.
   (T2) The calculated measure of the polytope, the corresponding 
          hC-vector and the corresponding lambda-vector must be equal for 
          every partition. This step verifies the mixed volumes in
          tensorSe.

 validateMeasureDataDec(.., 'measure', measureNameList) let you specify
   the measures that are validated. Single parameters cannot be tested.
   measureNameList is a cell array of the field names of dec.measureData.
   Default: all fields of dec.measureData

 validateMeasureDataDec(.., 'zerotol', zerotol) sets the zerotol. 
   Default: elkZerotol

 validateMeasureDataDec(.., 'verbose', verbose) sets the verbosity. For 
   verbose=0, no messages are displayed, verbose=1 states which tests
   went wrong including some details about measure and partition. 
   Default: 1

 validateMeasureDataDec(.., 'detailed', detail) sets the format of the
   returned variable. With detail=0 only a single boolean is returned, 
   whether the validation was successful. With detail=1 a matrix is 
   returned where the row index is generated from the measures and the
   tests: the first third contains (T1), the second third contains the
   tests of the polytope measure against the measure by hC-vector and the
   last third contains the test of the polytope measure against the
   polytope measure against the lambda-vector. The columns are according
   to the simplex partitions. Default: 0

 See also: validateDec, addMeasureDataDec, computeMeasureDec

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function acceptMeas = validateMeasureDataDec(dec, varargin)
0002 % validates the measure data in a decomposition structure
0003 %
0004 % Syntax: acceptMeas = validateMeasureDataDec(dec)
0005 %
0006 % The measure data in dec is validated according to the following tests:
0007 %   (T1) The coefficient tensors for all simplex partitions that belong to
0008 %          the same unified partition must be equal. A failure here
0009 %          indicates either a failure in the conversion, a failure in
0010 %          the triangulation of the unified partitions or any prior step of
0011 %          the decomposition.
0012 %   (T2) The calculated measure of the polytope, the corresponding
0013 %          hC-vector and the corresponding lambda-vector must be equal for
0014 %          every partition. This step verifies the mixed volumes in
0015 %          tensorSe.
0016 %
0017 % validateMeasureDataDec(.., 'measure', measureNameList) let you specify
0018 %   the measures that are validated. Single parameters cannot be tested.
0019 %   measureNameList is a cell array of the field names of dec.measureData.
0020 %   Default: all fields of dec.measureData
0021 %
0022 % validateMeasureDataDec(.., 'zerotol', zerotol) sets the zerotol.
0023 %   Default: elkZerotol
0024 %
0025 % validateMeasureDataDec(.., 'verbose', verbose) sets the verbosity. For
0026 %   verbose=0, no messages are displayed, verbose=1 states which tests
0027 %   went wrong including some details about measure and partition.
0028 %   Default: 1
0029 %
0030 % validateMeasureDataDec(.., 'detailed', detail) sets the format of the
0031 %   returned variable. With detail=0 only a single boolean is returned,
0032 %   whether the validation was successful. With detail=1 a matrix is
0033 %   returned where the row index is generated from the measures and the
0034 %   tests: the first third contains (T1), the second third contains the
0035 %   tests of the polytope measure against the measure by hC-vector and the
0036 %   last third contains the test of the polytope measure against the
0037 %   polytope measure against the lambda-vector. The columns are according
0038 %   to the simplex partitions. Default: 0
0039 %
0040 % See also: validateDec, addMeasureDataDec, computeMeasureDec
0041 
0042 % The elk-library: convex geometry applied to crystallization modeling.
0043 %   Copyright (C) 2012 Alexander Reinhold
0044 %
0045 % This program is free software: you can redistribute it and/or modify it
0046 %   under the terms of the GNU General Public License as published by the
0047 %   Free Software Foundation, either version 3 of the License, or (at your
0048 %   option) any later version.
0049 %
0050 % This program is distributed in the hope that it will be useful, but
0051 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0052 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0053 %   General Public License for more details.
0054 %
0055 % You should have received a copy of the GNU General Public License along
0056 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0057 
0058 %% Input handling
0059 
0060 % cancel, if measure data does not exist
0061 if ~isfield(dec, 'measureData')
0062     error('elk:decomposition:wrongInput', ...
0063         'The decomposition does not contain measure data');
0064 end
0065 
0066 % options
0067 [measureNameList, detailed, zerotol, verbose] = mapOption(varargin, ...
0068     'measure', fieldnames(dec.measureData),...
0069     'detailed', 0, ...
0070     'zerotol', elkZerotol, ...
0071     'verbose', 1);
0072 
0073 % ensure measure is a cell-array
0074 if ~iscell(measureNameList)
0075     measureNameList = {measureNameList};
0076 end
0077 
0078 %% Perform check
0079 % starting with invalid assignements
0080 coefficientTest = ones([length(measureNameList), ...
0081                         dec.nPS]);
0082 vectorHcTest = coefficientTest;
0083 vectorLamTest = coefficientTest;
0084 
0085 
0086 for iMeasure = 1:length(measureNameList)
0087     % shortcut to measure
0088     thisMeasure = dec.measureData.(measureNameList{iMeasure});
0089     
0090     % for each measure, we cycle through the simplex partitions to check
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                 % coefficient test
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                 % get measures
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                 % hC-vector test
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                 % lambda-vector test
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             % coefficient test
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             % get measures
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             % hC-vector test
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             % lambda-vector test
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

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005