function result = checkDistribution(dis, type)
% identify input distribution
%
% Syntax: result = identifyDistribution(dis)
%
% A logical array is returned that contains true if the distribution is
%   continuous (first element), discrete (second) or reduced (third).
%
% In the form identifyDistribution(dis, type) only the specific type is
%   returned: disC (continuous), disD (discrete), disR (reduced).
%
% see also: obtainDistributioncontinuous, discretizeDistribution,
%   reduceDistribution

% 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
if ~exist('type', 'var')
    type = '';
end

%% conditions
% required fields for distribution
isDis = all(isfield(dis, {'name', 'nDim'}));

% seperate types
isDisC = all(isfield(dis, {'fhandle', 'parContinuous'}));
isDisD = all(isfield(dis, {'positionMatrix', 'valueVector', ...
    'probabilityVector', 'parDiscrete'}));
isDisR = all(isfield(dis, {'positionMatrix', 'valueVector', ...
    'parReduce'}));

%% assign result
switch lower(type)
    case ''
        result = isDis & [isDis isDisD isDisR];
    case 'disc'
        result = isDis && isDisC;
    case 'disd'
        result = isDis && isDisD;
    case 'disr'
        result = isDis && isDisR;
end