You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: nnz.m
    path of file: ./repos/YALMIP/@sdpvar
    
    the code of the file until where you have to start completion: function varargout = nnz(varargin)
%NNZ (overloaded)
%
%    n = nnz(X)
%
% The NNZ operator is implemented using the concept of nonlinear operators
% in YALMIP. NNZ(X) creates a new so called derived variable that can be
% treated as any other variable in YALMIP. When OPTIMIZE is issued,

    
function varargout = nnz(varargin)
%NNZ (overloaded)
%
%    n = nnz(X)
%
% The NNZ operator is implemented using the concept of nonlinear operators
% in YALMIP. NNZ(X) creates a new so called derived variable that can be
% treated as any other variable in YALMIP. When OPTIMIZE is issued,
% logic constraints are added to the problem to model the NNZ operator.

switch class(varargin{1})

    case 'sdpvar'
        % Simple binary vector?
        if all(ismember(getvariables(varargin{1}),yalmip('binvariables')))
            if is(varargin{1},'lpcone')
                varargout{1} = sum(reshape(varargin{1},prod(size(varargin{1})),1));
                return
            end