
12

C=[1 2 3;4 5 6; 2 4 6]
D=[4 5 8]'
lsqlin(C,D,[],[])
error: __qp__: operator *: nonconformant arguments (op1 is 2x2, op2 is 3x1)
error: called from
quadprog at line 351 column 32
lsqlin at line 123 column 19
it is because two rows in C and D are linearly dependent, row 1 and 3 in
this case.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html


C=[1 2 3; 2 4 6;4 5 6]
D=[4 8 5]'
lsqlin(C,D,[],[])
error: __qp__: operator *: nonconformant arguments (op1 is 2x2, op2 is 3x1)
error: called from
quadprog at line 351 column 32
lsqlin at line 123 column 19
changed rows and gives error again. Anyway, I would appreciate if you fixed
it.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html


C=[1 2 3; 2 4 6;4 5 6]
D=[4 8 5]'
lsqlin(C,D,[],[])
error: __qp__: operator *: nonconformant arguments (op1 is 2x2, op2 is 3x1)
error: called from
quadprog at line 351 column 32
lsqlin at line 123 column 19
changed rows and gives error again. Anyway, I would appreciate if you fixed
it.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html
You should be watching the EXITFLAG
 DAS


On Fri, Jul 05, 2019 at 03:33:24AM 0500, GoSim wrote:
> C=[1 2 3; 2 4 6;4 5 6]
> D=[4 8 5]'
> lsqlin(C,D,[],[])
> error: __qp__: operator *: nonconformant arguments (op1 is 2x2, op2 is 3x1)
> error: called from
> quadprog at line 351 column 32
> lsqlin at line 123 column 19
>
>
>
> changed rows and gives error again. Anyway, I would appreciate if you fixed
> it.
How does Matlabs lsqlin behave if given the 'C' from your examples?
Olaf

public key id EAFE0591, e.g. on xhkp://pool.skskeyservers.net


more outputs gives the same error:
[X, RESNORM, RESIDUAL, EXITFLAG, OUTPUT, LAMBDA]=lsqlin(C,D,[],[])
error: __qp__: operator *: nonconformant arguments (op1 is 2x2, op2 is 3x1)
error: called from
quadprog at line 351 column 32
lsqlin at line 123 column 19

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html


El divendres, 5 de juliol de 2019, a les 7:58:14 EDT, GoSim va escriure:
I don't have Matlab.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.htmlFor the case it is useful, in Matlab 2019a:
>> C = [1 2 3;4 5 6; 2 4 6]
C =
1 2 3
4 5 6
2 4 6
>> D=[4 5 8]'
D =
4
5
8
>> lsqlin(C,D,[],[])
ans =
NaN
NaN
NaN


C=[1 2 3;4 5 6]
D=[4 5]'
lsqlin(C,D,[],[])
ans =
2.4495
4.8990
2.4495
removing the linearly dependent rows makes it work. So the algorithm should
remove rows which are linearly dependent is a solution idea.
But if the matrix is only two rows which are lin. dependent it works... so
this is a really nice bug. This error message has appeared to me for a long
time and I finally could recreate it.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html


El divendres, 5 de juliol de 2019, a les 7:58:14 EDT, GoSim va escriure:
I don't have Matlab.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html
For the case it is useful, in Matlab 2019a:
>> C = [1 2 3;4 5 6; 2 4 6]
C =
1 2 3
4 5 6
2 4 6
>> D=[4 5 8]'
D =
4
5
8
>> lsqlin(C,D,[],[])
ans =
NaN
NaN
NaN
Ok so it appears the compatibility bug is that MATLAB produces a nonerror output of NaNs, and Octave throws an error when the inputs are not linearly independent. Might be worth playing around with the MATLAB outputs a bit more to see if there are any other corner cases octave doesn't capture.
Whether or not to add a noncompatible flag to have octave clip out the linearly dependent input as per GoSim's suggestion may warrant further discussion.


nrjank wrote
> Whether or not to add a noncompatible flag to have octave clip out the
> linearly dependent input as per GoSim's suggestion may warrant further
> discussion.
First make lsqlin give NaN in these cases instead of error. Then if lsqlin
gives NaN try to remove lin. dependent rows and try again.
Like this there is no need to always look for lin. dependent rows.
Matlab should do this too.
But it could be something else because when two lin. dependent rows were the
only two inputs it worked.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html


