Skip to content

Commit

Permalink
Much faster cumsum operator
Browse files Browse the repository at this point in the history
  • Loading branch information
johanlofberg committed Jul 25, 2019
1 parent bd0bf8e commit 72e9132
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions @sdpvar/cumsum.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
%CUMSUM (overloaded)

if nargin == 1 & min(X.dim)==1
B = cumsum(X.basis);
X.basis = cumsum(X.basis);
else
if nargin == 1
I = min(find(X.dim>1));
if isempty(I)
I = 1;
end
end

B = [];
for i = 1:length(X.lmi_variables)+1
C = reshape(X.basis(:,i),X.dim);
C = cumsum(C,I);
B = [B C(:)];
end
if I == 2
X = (tril(ones(size(X,2)))*X')';
else
X = tril(ones(size(X,1)))*X;
end
end
X.basis = B;
X.conicinfo = [0 0];
X.extra.opname = '';
X = flush(X);
Expand Down

0 comments on commit 72e9132

Please sign in to comment.