function isValidVector = isValidDec(hcMatrix, dec, zerotol)
% determine valid and invalid entries in a matrix of hC-vectors
%
% Syntax: isValidVecor = isValidDec(hcMatrix, dec, zerotol)
%
% See also: obtainDec, mapToConfinementCone, isConfinedDec

% The elk-library: convex geometry applied to crystallization modeling.
%   Copyright (C) 2013 Alexander Reinhold
%
% This program is free software: you can redistribute it and/or modify it 
%   under the terms of the GNU General Public License as published by the 
%   Free Software Foundation, either version 3 of the License, or (at your 
%   option) any later version.
%
% This program is distributed in the hope that it will be useful, but 
%   WITHOUT ANY WARRANTY; without even the implied warranty of 
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
%   General Public License for more details.
%
% You should have received a copy of the GNU General Public License along 
%   with this program.  If not, see <http://www.gnu.org/licenses/>.

%% input handling
% ensure zerotol exists
if ~exist('zerotol', 'var')
    zerotol = elkZerotol;
end

% ensure hcMatrix has proper size
if size(hcMatrix, 1) == dec.nC
    % everything OK
elseif size(hcMatrix, 2) == dec.nC
    hcMatrix = hcMatrix';
else
    error('elk:decomposition:wrongInput', ['hcMatrix must contain '...
        'a hC-vectors in each column']);
end

%% Operation
if dec.isComplete
    isValidVector = all(dec.validityCone.A * hcMatrix < zerotol, 1);
else
    isValidVector = all(dec.validityConePart.A * hcMatrix < zerotol, 1);
end