Skip to content

Commit

Permalink
trying to fix C++ build
Browse files Browse the repository at this point in the history
  • Loading branch information
dance858 committed Nov 17, 2024
1 parent 625a25b commit 6f44842
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/cones.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/spectral_cones/logdeterminant/log_cone_IPM.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/spectral_cones/logdeterminant/logdet_cone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions src/spectral_cones/nuclear/nuclear_cone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/spectral_cones/util_spectral_cones.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand All @@ -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)
{
Expand Down

0 comments on commit 6f44842

Please sign in to comment.