embotech/ecos

Unclear which parameters of ECOS_setup can be read-only (if any)

Opened this issue · 2 comments

This is about the C interface.

From the README it would seem that all can be read-only (none is used as output, there's no mention of them being modified). However some of these arrays will be written to (equil.c: use_alternating_norm_equilibration that I've seen at least). So I can't pass pointers to read-only memory, and I may need to make copies of the arrays I don't want modified. This should be documented.

Any suggestion how to handle this properly? Of course modifying the matrices without documenting it is to be avoided… but I am contemplating to leave the data completely unmodified and to create a copy during equilibration instead. This way we save the unset_equilibration() call at the end (which undos equilibration) and don't temper with the user's data. @echu What do you think would be the best solution?

On 14 Oct 2014, at 17:40, Alexander Domahidi notifications@github.com wrote:

Any suggestion how to handle this properly? Of course modifying the matrices without documenting it is to be avoided… but I am contemplating to leave the data completely unmodified and to create a copy during equilibration instead. This way we save the unset_equilibration() call at the end (which undos equilibration) and don't temper with the user's data. @echu What do you think would be the best solution?

If none of the arguments are modified, that's the safest solution. But I imagine we don't want unnecessary copies to be made either, and the arguments will often be temporaries that are built just to call ECOS. The way I hit upon this problem is probably uncommon (a test case using a literal array, which was allocated to read-only memory).

As far as I'm concerned, just const-qualifying the appropriate arguments of ECOS_setup() and a couple of comments in the README.md should be enough.