Using cumsum in cvx

Hi,
I’ve encountered 2 problems when using cumsum in my objective function. My variable is 2xN matrix called p (actually N 2-dimensional vectors).

First, for the case N=2, the specification of the dimension seem to be reversed as compared to Matlab, i.e Matlab’s cumsum(p,2) should be specified in cvx as cumsum(p,1). This is demonstrated by the following code, once using g1 as the objective and once using g2, where g1 uses cumsum(p,1) and g2 computes cumsum(p,2) explicitly:

x=[1 3;2 4];
[d N] = size(x);
c=2;
g1=@(p)sum(sum((x-cumsum(p,1)).^2)) + c*sum(norms(p(:,2:end)));
g2=@(p)sum((x(:,1)-p(:,1)).^2 + (x(:,2)-sum(p,2)).^2) + c*norm(p(:,2));
cvx_begin
    variable p(d,N)
    minimize ( g2(p) )
cvx_end

Second, for N>=2, both cumsum(p,1) and cumsum(p,2) gives wrong results. Only If calculate the cumsum explicitly I get the correct result. This is demonstrated by the following code, comparing g3 and g1:

x=[1 3;2 4;5 6];
[d N] = size(x);
c=2;
g1=@(p)sum(sum((x-cumsum(p,1)).^2)) + c*sum(norms(p(:,2:end)));    
g3=@(p,pcsum)sum(sum((x-pcsum).^2)) + c*sum(norms(p(:,2:end)));
cvx_begin
    variables p(d,N) pcsum(d,N)
    minimize ( g3(p,pcsum) ) % g1(p)
    subject to
    for n = 1:N
        pcsum(:,n) == sum(p(:,1:n),2);
    end
cvx_end

Is this really a bug or am I doing something wrong?
Thanks.

You may wish to file a full bug report for this at http://support.cvxr.com … please note however that this is a holiday period so there will be a bit of a delay in investigation.