norm function not recognized properly

18 views
Skip to first unread message

Naoya Kumagai

unread,
Oct 27, 2025, 11:20:12 PMOct 27
to YALMIP
Hi Prof. Lofberg,

I'm having an issue where YALMIP's overloaded norm function is not called on sdpvar inputs, resulting in the default MATLAB norm function being called and causing errors. I'm calling norm from the same function, which works in some cases (calling YALMIP's norm correctly) and sometimes not. I've been a long-time user of YALMIP and it's the first time I've seen this thing happen, I'm wondering if anyone has had similar issues before.

I've tried using the debugger, and when I try "yalmiptest" from inside this function which calls norm, it works as expected, so it doesn't seem to be a path issue. I've tried on different operating systems and the issue is the same. Environment is newest YALMIP main branch and MATLAB 2025b.

Naoya Kumagai

unread,
Oct 27, 2025, 11:42:39 PMOct 27
to YALMIP
Let's say this variable name is v. 

I tried calling the max function (arbitrary choice of function), but it works as expected.
'''
max(v)
Nonlinear scalar (real, 1 variable)
Coefficients range: 1 to 1
'''

I tried calling abs function on this, but this also errors. 
'''
abs(v)
Index exceeds array bounds.

Error in
sdpvar/value (line 39)
nonlinears = lmi_variables(find(variabletype(lmi_variables)));
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
sdpvar/value (line 106)
[extstruct.arg{k},values] = value(extstruct.arg{k},allextended,allevaluators,allStruct,mt,variabletype,solution,values);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
sdpvar/value (line 106)
[extstruct.arg{k},values] = value(extstruct.arg{k},allextended,allevaluators,allStruct,mt,variabletype,solution,values);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
sdpvar/display (line 176)
if ~any(any(isnan(value(x))))
'''

Naoya Kumagai

unread,
Oct 27, 2025, 11:52:39 PMOct 27
to YALMIP
Found the source. A vec function had been newly added to YALMIP, which I was calling before handing to the norm function.
The vec function will keep your ndsdpvar as an ndsdpvar (not a sdpvar), so it won't be passed to YALMIP's norm function.

Johan Löfberg

unread,
Oct 28, 2025, 2:48:20 AMOct 28
to YALMIP
Can you provide a reproducible example. I cannot trigger this

>> v = sdpvar(2,2,2);
>> abs(max(v))
Multi-dimensional SDPVAR object 1x2x2
>>

For bug reports, it is better to use the tracker here though
https://github.com/yalmip/YALMIP/issues 
Message has been deleted

Mark L. Stone

unread,
Oct 29, 2025, 11:23:41 AMOct 29
to YALMIP
My guess,  Naoya Kumagaihas added a non-YALMIP version of `vec` to the matlabpath ahead of yalmip's `vec` so can't be reproduced by someone, Johan, who hasn't done that. 

So  Naoya Kumagaihas should post the output of  
`which -all vec` 
for the configuration which generated the error.

Johan Löfberg

unread,
Oct 29, 2025, 11:57:00 AMOct 29
to YALMIP
No, I don't think that is the issue. The vec operators in YALMIP are overloaded and thus will be called, have been in the code for at least 11 years, and there is a vec operator in sedumi which never caused issues.

Naoya Kumagai

unread,
Oct 29, 2025, 8:45:42 PMOct 29
to YALMIP
Mark is right, this is what was happening. 

x = sdpvar(2,2,2)
v = vec(x)
norm(v)

should throw an error, as v is not an sdpvar but an ndsdpvar.

But when I use my own vec function 
function x = vec(x)
x = x(:)
end

then, the above code works as I intended. It's not any bug in yalmip of course, just something that I want to do for my case. Now that I think about it, I had never used ndsdpvars as inputs to my vec function before, so that's why I was confused here.

Johan Löfberg

unread,
Oct 30, 2025, 2:54:14 AMOct 30
to YALMIP
That is a YALMIP bug actually. The overloaded vec operator on ndsdpvar should return an sdpvar but it doesn't.
Reply all
Reply to author
Forward
0 new messages