


map a hC vector to the cone of confined hC-vectors
Syntax: hcMapped = mapToConfinementCone(hcMatrix, dec)
Map all input hC-vectors in hcMatrix (each column a hC-vector) to
confined hC-vectors while preserving their shape. For improper
representations, this mapping is performed via the embedding proper
representation. For proper representation, this operation is equivalent
to mapToValidityCone.
With mapToConfinementCone(hcMatrix, dec, zerotol) you can also set the
applied tolerance for determining whether hC-vectors are confined or
not.
[hcMatrix, filterToZero] = mapToValidCone(..) returns a logical row
vector filterToZero that contains true for empty polytopes. Note that
empty polytopes (empty sets of points {}) cannot be represented by a
valid vector so that they must be represented by the origin, the set
{0}.
See also: obtainDec, validateDec, mapToValidityCone

0001 function [hcMatrix filterToZero] = mapToConfinementCone(hcMatrix, dec, ... 0002 zerotol) 0003 % map a hC vector to the cone of confined hC-vectors 0004 % 0005 % Syntax: hcMapped = mapToConfinementCone(hcMatrix, dec) 0006 % 0007 % Map all input hC-vectors in hcMatrix (each column a hC-vector) to 0008 % confined hC-vectors while preserving their shape. For improper 0009 % representations, this mapping is performed via the embedding proper 0010 % representation. For proper representation, this operation is equivalent 0011 % to mapToValidityCone. 0012 % 0013 % With mapToConfinementCone(hcMatrix, dec, zerotol) you can also set the 0014 % applied tolerance for determining whether hC-vectors are confined or 0015 % not. 0016 % 0017 % [hcMatrix, filterToZero] = mapToValidCone(..) returns a logical row 0018 % vector filterToZero that contains true for empty polytopes. Note that 0019 % empty polytopes (empty sets of points {}) cannot be represented by a 0020 % valid vector so that they must be represented by the origin, the set 0021 % {0}. 0022 % 0023 % See also: obtainDec, validateDec, mapToValidityCone 0024 0025 % The elk-library: convex geometry applied to crystallization modeling. 0026 % Copyright (C) 2013 Alexander Reinhold 0027 % 0028 % This program is free software: you can redistribute it and/or modify it 0029 % under the terms of the GNU General Public License as published by the 0030 % Free Software Foundation, either version 3 of the License, or (at your 0031 % option) any later version. 0032 % 0033 % This program is distributed in the hope that it will be useful, but 0034 % WITHOUT ANY WARRANTY; without even the implied warranty of 0035 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0036 % General Public License for more details. 0037 % 0038 % You should have received a copy of the GNU General Public License along 0039 % with this program. If not, see <http://www.gnu.org/licenses/>. 0040 0041 %% Input handling 0042 % define zerotol, if not provided 0043 if ~exist('zerotol', 'var') || isempty(zerotol) 0044 zerotol = elkZerotol; 0045 end 0046 0047 %% fallback: validity mapping 0048 % immediate jump to validity mapping 0049 if dec.isProper 0050 if nargout >= 2 0051 [hcMatrix filterToZero] = mapToValidityCone(hcMatrix, dec, ... 0052 zerotol); 0053 else 0054 hcMatrix = mapToValidityCone(hcMatrix, dec, zerotol); 0055 end 0056 % and thats it, already 0057 return 0058 end 0059 0060 %% general input handling 0061 % try to correct size of input 0062 if size(hcMatrix, 1) ~= dec.nC 0063 hcMatrix = hcMatrix'; 0064 end 0065 % define zerotol, if not provided 0066 if ~exist('zerotol', 'var') || isempty(zerotol) 0067 zerotol = elkZerotol; 0068 end 0069 % throw error for incomplete representations 0070 if isfield(dec, 'isComplete') && ~dec.isComplete 0071 error('elk:decomposition:inputError', ['Confinement mapping for ' ... 0072 'incomplete decompositions is not possible']); 0073 end 0074 0075 %% determine required processing 0076 % filter which vectors must be processed 0077 if dec.isOrdinary 0078 filterProcessThem = max(dec.confinementCone.A * hcMatrix, [], 1) > zerotol; 0079 else 0080 filterProcessThem = max(dec.confinementConeHull.A * hcMatrix, [], 1) > zerotol; 0081 end 0082 % return if there is nothing to do 0083 if isempty(hcMatrix) || ~any(filterProcessThem) 0084 if nargout >= 2,filterToZero = [];end 0085 return 0086 end 0087 0088 %% Mapping via proper representation 0089 filterToZero = zeros(1, size(hcMatrix, 2)); 0090 [heMatrix filterToZero(filterProcessThem)] = ... 0091 mapToValidityCone(dec.properData.mappingNewToProper * ... 0092 hcMatrix(:, filterProcessThem), dec.properData, 0); 0093 % map back to hC-representation - we don't provide partition data so it is 0094 % computed by mapFromProperEmbedding 0095 hcMatrix(:, filterProcessThem) = mapFromProperEmbedding(heMatrix, dec, ... 0096 zerotol + 10*eps); 0097 0098 %% handle output 0099 if nargout < 2 0100 clear filterToZero 0101 end