diff --git a/src/cones.c b/src/cones.c index 7140fff0..7da10411 100644 --- a/src/cones.c +++ b/src/cones.c @@ -39,13 +39,6 @@ void BLAS(scal)(const blas_int *n, const scs_float *sa, scs_float *sx, } #endif -#endif - -/* Forward declare exponential cone projection routine. - * Implemented in exp_cone.c. - */ -scs_float SCS(proj_pd_exp_cone)(scs_float *v0, scs_int primal); - // Forward declare spectral matrix cone projections scs_int SCS(proj_logdet_cone)(scs_float *tvX, const scs_int n, ScsConeWork *c, scs_int offset, bool *warmstart); @@ -54,6 +47,13 @@ void SCS(proj_ell_one)(scs_float *tx, size_t n, ScsConeWork *c); scs_int SCS(proj_sum_largest_evals)(scs_float *tX, scs_int n, scs_int k, ScsConeWork *c); +#endif + +/* Forward declare exponential cone projection routine. + * Implemented in exp_cone.c. + */ +scs_float SCS(proj_pd_exp_cone)(scs_float *v0, scs_int primal); + void SCS(free_cone)(ScsCone *k) { if (k) { if (k->bu) diff --git a/src/spectral_cones/logdeterminant/log_cone_IPM.c b/src/spectral_cones/logdeterminant/log_cone_IPM.c index 4dd0053d..f5111a43 100644 --- a/src/spectral_cones/logdeterminant/log_cone_IPM.c +++ b/src/spectral_cones/logdeterminant/log_cone_IPM.c @@ -33,11 +33,19 @@ scs_float d_one = 1.0; scs_float d_minus_one = -1.0; blas_int bi_three = 3; +#ifdef __cplusplus +extern "C" { +#endif + void BLAS(gemv)(const char *trans, const blas_int *m, const blas_int *n, const scs_float *alpha, const scs_float *a, const blas_int *lda, const scs_float *x, const blas_int *incx, const scs_float *beta, scs_float *y, const blas_int *incy); +#ifdef __cplusplus +} +#endif + /* Evaluates the oracle f(u) = (f0(u), f1(u), f2(u)) where u = [t, v, x, r] * and * f0 = 0.5 * (t - t0)^2 + 0.5 * (v - v0)^2 + 0.5 * ||x - x0||^2 - r diff --git a/src/spectral_cones/logdeterminant/logdet_cone.c b/src/spectral_cones/logdeterminant/logdet_cone.c index 7ac5f8d4..bb213acc 100644 --- a/src/spectral_cones/logdeterminant/logdet_cone.c +++ b/src/spectral_cones/logdeterminant/logdet_cone.c @@ -18,6 +18,10 @@ * Last modified: 25 August 2024. */ +#ifdef __cplusplus +extern "C" { +#endif + void BLAS(syev)(const char *jobz, const char *uplo, blas_int *n, scs_float *a, blas_int *lda, scs_float *w, scs_float *work, blas_int *lwork, blas_int *info); @@ -28,6 +32,11 @@ blas_int BLAS(syrk)(const char *uplo, const char *trans, const blas_int *n, void BLAS(scal)(const blas_int *n, const scs_float *sa, scs_float *sx, const blas_int *incx); +#ifdef __cplusplus +} +#endif + + // forward declare from log_cone_wrapper.c scs_int log_cone_proj_wrapper(scs_float t0, scs_float v0, const scs_float *x0, scs_float *proj, scs_int n, scs_float *workspace, diff --git a/src/spectral_cones/nuclear/nuclear_cone.c b/src/spectral_cones/nuclear/nuclear_cone.c index 238f6647..86d7f326 100644 --- a/src/spectral_cones/nuclear/nuclear_cone.c +++ b/src/spectral_cones/nuclear/nuclear_cone.c @@ -16,6 +16,11 @@ * * Last modified: 25 August 2024. */ + +#ifdef __cplusplus +extern "C" { +#endif + void BLAS(gemm)(const char *transa, const char *transb, blas_int *m, blas_int *n, blas_int *k, scs_float *alpha, scs_float *a, blas_int *lda, scs_float *b, blas_int *ldb, scs_float *beta, @@ -30,6 +35,10 @@ void BLAS(gesvd)(const char *jobu, const char *jobvt, const blas_int *m, const blas_int *ldvt, scs_float *work, const blas_int *lwork, blas_int *info); +#ifdef __cplusplus +} +#endif + // forward declaration from ell1_cone.c scs_int ell1_cone_proj_sorted(scs_float t0, const scs_float *x0, scs_float *proj, scs_int n); diff --git a/src/spectral_cones/util_spectral_cones.c b/src/spectral_cones/util_spectral_cones.c index 1a91ee4d..32b82a2d 100644 --- a/src/spectral_cones/util_spectral_cones.c +++ b/src/spectral_cones/util_spectral_cones.c @@ -32,9 +32,9 @@ void non_neg_proj(const scs_float *src, scs_float *dst, scs_int n) } } -void print_vector(const scs_float *x, size_t n) +void print_vector(const scs_float *x, scs_int n) { - for (size_t i = 0; i < n; ++i) + for (scs_int i = 0; i < n; ++i) { printf("%f ", x[i]); } @@ -45,7 +45,7 @@ scs_float min_vec(const scs_float *vec, scs_int n) { scs_float minVal = vec[0]; - for (size_t i = 1; i < n; ++i) + for (scs_int i = 1; i < n; ++i) { if (vec[i] < minVal) {