clarifyVectorInformation

PURPOSE ^

obtain simplex partition and obtain proper vector type

SYNOPSIS ^

function [vecType, vec, partitionIndex] =clarifyVectorInformation(vecType, vec, simplex, dec, zerotol,enforceValid)

DESCRIPTION ^

 obtain simplex partition and obtain proper vector type

 No matter what "simplex" says, this function returns ALWAYS a simplex
   partition index. However, if vec is {p, vec} then p is interpreted
   as simplex partition (simplex=1) or unified partition (simplex=0),
   directly.

 THIS FUNCTION IS NO USER FUNCTION.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [vecType, vec, partitionIndex] = ...
0002     clarifyVectorInformation(vecType, vec, simplex, dec, zerotol, ...
0003     enforceValid)
0004 % obtain simplex partition and obtain proper vector type
0005 %
0006 % No matter what "simplex" says, this function returns ALWAYS a simplex
0007 %   partition index. However, if vec is {p, vec} then p is interpreted
0008 %   as simplex partition (simplex=1) or unified partition (simplex=0),
0009 %   directly.
0010 %
0011 % THIS FUNCTION IS NO USER FUNCTION.
0012 
0013 % The elk-library: convex geometry applied to crystallization modeling.
0014 %   Copyright (C) 2012 Alexander Reinhold
0015 %
0016 % This program is free software: you can redistribute it and/or modify it
0017 %   under the terms of the GNU General Public License as published by the
0018 %   Free Software Foundation, either version 3 of the License, or (at your
0019 %   option) any later version.
0020 %
0021 % This program is distributed in the hope that it will be useful, but
0022 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0023 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0024 %   General Public License for more details.
0025 %
0026 % You should have received a copy of the GNU General Public License along
0027 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0028 
0029 %% Skip incomplete dec
0030 % no validity mapping, only one partition
0031 if ~dec.isComplete
0032     if iscell(vec)
0033         if simplex
0034             partitionIndex = vec{1};
0035         else
0036             partitionIndex = dec.unifiedToSimplexVector(vec{1});
0037         end
0038         vec = vec{2};
0039     else
0040         % the default partition is nPS not 1
0041         partitionIndex = dec.unifiedToSimplexVector*ones(1, size(vec, 2));
0042     end
0043     return
0044 end
0045 
0046 %% Determine simplex partition
0047 % if partition is provided
0048 if iscell(vec)
0049     if simplex
0050         % simplex partition is given number
0051         partitionIndex = vec{1};
0052     else
0053         % unified is given, determine a matching simplex partition
0054         partitionIndex = dec.unifiedToSimplexVector(vec{1});
0055     end
0056     % the following is my vector
0057     vec = vec{2};
0058     
0059 elseif strcmpi(vecType, 'hc')
0060     %% Check validity
0061     %! ToDo: added these lines of code, but not documented it:
0062     validVector = isValidDec(vec, dec, zerotol);
0063     partitionIndex = nan(size(validVector));
0064     if all(validVector)
0065         % nothing to do
0066     elseif enforceValid == 1
0067         % map vectors to valid vectors
0068         vec = mapToValidityCone(vec, dec, zerotol);
0069         validVector = true(size(validVector));
0070     elseif enforceValid == -1
0071         % set partitions to 0 for invalid partitions and use the proper
0072         %   partition otherwise.
0073         partitionIndex = double(validVector);
0074     else
0075         error('elk:decomposition:invalidPoints', ['Not all input vectors ' ...
0076             'are valid. You might want to use the enforceValid option.']);
0077     end
0078     %/
0079     if simplex
0080         partitionIndex(validVector) = computePartitionIndexDec(dec, ...
0081             vec(:, validVector), zerotol, 0);
0082     else
0083         partitionIndex(validVector) = computePartitionIndexDec(dec, ...
0084             vec(:, validVector), zerotol, 1);
0085         partitionIndex(validVector) = dec.unifiedToSimplexVector(...
0086             partitionIndex(validVector));
0087     end
0088     
0089     
0090 else
0091     error('elk:decomposition:wrongInput', ...
0092         ['For a given vector of scalar multiples of structuring elements ' ...
0093          'the partition must be provided']);
0094 end
0095 
0096 % Result: independent of the simplex option, the vector paritionIndex
0097 %   represents the simplex partitions for the vectors in vec.
0098 
0099 %% Ensure format of vec
0100 % ensure hc being a column vector or matrix of hc-vectors
0101 if size(vec, 1) ~= dec.nC
0102     if size(vec, 2) == dec.nC
0103         vec = vec';
0104     else
0105         error('elk:decomposition:wrongInput', ...
0106             ['the provided vector must be a row vector (or matrix of ' ...
0107              'vectors) with the dimension of: size(dec.se, 2)']);
0108     end
0109 end

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