-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve public API for user-facing types #577
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 5764374642Details
💛 - Coveralls |
This looks great! I would recommend changing the main interfaces to use this slightly modified API so that everything is consistent. Let's at least create issues on the corresponding repos. |
Agree that this is a bit nicer, but with this:
It needs to be really clear what happens when I call It would also be nice to provide something like We could maybe add some internal data ownership flag to the |
//settings->linsys_solver = OSQP_DIRECT_SOLVER; | ||
//settings->linsys_solver = OSQP_INDIRECT_SOLVER; |
Check notice
Code scanning / CodeQL
Commented-out code Note
//settings->linsys_solver = OSQP_DIRECT_SOLVER; | ||
//settings->linsys_solver = OSQP_INDIRECT_SOLVER; |
Check notice
Code scanning / CodeQL
Commented-out code Note
I've gone ahead and tweaked the API so that we now track owning and not-owning the arrays inside a CSC matrix, and free them accordingly. This comes alongside adding some helper functions to create diagonal matrices, the identity matrix and a matrix of all zeros. |
Pull Request Test Coverage Report for Build 10377784078Details
💛 - Coveralls |
WIth the new changes it looks great to me! @goulart-paul what do you think? I saw you left quite a few comments |
We have three main user-facing types that are used to pass data into the solver:
OSQPSettings
,OSQPCscMatrix
andOSQPCodegenDefines
. Currently, our system requires the user to malloc the object, then do a separate call to get the defaults, then use them. This can be very awkward, and leads to having a lot of boilerplate code likeor
With this PR, new functions to allocate and free these objects are added:
OSQPCscMatrix_new()
OSQPCscMatrix_free()
OSQPSettings_new()
OSQPSettings_free()
OSQPCodegenDefines_new()
OSQPCodegenDefines_free()
Additionally, the
csc_set_data()
function has been renamed toOSQPCscMatrix_set_data()
.These changes mean that the boilerplate code from above becomes:
and
These 6 new functions are only available in non-embedded mode since they allocate data. The
OSQPCscMatrix_set_data()
function is still available in all modes, since it will just assign pointers (so it is still a direct replacement forcsc_set_data()
.