From 26038855321369a29d19323da6c890e7bf57a9a2 Mon Sep 17 00:00:00 2001 From: Haavard Rue Date: Sun, 17 Nov 2024 12:03:41 +0300 Subject: [PATCH] Indent only --- gmrflib/idxval.c | 2 +- gmrflib/utils.c | 10 +++++----- inlaprog/src/inla-likelihood.c | 19 +++++++++---------- inlaprog/src/inla.c | 28 ++++++++++++++-------------- inlaprog/src/inla.h | 2 +- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/gmrflib/idxval.c b/gmrflib/idxval.c index fafe49652..c4bfe03dd 100644 --- a/gmrflib/idxval.c +++ b/gmrflib/idxval.c @@ -1318,7 +1318,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) { diff --git a/gmrflib/utils.c b/gmrflib/utils.c index bc23a367e..7d0a73907 100644 --- a/gmrflib/utils.c +++ b/gmrflib/utils.c @@ -2111,9 +2111,9 @@ int GMRFLib_is_sorted_ddec_plain(int n, double *a) int GMRFLib_is_sorted(void *a, size_t n, size_t size, int (*cmp)(const void *, const void *)) { - if((cmp ==(void *) GMRFLib_icmp) && size == sizeof(int)) { + if ( (cmp == (void *) GMRFLib_icmp) && size == sizeof(int)) { // increasing ints - return GMRFLib_is_sorted_iinc(n,(int *) a); + return GMRFLib_is_sorted_iinc(n, (int *) a); } else if (cmp == (void *) GMRFLib_icmp_r && size == sizeof(int)) { // decreasing ints return GMRFLib_is_sorted_idec(n, (int *) a); @@ -2133,15 +2133,15 @@ int GMRFLib_is_sorted(void *a, size_t n, size_t size, int (*cmp)(const void *, c void GMRFLib_qsort(void *a, size_t n, size_t size, int (*cmp)(const void *, const void *)) { // sort if not sorted - if(n > 0 && !GMRFLib_is_sorted(a, n, size, cmp)) { + if (n > 0 && !GMRFLib_is_sorted(a, n, size, cmp)) { QSORT_FUN(a, n, size, cmp); } } void GMRFLib_qsort2(void *x, size_t nmemb, size_t size_x, void *y, size_t size_y, int (*compar)(const void *, const void *)) { - if(!y) { - return (GMRFLib_qsort(x, nmemb, size_x, compar)); + if (!y) { + return(GMRFLib_qsort(x, nmemb, size_x, compar)); } if (nmemb == 0) { diff --git a/inlaprog/src/inla-likelihood.c b/inlaprog/src/inla-likelihood.c index 676254fcd..9fe9707e3 100644 --- a/inlaprog/src/inla-likelihood.c +++ b/inlaprog/src/inla-likelihood.c @@ -2981,13 +2981,12 @@ int loglikelihood_occupancy(int thread_id, double *__restrict logll, double *__r if (m == 0) { return GMRFLib_SUCCESS; } - #if 0 // debug-code to check the likelihood if (m != 99) { double xx[99]; - for(int i = 0; i < 99; i++) { - xx[i] = -4.0 + 8.0 * i/99.0; + for (int i = 0; i < 99; i++) { + xx[i] = -4.0 + 8.0 * i / 99.0; } double llxx[99]; loglikelihood_occupancy(thread_id, llxx, xx, 99, idx, NULL, NULL, arg, NULL); @@ -2995,13 +2994,13 @@ int loglikelihood_occupancy(int thread_id, double *__restrict logll, double *__r char *fnm; GMRFLib_sprintf(&fnm, "FILE%1d.txt", idx); FILE *fp = fopen(fnm, "w"); - for(int i = 0; i < 99; i++) { - fprintf(fp, "%f %f\n", xx[i], llxx[i]); + for (int i = 0; i < 99; i++) { + fprintf(fp, "%f %f\n", xx[i], llxx[i]); } fclose(fp); } #endif - + Data_section_tp *ds = (Data_section_tp *) arg; int ny = ds->data_observations.occ_ny[idx]; @@ -3202,7 +3201,7 @@ int loglikelihood_occupancy(int thread_id, double *__restrict logll, double *__r double t19 = exp(-t2); double t22 = SQR(-cg + cg * t19 - t19); double c2 = - -(-t1 * t4 + t1 * t8 - 2.0 * cg * t8 + t1 * t14 + cg * t4 + t8 - cg * t14) / t22; + -(-t1 * t4 + t1 * t8 - 2.0 * cg * t8 + t1 * t14 + cg * t4 + t8 - cg * t14) / t22; logll[i] = c0 + dx * (c1 + 0.5 * c2 * dx); } } @@ -3393,7 +3392,7 @@ int loglikelihood_binomialmix(int thread_id, double *__restrict logll, double *_ int nbeta = 2 * mm + 1; double y = ds->data_observations.y[idx]; double *dat = ds->data_observations.binmix_dat[idx]; - double n = dat[nbeta + 4]; + double n = dat[nbeta + 4]; double ny = n - y; if (ISZERO(y) && ISZERO(n)) { @@ -5858,9 +5857,9 @@ int loglikelihood_mix_gaussian(int thread_id, double *__restrict logll, double * int loglikelihood_mix_core(int thread_id, double *__restrict logll, double *__restrict 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)); diff --git a/inlaprog/src/inla.c b/inlaprog/src/inla.c index f09df42d2..5331f50d0 100644 --- a/inlaprog/src/inla.c +++ b/inlaprog/src/inla.c @@ -1996,7 +1996,7 @@ double extra(int thread_id, double *theta, int ntheta, void *argument) case L_BINOMIALMIX: { int m = ds->data_observations.binmix_m; - for (int k = 0; k < 2*m+1; k++) { + for (int k = 0; k < 2 * m + 1; k++) { if (!ds->data_nfixed[k]) { double b = theta[count]; val += PRIOR_EVAL(ds->data_nprior[k], &b); @@ -5948,30 +5948,30 @@ int inla_INLA_preopt_experimental(inla_tp *mb) GMRFLib_openmp->likelihood_nt = 0; int nt_upper = IMAX(1, IMIN(512, GMRFLib_MAX_THREADS())); double tused[nt_upper + 1]; - for(int nt = 1; nt <= nt_upper; nt++) { + for (int nt = 1; nt <= nt_upper; nt++) { double sum = 0.0, xx = 0.0; tused[nt] = -GMRFLib_timer(); - for(int kk = 0; kk < 2; kk++) { + for (int kk = 0; kk < 2; kk++) { #pragma omp parallel for num_threads(nt) reduction(+: sum) - for (int ii = 0; ii < d_idx->n; ii++) { + for (int ii = 0; ii < d_idx->n; ii++) { int idx = d_idx->idx[ii]; - double acoof = 0.0, bcoof = 0.0, ccoof = 0.0; - GMRFLib_2order_approx(0, &acoof, &bcoof, &ccoof, NULL, mb->d[idx], - xx, idx, NULL, loglikelihood_inla, (void *) mb, - &(mb->ai_par->step_len), &(mb->ai_par->stencil), NULL); + double acoof = 0.0, bcoof = 0.0, ccoof = 0.0; + GMRFLib_2order_approx(0, &acoof, &bcoof, &ccoof, NULL, mb->d[idx], + xx, idx, NULL, loglikelihood_inla, (void *) mb, + &(mb->ai_par->step_len), &(mb->ai_par->stencil), NULL); sum += acoof + bcoof + ccoof; } } assert(sum != 0.0); tused[nt] += GMRFLib_timer(); if (mb->verbose) { - printf("\tnum.threads = %1d time = %.4fms\n", nt, tused[nt]*1.0E3); + printf("\tnum.threads = %1d time = %.4fms\n", nt, tused[nt] * 1.0E3); } - if (nt > 1 && tused[nt] >= tused[nt-1]) { + if (nt > 1 && tused[nt] >= tused[nt - 1]) { if (mb->verbose) { - printf("\t\tFound optimal num.threads = %1d\n\n", nt-1); + printf("\t\tFound optimal num.threads = %1d\n\n", nt - 1); } - GMRFLib_openmp->likelihood_nt = nt-1; + GMRFLib_openmp->likelihood_nt = nt - 1; break; } else if (nt == nt_upper) { GMRFLib_openmp->likelihood_nt = nt; @@ -5980,7 +5980,7 @@ int inla_INLA_preopt_experimental(inla_tp *mb) GMRFLib_idx_free(d_idx); } #endif - + GMRFLib_ai_INLA_experimental(&(mb->density), NULL, NULL, (mb->output->hyperparameters ? &(mb->density_hyper) : NULL), @@ -6670,7 +6670,7 @@ int main(int argc, char **argv) GMRFLib_openmp->likelihood_nt = 0; GMRFLib_openmp->strategy = GMRFLib_OPENMP_STRATEGY_DEFAULT; GMRFLib_openmp_implement_strategy(GMRFLib_OPENMP_PLACES_DEFAULT, NULL, NULL); - + GMRFLib_bitmap_max_dimension = 512; GMRFLib_bitmap_swap = GMRFLib_TRUE; GMRFLib_aqat_m_diag_add = GSL_SQRT_DBL_EPSILON; diff --git a/inlaprog/src/inla.h b/inlaprog/src/inla.h index 05c12dcae..8fd2e5928 100644 --- a/inlaprog/src/inla.h +++ b/inlaprog/src/inla.h @@ -2288,7 +2288,7 @@ int loglikelihood_logperiodogram(int thread_id, double *logll, double *x, int m, int loglikelihood_mgamma(int thread_id, double *logll, double *x, int m, int idx, double *x_vec, double *y_cdf, void *arg, char **arg_str); int loglikelihood_mgammasurv(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);