When I run this CVX gives an error: “Error using .* Matrix dimensions must agree.” . This error is for the operation "tMode3Prod = squeeze(sum((theta.*lamdaR),3)); " , please note that lamda is of dim (mX1) and hence lamdaR is of (1X1Xm) . If i do the same operation in matlab with a tensor of size (n,n,m), it doesn’t give any error. The error is bcoz theta is of datatype “cvx” and “lamdaR” is double. What should I do ?
try let lamdaR= permute(repmat(lamda,1,n,n),[2 3 1]) to do what you want. I would say cvx is very unlikely to cause a dimension issue like that, even it does, from your description, it is clear your dimension doesn’t agree, one is 1x1xm,another is nxnxm.
But want to perform multiplication across only last dimension. Thats why I am doing a re-shape operation: lamdaR = reshape(lamda,1,1,[]), and then using this.
I have verified, this works well and correctly but in cvx its giving error
do as i told you, it will work. just think about it, even you just want to do to the last dimension, the result will definetly be a nXnXm array. how can you get an array like that without expandsion? or, please use mathematical formula or a loop to illustrate what you actually mean.
you can actually test in matlab whether what i told you is correct.
please test it in matlab. it is easy to do. just use a loop to do what you want, then use that formular i give you, see whether they produce the same thing.
Just for the record, because bsxfun is mentioned as an alternative to implicit expansion in the link a couple of posts back, bsxfun is not supported by CVX.
The example, which predates MATLAB introduction of implicit expansion, or the MATLAB term “implicit expansion”, is kind of a pre(non)implicit expansion way of doing implicit expansion.