0001 function hcMatrix = mapFromProperEmbedding(heMatrix, dec, zerotol, ...
0002 partitionVector, enforcePartition)
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 if dec.isProper
0034 error(['elk:decomposition:inputError', 'The input decomposition is ' ...
0035 'supposed to be improper for this function.']);
0036
0037 end
0038 if ~dec.isComplete
0039
0040 hcMatrix = dec.properData.mappingProperToNew * heMatrix;
0041 return
0042 end
0043 if ~exist('zerotol', 'var') || isempty(zerotol)
0044 zerotol = elkZerotol;
0045 end
0046 if ~exist('partitionVector', 'var') || isempty(partitionVector)
0047 partitionVector = zeros(1, size(heMatrix, 2));
0048 processFilter = true(1, size(heMatrix, 2));
0049
0050 for iPart = 1:dec.nPU
0051 filterInPartition = processFilter;
0052 filterInPartition(processFilter) = max(...
0053 dec.unifiedPartition{iPart}.embeddingDomain.hrepStrict.A * ...
0054 heMatrix(:, processFilter), [], 1) < zerotol;
0055 partitionVector(filterInPartition) = iPart;
0056 processFilter(filterInPartition) = false;
0057
0058 if ~any(processFilter)
0059 break;
0060 end
0061 end
0062
0063
0064 if any(partitionVector == 0)
0065 error('elk:decomposition:indistinctError', ...
0066 ['the unified partition for some input vector could ' ...
0067 'not be found. This can have several causes, please check: ' ...
0068 '(1) whether your decomposition is ordinary, (2) whether ' ...
0069 'all input vectors describe a polytope of the input improper ' ...
0070 'decomposition, (3) otherwise, the decomposition was not ' ...
0071 'created properly and this should not happen.']);
0072 end
0073 end
0074
0075 if exist('enforcePartition', 'var') && enforcePartition
0076 for iPart = 1:dec.nPU
0077 thisFilter = partitionVector == iPart;
0078 heMatrix(:, thisFilter) = dec.unifiedPartition{iPart...
0079 }.embedding.validityProjection * heMatrix(:, thisFilter);
0080 end
0081 end
0082
0083 hcMatrix = nan(dec.nC, size(heMatrix, 2));
0084 for iPart = 1:dec.nPU
0085 thisFilter = partitionVector == iPart;
0086 hcMatrix(:, thisFilter) = ...
0087 dec.unifiedPartition{iPart}.projection.fromProper * ...
0088 heMatrix(:, thisFilter);
0089 end
0090
0091 if any(isnan(hcMatrix(:)))
0092 error(['elk:decomposition:wrongInput', 'Please check your input to ' ...
0093 'this function (partitionVector) as some vectors could not ' ...
0094 'be projected.']);
0095 end