matbesancon/MathOptSetDistances.jl

Factor of sqrt(2) in unvec_symm and vec_symm?

tjdiamandis opened this issue · 7 comments

I think the unvec_symm and vec_symm functions should have a sqrt(2) factor on the off-diagonal entires to preserve the inner product, i.e., Tr(CX) = vec(C)' * vec(X) (see SCS README).

X = [ X11 X12 ... X1k
      X21 X22 ... X2k
      ...
      Xk1 Xk2 ... Xkk ]

becomes

vec(X) = (X11, sqrt(2)*X21, ..., sqrt(2)*Xk1, X22, sqrt(2)*X32, ..., Xkk).

yes it's been mentionned by @joaquimg in an earlier issue. A PR would be very much welcome on this part

Also pinging @blegat on that

Actually, I was incorrect about the factor of sqrt(2) if MathOptInterface convention is used (see AbstractSymmetricMatrixSetTriangle).

Didn't realize the mismatch between the MOI and SCS vectorizations. The former has no scaling but does not preserve the inner product when vectorized.

the factor of sqrt(2) if MathOptInterface convention is used

now that you mention it, I think it was settled somewhere with the MOI convention being favoured

Ah, I found it here. I think a note in the docstring that mentions this would be valuable. I can add this.

That would be great yes thank you!

fixed in the PR with a precision thanks!