Skip to content

Commit

Permalink
Indent only
Browse files Browse the repository at this point in the history
  • Loading branch information
hrue committed Jan 11, 2024
1 parent c35addf commit 0cf5539
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
1 change: 0 additions & 1 deletion gmrflib/dot.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,3 @@ double GMRFLib_ddot_idx_mkl(int n, double *__restrict v, double *__restrict a, i
}

#endif /* if defined(INLA_LINK_WITH_MKL) */

26 changes: 11 additions & 15 deletions gmrflib/idxval.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in
// check if we have one of two special cases. sequential with or without all one. If so, add them spesifically
int is_sequential = 1;
for (int i = 1; is_sequential && i < h->n; i++) {
is_sequential = (h->idx[i] == h->idx[i-1] + 1);
is_sequential = (h->idx[i] == h->idx[i - 1] + 1);
}
if (is_sequential) {
int is_all_1 = 1;
Expand All @@ -551,23 +551,23 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in

h->g_n = 1;
h->g_len = Calloc(1, int);
h->g_len[0] = - h->n;
h->g_len[0] = -h->n;

assert(h->n > 0);
h->g_n_mem = 2;
h->g_mem = Calloc(2, void *);
h->g_mem[0] = (void *) (Calloc(h->n, int));
h->g_mem[0] = (void *) (Calloc(h->n, int));
h->g_mem[1] = (void *) (Calloc(h->n, double));

h->g_idx = Calloc(1, int *);
h->g_idx[0] = (int *) h->g_mem[0];
Memcpy(h->g_idx[0], h->idx, h->n * sizeof(int));

h->g_val = Calloc(1, double *);
h->g_val[0] = (double *) h->g_mem[1];
Memcpy(h->g_val[0], h->val, h->n * sizeof(double));
h->g_1 = Calloc(1, int );

h->g_1 = Calloc(1, int);
h->g_1[0] = is_all_1;

h->preference = IDXVAL_GROUP_MKL;
Expand All @@ -577,7 +577,6 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in

return GMRFLib_SUCCESS;
}

// an upper bound for the number of groups for memory allocation
int ng = 1;
int i = 1;
Expand All @@ -588,7 +587,7 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in
i++;
ng += 2;
}

int *g_istart = Calloc(ng, int);
int *g_len = Calloc(ng, int);
int *g_1 = Calloc(ng, int);
Expand All @@ -615,7 +614,7 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in

// keep only sequential groups with length >= limit_g_len
int ggg = 1;
for(int g = 1; g < ng; g++) {
for (int g = 1; g < ng; g++) {
if (g_len[g] >= limit_g_len) {
g_istart[ggg] = g_istart[g];
g_len[ggg] = g_len[g];
Expand Down Expand Up @@ -712,7 +711,6 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in
printf("i %d new_idx %1d new_val %f\n", i, new_idx[i], new_val[i]);
}
}

// set g_1's
g_1[0] = 0;
for (int g = 0; g < ng; g++) {
Expand All @@ -733,7 +731,6 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in
}
}
}

// remove groups with zero length
int g = 0;
while (1) {
Expand Down Expand Up @@ -761,7 +758,6 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in
printf("group %1d start %1d len %1d g_1 %1d\n", g, g_istart[g], g_len[g], g_1[g]);
}
}

// merge
if (ng > 2) {
g = 1;
Expand Down Expand Up @@ -840,7 +836,7 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in
treff[0] -= GMRFLib_cpu();
value[0] = GMRFLib_dot_product_serial(h, x);
treff[0] += GMRFLib_cpu();

if (with_mkl) {
treff[1] -= GMRFLib_cpu();
value[1] = GMRFLib_dot_product_serial_mkl(h, x);
Expand Down Expand Up @@ -956,7 +952,7 @@ int GMRFLib_idxval_nsort_x_core(GMRFLib_idxval_tp *h, double *x, int prepare, in
h->g_n_mem = 0;
}
}

if (GMRFLib_dot_product_optim_report || GMRFLib_testit_mode) {
int idx = 0;
GMRFLib_CACHE_SET_ID(idx);
Expand Down Expand Up @@ -1145,7 +1141,7 @@ int GMRFLib_str_is_member(GMRFLib_str_tp *hold, char *s, int case_sensitive, int
return 0;
}

int (*cmp)(const char *, const char *) =(case_sensitive ? strcmp : strcasecmp);
int (*cmp)(const char *, const char *) = (case_sensitive ? strcmp : strcasecmp);
for (int i = 0; i < hold->n; i++) {
if (cmp(s, hold->str[i]) == 0) {
if (idx_match) {
Expand Down
3 changes: 1 addition & 2 deletions gmrflib/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ __BEGIN_DECLS
\brief Define GMRFLib_TRUE as (1)
*/
#define GMRFLib_TRUE (1)

#endif
__END_DECLS
__END_DECLS
#endif
4 changes: 2 additions & 2 deletions inlaprog/src/inla-likelihood.c
Original file line number Diff line number Diff line change
Expand Up @@ -4854,9 +4854,9 @@ int loglikelihood_mix_gaussian(int thread_id, double *logll, double *x, int m, i

int loglikelihood_mix_core(int thread_id, double *logll, double *x, int m, int idx, double *x_vec, double *y_cdf, void *arg,
int (*func_quadrature)(int, double **, double **, int *, void *arg),
int(*func_simpson)(int, double **, double **, int *, void *arg), char **arg_str)
int (*func_simpson)(int, double **, double **, int *, void *arg), char **arg_str)
{
Data_section_tp *ds =(Data_section_tp *) arg;
Data_section_tp *ds = (Data_section_tp *) arg;
if (m == 0) {
if (arg) {
return (ds->mix_loglikelihood(thread_id, NULL, NULL, 0, 0, NULL, NULL, arg, arg_str));
Expand Down
2 changes: 1 addition & 1 deletion inlaprog/src/inla-testit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2267,7 +2267,7 @@ int testit(int argc, char **argv)
double *xx = Calloc(n, double);

GMRFLib_testit_debug = debug;

for (int i = 0; i < n; i++) {
xx[i] = (GMRFLib_uniform() < 0.8 ? 1.0 : GMRFLib_uniform());
}
Expand Down
2 changes: 1 addition & 1 deletion inlaprog/src/inla.h
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,7 @@ int loglikelihood_lognormal(int thread_id, double *logll, double *x, int m, int
int loglikelihood_lognormalsurv(int thread_id, double *logll, double *x, int m, int idx, double *x_vec, double *y_cdf, void *arg, char **arg_str);
int loglikelihood_logperiodogram(int thread_id, double *logll, double *x, int m, int idx, double *x_vec, double *y_cdf, void *arg, char **arg_str);
int loglikelihood_mix_core(int thread_id, double *logll, double *x, int m, int idx, double *x_vec, double *y_cdf, void *arg,
int (*quadrature)(int, double **, double **, int *, void *), int (*simpson)(int, double **, double **, int *, void *),
int (*quadrature)(int, double **, double **, int *, void *), int(*simpson)(int, double **, double **, int *, void *),
char **arg_str);
int loglikelihood_mix_loggamma(int thread_id, double *logll, double *x, int m, int idx, double *x_vec, double *y_cdf, void *arg, char **arg_str);
int loglikelihood_mix_mloggamma(int thread_id, double *logll, double *x, int m, int idx, double *x_vec, double *y_cdf, void *arg, char **arg_str);
Expand Down

0 comments on commit 0cf5539

Please sign in to comment.