0001 function [hcMatrix, upVector, fractionCorrected] = ensureProperDecData(...
0002 hcMatrixDynamic, upVector, pbeDef)
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 nDecCoordinate = pbeDef.nDecCoordinate;
0028 rowFilter = false(1, size(hcMatrixDynamic, 1));
0029 rowFilter(1:pbeDef.nDecCoordinate) = true;
0030
0031 if isempty(hcMatrixDynamic)
0032 fractionCorrected = 0;
0033 return
0034 end
0035
0036 if ~pbeDef.dec.isComplete
0037 fractionCorrected = 0;
0038 return
0039 end
0040
0041
0042
0043 tolVector = computePositionTolVector(hcMatrixDynamic(1:nDecCoordinate, :), pbeDef.optionStruct);
0044
0045
0046
0047
0048 correctFilter = false(size(upVector));
0049
0050
0051 hcMatrix = hcMatrixDynamic;
0052
0053
0054 if ~pbeDef.dec.isComplete
0055
0056 upVector = ones(1, size(hcMatrix, 2));
0057
0058
0059 if pbeDef.optionStruct.useEmbeddingPartitions
0060 hcMatrix(rowFilter, :) = pbeDef.dec.properEmbedding.mappingNewToProper * ...
0061 hcMatrix(rowFilter, :);
0062 end
0063 end
0064
0065
0066 if (pbeDef.dec.isProper && pbeDef.dec.isComplete) || ...
0067 ~pbeDef.optionStruct.useEmbeddingPartitions
0068
0069
0070
0071
0072
0073 if ~pbeDef.optionStruct.limitGrowthRate
0074 hcMatrix(rowFilter, :) = mapToConfinementCone(...
0075 hcMatrix(rowFilter, :), pbeDef.dec);
0076 end
0077
0078
0079 for upIndex = 1:pbeDef.dec.nPU
0080
0081 thisFilter = upVector == upIndex;
0082
0083 if ~any(thisFilter), continue;end;
0084
0085
0086
0087 thisFilter(thisFilter) = max(...
0088 pbeDef.dec.unifiedPartition{upIndex}.A * ...
0089 hcMatrix(1:pbeDef.nDecCoordinate, thisFilter), ...
0090 [], 1) > tolVector(thisFilter);
0091
0092
0093 if any(thisFilter)
0094
0095
0096 if pbeDef.optionStruct.limitGrowthRate
0097 hcMatrix(rowFilter, thisFilter) = mapToConfinementCone(...
0098 hcMatrix(rowFilter, thisFilter), pbeDef.dec);
0099 end
0100
0101 upVector(thisFilter) = computePartitionIndexDec(...
0102 pbeDef.dec, hcMatrix(rowFilter, thisFilter), ...
0103 tolVector(thisFilter), 1);
0104
0105 correctFilter = correctFilter | thisFilter;
0106 end
0107
0108 end
0109 elseif pbeDef.optionStruct.useEmbeddingPartitions
0110
0111
0112 hcMatrixLocal = pbeDef.dec.properData.mappingNewToProper * ...
0113 hcMatrix(rowFilter, :);
0114
0115 hcMatrixLocal = mapToConfinementCone(...
0116 hcMatrixLocal, pbeDef.dec.properData);
0117
0118
0119 for upIndex = 1:pbeDef.dec.properData.nPU
0120
0121 thisFilter = upVector == upIndex;
0122
0123 if ~any(thisFilter), continue;end;
0124
0125
0126
0127 thisFilter(thisFilter) = max(...
0128 pbeDef.dec.properData.unifiedPartition{upIndex}.A * ...
0129 hcMatrixLocal(:, thisFilter), ...
0130 [], 1) > tolVector(thisFilter);
0131
0132
0133 if any(thisFilter)
0134 hcMatrixLocal(:, thisFilter) = mapToConfinementCone(...
0135 hcMatrixLocal(:, thisFilter), pbeDef.dec.properData);
0136
0137 upVector(thisFilter) = computePartitionIndexDec(...
0138 pbeDef.dec.properData, hcMatrixLocal(:, thisFilter), ...
0139 tolVector(thisFilter), 1);
0140
0141 correctFilter = correctFilter | thisFilter;
0142 end
0143
0144 end
0145
0146
0147 hcMatrix = [hcMatrixLocal; hcMatrix(~rowFilter, :)];
0148 else
0149 error('elk:pbeSolver:inputError', ['The given representation is neither ' ...
0150 'proper, nor improper but complete, nor incomplete. This does not ' ...
0151 'makes sense. Please check your decomposition, dude.']);
0152 end
0153
0154
0155 if any(correctFilter)
0156 fractionCorrected = sum(correctFilter) / length(correctFilter);
0157 else
0158 fractionCorrected = 0;
0159 end