# "Incorrect dimensions for matrix multiplication" for sum_log function

Hi. I get the error when the function is sum_log. Below is the MATLAB code and error messages.
There would be no error if the function is replaced by other concave function such as -norm(t).

``````clear
close all
clc

K = 2;

F = [2 1; 1 2];

cvx_begin
cvx_solver mosek
variable Z(K, K) complex
variable t(K, 1)
maximize sum_log(t+1)
% maximize -norm(t)
subject to

Z == hermitian_semidefinite(K);
for kk = 1:K
Z(kk, kk) == 1;
end

for kk = 1:K
[Z + F(:, 1:kk ) * F(:, 1:kk)', F(:, kk); F(:, kk)', t(kk)] == hermitian_semidefinite(K + 1);
end

cvx_end
``````

Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in
the second matrix. To perform elementwise multiplication, use ‘.*’.

Error in cvxprob/eliminate (line 137)
P = P * cvx_invert_structure( xR );

Error in cvxprob/solve (line 18)
[ At, cones, sgn, Q, P, dualized ] = eliminate( prob, true, shim.dualize );

Error in cvx_end (line 88)
solve( prob );

Error in run (line 28)
cvx_end

CVX us very good at issuing error messages when something is wrong. But the error messages are sometimes misleading as to what the actual error is.

In this case, the error is due to violating the DCP rules on convexity of the objective function (minimize convex or maximize concave). Admittedly, the error message is “wrong”, but CVX is correct to issue an error message.

Thanks. But the objective function to be maximized in this example is concave. I don’t know where is the DCP rules violated.

Try `geo_mean(t+1)`, the optimal point is the same, to work around the (likely?) bug. It goes through but I haven’t checked if it the result makes sense.