Skip to content

Commit

Permalink
Merge pull request #64 from mlubin/constfix
Browse files Browse the repository at this point in the history
Adds additional const qualifiers for the public API
  • Loading branch information
bstellato committed May 4, 2018
2 parents e1563e6 + 922b332 commit b6aef90
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 40 deletions.
12 changes: 6 additions & 6 deletions include/lin_alg.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ c_float* vec_copy(c_float *a,
# endif // ifndef EMBEDDED

/* copy vector a into preallocated vector b */
void prea_vec_copy(c_float *a,
c_float *b,
c_int n);
void prea_vec_copy(const c_float *a,
c_float *b,
c_int n);

/* copy integer vector a into preallocated vector b */
void prea_int_vec_copy(c_int *a,
c_int *b,
c_int n);
void prea_int_vec_copy(const c_int *a,
c_int *b,
c_int n);

/* set float vector to scalar */
void vec_set_scalar(c_float *a,
Expand Down
34 changes: 17 additions & 17 deletions include/osqp.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ c_int osqp_cleanup(OSQPWorkspace *work);
* @return Exitflag for errors and warnings
*/
c_int osqp_update_lin_cost(OSQPWorkspace *work,
c_float *q_new);
const c_float *q_new);


/**
Expand All @@ -123,8 +123,8 @@ c_int osqp_update_lin_cost(OSQPWorkspace *work,
* @return Exitflag: 1 if new lower bound is not <= than new upper bound
*/
c_int osqp_update_bounds(OSQPWorkspace *work,
c_float *l_new,
c_float *u_new);
const c_float *l_new,
const c_float *u_new);


/**
Expand All @@ -134,7 +134,7 @@ c_int osqp_update_bounds(OSQPWorkspace *work,
* @return Exitflag: 1 if new lower bound is not <= than upper bound
*/
c_int osqp_update_lower_bound(OSQPWorkspace *work,
c_float *l_new);
const c_float *l_new);


/**
Expand All @@ -144,7 +144,7 @@ c_int osqp_update_lower_bound(OSQPWorkspace *work,
* @return Exitflag: 1 if new upper bound is not >= than lower bound
*/
c_int osqp_update_upper_bound(OSQPWorkspace *work,
c_float *u_new);
const c_float *u_new);


/**
Expand All @@ -155,8 +155,8 @@ c_int osqp_update_upper_bound(OSQPWorkspace *work,
* @return Exitflag
*/
c_int osqp_warm_start(OSQPWorkspace *work,
c_float *x,
c_float *y);
const c_float *x,
const c_float *y);


/**
Expand All @@ -166,7 +166,7 @@ c_int osqp_warm_start(OSQPWorkspace *work,
* @return Exitflag
*/
c_int osqp_warm_start_x(OSQPWorkspace *work,
c_float *x);
const c_float *x);


/**
Expand All @@ -176,7 +176,7 @@ c_int osqp_warm_start_x(OSQPWorkspace *work,
* @return Exitflag
*/
c_int osqp_warm_start_y(OSQPWorkspace *work,
c_float *y);
const c_float *y);


