Skip to content

Commit

Permalink
240419.220802.HKT further revise the indentation style of c/tests/*.c
Browse files Browse the repository at this point in the history
  • Loading branch information
zaikunzhang committed Apr 19, 2024
1 parent c478f52 commit baa2a1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
14 changes: 7 additions & 7 deletions c/tests/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ int main(int argc, char * argv[])

// Data for the problem
double x0[] = {0.0,
0.0};
0.0};
double xl[] = {-6.0,
-6.0};
-6.0};
double xu[] = {6.0,
6.0};
6.0};
double Aineq[3*2] = {1.0, 0.0,
0.0, 1.0,
1.0, 1.0};
0.0, 1.0,
1.0, 1.0};
double bineq[3] = {4.0,
3.0,
10.0};
3.0,
10.0};

// Define the algorithm and the problem according to `algo`
prima_problem_t problem;
Expand Down
16 changes: 7 additions & 9 deletions c/tests/stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void fun(const double x[], double *const f, const void *data)
// Objective: Rosenbrock function
*f = 0.0;
for (int i = 0; i < n-1; ++ i)
*f += (x[i] - 1.0) * (x[i] - 1.0) + alpha * (x[i+1] - x[i]*x[i]) * (x[i+1] - x[i]*x[i]);
*f += (x[i] - 1.0) * (x[i] - 1.0) + alpha * (x[i+1] - x[i]*x[i]) * (x[i+1] - x[i]*x[i]);

static int nf = 0;
if (debug) {
Expand All @@ -46,11 +46,11 @@ static void fun_con(const double x[], double *const f, double constr[], const vo
// Objective: Rosenbrock function
*f = 0.0;
for (int i = 0; i < n-1; ++ i)
*f += (x[i] - 1.0) * (x[i] - 1.0) + alpha * (x[i+1] - x[i]*x[i]) * (x[i+1] - x[i]*x[i]);
*f += (x[i] - 1.0) * (x[i] - 1.0) + alpha * (x[i+1] - x[i]*x[i]) * (x[i+1] - x[i]*x[i]);

// Constraint: x_{i+1} <= x_i^2
for (int i = 0; i < MIN(M_NLCON, n-1); ++ i)
constr[i] = x[i+1] - x[i] * x[i];
constr[i] = x[i+1] - x[i] * x[i];

static int nf = 0;
if (debug) {
Expand Down Expand Up @@ -100,21 +100,19 @@ int main(int argc, char * argv[])
double x0[N_MAX];
double xl[N_MAX];
double xu[N_MAX];
for (int i = 0; i < N_MAX; ++ i)
{
for (int i = 0; i < N_MAX; ++ i) {
x0[i] = random_gen(-1.0, 1.0);
xl[i] = random_gen(-2.0, -1.0);
xu[i] = random_gen(1.0, 2.0);
}
double *Aineq = malloc(N_MAX*M_INEQ_MAX*sizeof(double));
for (int i = 0; i < N_MAX; ++ i)
{
for (int i = 0; i < N_MAX; ++ i) {
for (int j = 0; j < m_ineq; ++ j)
Aineq[j*N_MAX+i] = random_gen(-1.0, 1.0);
Aineq[j*N_MAX+i] = random_gen(-1.0, 1.0);
}
double bineq[M_INEQ_MAX];
for (int j = 0; j < M_INEQ_MAX; ++ j)
bineq[j] = random_gen(-1.0, 1.0);
bineq[j] = random_gen(-1.0, 1.0);

// Define the algorithm and the problem according to `algo`
prima_problem_t problem;
Expand Down

0 comments on commit baa2a1c

Please sign in to comment.