function dim = dimVVbar(varargin)
% [ V ] = dimVVbar( Om, [k], [options] );
% Computes the dimension of the spaces V_k and \bar{V}_k, as described in Charina, Mejstrik, 2018.
%
% Input: 
%   Om          The set for which Vbar_k shall be constructed as an array of column vectors
%   k           index k, optional. Either an integer or a vector of integers (greater equal zero)
%               If k is empty, then all spaces where dim V_k>0 are computed.
%
% Options:
%   '01'        give input as a 0/1 matrix
%   'verbose'   more text output
%   'V'         only compute dimensions of spaces V_k
%   'Vbar'      only compute dimensions of spaces \bar{V}_k
%
% Output:
%   dim         first line: dimensions of V_k, for k=0,1,2,3,...
%               second line: dimensions of \bar{V}_k, for k=0,1,2,3,...
%
% Note:
%  If both options 'V' and 'Vbar' are given, the behaviour is undefined.
%
% E.g.: dimVVbar([1 1 0 0;1 0 1 1;0 1 0 0],'01','verbose',1)
%
% See also: constructV, constructVbar
%
% Written by: tommsch, 2017

[verbose,varargin]=parsem('verbose',varargin);
[Vflag,varargin]=parsem('V',varargin);
[Vbarflag,varargin]=parsem('Vbar',varargin);


if(~Vbarflag); dimV=cellfun(@rank,constructV(varargin{:})); end;
if(~Vflag); dimVbar=cellfun(@rank,constructVbar(varargin{:})); end;


if(verbose); vdisp(varargin{1}); end;
if(~Vbarflag & ~Vflag);
    if(size(dimV,2)>size(dimVbar,2)); dimVbar(size(dimV,2))=0; end;
    dim=[dimV;dimVbar];
elseif(Vbarflag)
    dim=dimVbar;
elseif(Vflag);
    dim=dimV;
end;

end
