From b2b3be00650f8e0c4def1a8cd216a334d5b75419 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Mon, 4 Dec 2023 17:29:04 +0000 Subject: [PATCH] Simplify check inside setup function --- @osqp/setup.m | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/@osqp/setup.m b/@osqp/setup.m index 800a442..5317e2d 100644 --- a/@osqp/setup.m +++ b/@osqp/setup.m @@ -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 @@ -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 @@ -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');