Skip to content

Commit

Permalink
Simplify check inside setup function
Browse files Browse the repository at this point in the history
  • Loading branch information
imciner2 committed Dec 4, 2023
1 parent 5cf4a61 commit b2b3be0
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions @osqp/setup.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@
%

% Get number of variables n
if (isempty(P))
if (~isempty(q))
n = length(q);
else
if (~isempty(A))
n = size(A, 2);
else
error('The problem does not have any variables');
end
end
else
if (~isempty(P))
n = size(P, 1);
elseif (~isempty(q))
n = length(q);
elseif (~isempty(A))
n = size(A, 2);
else
error('The problem does not have any variables');
end

% Get number of constraints m
Expand All @@ -53,7 +49,7 @@
if (isempty(q))
q = zeros(n, 1);
else
q = full(q(:));
q = full(q(:));
end

% Create proper constraints if they are not passed
Expand Down Expand Up @@ -84,7 +80,6 @@
%
% Check vector dimensions (not checked from the C solver)
%

assert(length(q) == n, 'Incorrect dimension of q');
assert(length(l) == m, 'Incorrect dimension of l');
assert(length(u) == m, 'Incorrect dimension of u');
Expand Down

0 comments on commit b2b3be0

Please sign in to comment.