# if EMBEDDED != 1
Expand All @@ -198,8 +198,8 @@ c_int osqp_warm_start_y(OSQPWorkspace *work,
* <0: error in the update
*/
c_int osqp_update_P(OSQPWorkspace *work,
c_float *Px_new,
c_int *Px_new_idx,
const c_float *Px_new,
const c_int *Px_new_idx,
c_int P_new_n);


Expand All @@ -219,8 +219,8 @@ c_int osqp_update_P(OSQPWorkspace *work,
* <0: error in the update
*/
c_int osqp_update_A(OSQPWorkspace *work,
c_float *Ax_new,
c_int *Ax_new_idx,
const c_float *Ax_new,
const c_int *Ax_new_idx,
c_int A_new_n);


Expand Down Expand Up @@ -248,11 +248,11 @@ c_int osqp_update_A(OSQPWorkspace *work,
* <0: error in the update
*/
c_int osqp_update_P_A(OSQPWorkspace *work,
c_float *Px_new,
c_int *Px_new_idx,
const c_float *Px_new,
const c_int *Px_new_idx,
c_int P_new_n,
c_float *Ax_new,
c_int *Ax_new_idx,
const c_float *Ax_new,
const c_int *Ax_new_idx,
c_int A_new_n);

/**
Expand Down
4 changes: 2 additions & 2 deletions src/lin_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ c_float* vec_copy(c_float *a, c_int n) {
#endif // end EMBEDDED


void prea_int_vec_copy(c_int *a, c_int *b, c_int n) {
void prea_int_vec_copy(const c_int *a, c_int *b, c_int n) {
c_int i;

for (i = 0; i < n; i++) {
b[i] = a[i];
}
}

void prea_vec_copy(c_float *a, c_float *b, c_int n) {
void prea_vec_copy(const c_float *a, c_float *b, c_int n) {
c_int i;

for (i = 0; i < n; i++) {
Expand Down
32 changes: 17 additions & 15 deletions src/osqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ c_int osqp_cleanup(OSQPWorkspace *work) {
/************************
* Update problem data *
************************/
c_int osqp_update_lin_cost(OSQPWorkspace *work, c_float *q_new) {
c_int osqp_update_lin_cost(OSQPWorkspace *work, const c_float *q_new) {
// Replace q by the new vector
prea_vec_copy(q_new, work->data->q, work->data->n);

Expand All @@ -759,7 +759,9 @@ c_int osqp_update_lin_cost(OSQPWorkspace *work, c_float *q_new) {
return 0;
}

c_int osqp_update_bounds(OSQPWorkspace *work, c_float *l_new, c_float *u_new) {
c_int osqp_update_bounds(OSQPWorkspace *work,
const c_float *l_new,
const c_float *u_new) {
c_int i, exitflag = 0;

// Check if lower bound is smaller than upper bound
Expand Down Expand Up @@ -794,7 +796,7 @@ c_int osqp_update_bounds(OSQPWorkspace *work, c_float *l_new, c_float *u_new) {
return exitflag;
}

c_int osqp_update_lower_bound(OSQPWorkspace *work, c_float *l_new) {
c_int osqp_update_lower_bound(OSQPWorkspace *work, const c_float *l_new) {
c_int i, exitflag = 0;

// Replace l by the new vector
Expand Down Expand Up @@ -827,7 +829,7 @@ c_int osqp_update_lower_bound(OSQPWorkspace *work, c_float *l_new) {
return exitflag;
}

c_int osqp_update_upper_bound(OSQPWorkspace *work, c_float *u_new) {
c_int osqp_update_upper_bound(OSQPWorkspace *work, const c_float *u_new) {
c_int i, exitflag = 0;

// Replace u by the new vector
Expand Down Expand Up @@ -860,7 +862,7 @@ c_int osqp_update_upper_bound(OSQPWorkspace *work, c_float *u_new) {
return exitflag;
}

c_int osqp_warm_start(OSQPWorkspace *work, c_float *x, c_float *y) {
c_int osqp_warm_start(OSQPWorkspace *work, const c_float *x, const c_float *y) {
// Update warm_start setting to true
if (!work->settings->warm_start) work->settings->warm_start = 1;

Expand All @@ -881,7 +883,7 @@ c_int osqp_warm_start(OSQPWorkspace *work, c_float *x, c_float *y) {
return 0;
}

c_int osqp_warm_start_x(OSQPWorkspace *work, c_float *x) {
c_int osqp_warm_start_x(OSQPWorkspace *work, const c_float *x) {
// Update warm_start setting to true
if (!work->settings->warm_start) work->settings->warm_start = 1;

Expand All @@ -902,7 +904,7 @@ c_int osqp_warm_start_x(OSQPWorkspace *work, c_float *x) {
return 0;
}

c_int osqp_warm_start_y(OSQPWorkspace *work, c_float *y) {
c_int osqp_warm_start_y(OSQPWorkspace *work, const c_float *y) {
// Update warm_start setting to true
if (!work->settings->warm_start) work->settings->warm_start = 1;

Expand Down Expand Up @@ -941,8 +943,8 @@ c_int osqp_warm_start_y(OSQPWorkspace *work, c_float *y) {
* <0: error in update_matrices()
*/
c_int osqp_update_P(OSQPWorkspace *work,
c_float *Px_new,
c_int *Px_new_idx,
const c_float *Px_new,
const c_int *Px_new_idx,
c_int P_new_n) {
c_int i; // For indexing
c_int exitflag; // Exit flag
Expand Down Expand Up @@ -1021,8 +1023,8 @@ c_int osqp_update_P(OSQPWorkspace *work,
* <0: error in update_matrices()
*/
c_int osqp_update_A(OSQPWorkspace *work,
c_float *Ax_new,
c_int *Ax_new_idx,
const c_float *Ax_new,
const c_int *Ax_new_idx,
c_int A_new_n) {
c_int i; // For indexing
c_int exitflag; // Exit flag
Expand Down Expand Up @@ -1108,11 +1110,11 @@ c_int osqp_update_A(OSQPWorkspace *work,
* <0: error in update_matrices()
*/
c_int osqp_update_P_A(OSQPWorkspace *work,
c_float *Px_new,
c_int *Px_new_idx,
const c_float *Px_new,
const c_int *Px_new_idx,
c_int P_new_n,
c_float *Ax_new,
c_int *Ax_new_idx,
const c_float *Ax_new,
const c_int *Ax_new_idx,
c_int A_new_n) {
c_int i; // For indexing
c_int exitflag; // Exit flag
Expand Down

0 comments on commit b6aef90

Please sign in to comment.