C=[1 2 3;4 5 6]
D=[4 5]'
A=[1 1 1;2 2 2]
B=[1 2]'
lsqlin(C,D,[],[],A,B,[],[])
error: quadprog: equality constraint matrix must be full row rank
error: called from
quadprog at line 282 column 11
lsqlin at line 123 column 19
This is a similar thing. Not as severe. I would remove lin. dependent rows.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html


C=[1 2 3;4 5 6]
D=[4 5]'
A=[1 1 1;2 2 2]
B=[1 2]'
lsqlin(C,D,[],[],A,B,[],[])
error: quadprog: equality constraint matrix must be full row rank
error: called from
quadprog at line 282 column 11
lsqlin at line 123 column 19
This is a similar thing. Not as severe. I would remove lin. dependent rows.
I have a suggestion for you. make your own file that removes lin dependent rows and then calls lsqlin.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html
 DAS


I have already done it in the case of equality constraint matrices. Because
Octave gave an error message that said something.
In the other case I didn't know why this error appeared. Just tried to give
some info to whoever does the optim package.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html


I have already done it in the case of equality constraint matrices. Because
Octave gave an error message that said something.
In the other case I didn't know why this error appeared. Just tried to give
some info to whoever does the optim package.
since I don't know anything specific about the desired operation of the lsqlin function, I'll just mention that there are a lot of things we think Matlab should do. That said, mcode compatibility is one of the primary objectives of Octave, so the primary task should probably be to remove the error and ensure the NAN output, as you said. Octave does have code and other options that extend functionality beyond what Matlab does. it's possible this could be one of those cases, but only if mathematically justified within the function.


bug 56582 submitted to capture at least the noncompatible error


I tried to create a username in savannah 20 times but evidently I need a
password from Mars so I will just write my ideas here.
To the maintainer of optim:
Best solution: remove lin. dependent rows and keep lsqlin working even if
e.g. two of the same linear combinations are filled in.
Second best solution: Do like Matlab but also write an error/warning so the
user understands why he gets NaN. Lsqlin is very powerful and it is hard to
understand that such a small thing can make it fail.
Worst solution: just like Matlab
Experimental solution: identify lin. dependent rows and to all but one of
them add a very small white noise. The idea is that if you have many linear
combinations that are the same this means something, it should be weighted.
So by keeping them and adding a very small noise maybe the algorithm can
handle it and it will be weighted.
Thanks for optim, I use it often.

Sent from: http://octave.1599824.n4.nabble.com/OctaveGeneralf1599825.html


I tried to create a username in savannah 20 times but evidently I need a
password from Mars so I will just write my ideas here.
I have a fairly simple (as far as they go) password for savannah, so not sure what the issue is. you can always comment anonymously on that bug report if login remains an issue. I think you'll still get directly copied on replies since I added your email.
To the maintainer of optim:
(CC'd here)
Best solution: remove lin. dependent rows and keep lsqlin working even if
e.g. two of the same linear combinations are filled in.
Second best solution: Do like Matlab but also write an error/warning so the
user understands why he gets NaN. Lsqlin is very powerful and it is hard to
understand that such a small thing can make it fail.
Worst solution: just like Matlab
Experimental solution: identify lin. dependent rows and to all but one of
them add a very small white noise. The idea is that if you have many linear
combinations that are the same this means something, it should be weighted.
So by keeping them and adding a very small noise maybe the algorithm can
handle it and it will be weighted.
Thanks for optim, I use it often.
Matlab noncompatibility is generally considered a bug for Octave. so i would think your best solution would only be an possibility after quite a bit of discussion regarding deliberately breaking mcode compatibility. Emulating Matlab output would be a baseline. Adding a warning could still be ok I think. an error would break execution, so probably not. An optional flag or setting to enable one of the fixes you suggest could be ok, as it would extend Octave beyond matlab while maintaining compatibility. BUT the change would need to be mathematically justified. Do we know what algorithm matlab uses? they give a reference [1], why does it produce a NaN? Perturbing the inputs without user notification would require significant mathematical justification.

12
