diff --git a/gmrflib/approx-inference.c b/gmrflib/approx-inference.c index 7b731befc..365ebd404 100644 --- a/gmrflib/approx-inference.c +++ b/gmrflib/approx-inference.c @@ -3331,8 +3331,7 @@ GMRFLib_gcpo_groups_tp *GMRFLib_gcpo_build(int thread_id, GMRFLib_ai_store_tp *a assert(build_ai_store != NULL); double *isd = Calloc(mnpred, double); - groups = GMRFLib_idxval_ncreate_x(Npred, 1 + IABS((int) gcpo_param->num_level_sets), - GMRFLib_openmp->max_threads_outer); + groups = GMRFLib_idxval_ncreate_x(Npred, 1 + IABS((int) gcpo_param->num_level_sets), GMRFLib_openmp->max_threads_outer); GMRFLib_ai_add_Qinv_to_ai_store(ai_store); GMRFLib_ai_add_Qinv_to_ai_store(build_ai_store); diff --git a/gmrflib/domin-interface.c b/gmrflib/domin-interface.c index fae72fec1..754222d02 100644 --- a/gmrflib/domin-interface.c +++ b/gmrflib/domin-interface.c @@ -739,7 +739,7 @@ int GMRFLib_opt_estimate_hessian(double *hessian, double *x, double *log_dens_mo char first_entry = 1; int replace_from = -1; - int replace_to = 2*n; + int replace_to = 2 * n; #pragma omp parallel for num_threads(GMRFLib_openmp->max_threads_outer) for (int ii = 0; ii < 2 * n + 1; ii++) { diff --git a/gmrflib/fmesher-io.c b/gmrflib/fmesher-io.c index abee166b1..6ade4485a 100644 --- a/gmrflib/fmesher-io.c +++ b/gmrflib/fmesher-io.c @@ -566,21 +566,21 @@ int GMRFLib_matrix_add_graph_and_hash(GMRFLib_matrix_tp *M, int nt) map_id_init_hint(M->htable[k], nnbs_r[k] + 1); } Free(nnbs_r); - + if (nt == 1) { for (int k = 0; k < M->elems; k++) { map_id_set(M->htable[M->j[k]], M->i[k], M->values[k]); } } else { - int lim[nt+1]; + int lim[nt + 1]; lim[0] = 0; - for(int k = 1; k < nt + 1; k++) { + for (int k = 1; k < nt + 1; k++) { lim[k] = (M->ncol * k) / nt; } #pragma omp parallel for num_threads(nt) - for(int kk = 0; kk < nt; kk++) { + for (int kk = 0; kk < nt; kk++) { int cut_low = lim[kk]; - int cut_high = lim[kk+1]; + int cut_high = lim[kk + 1]; for (int k = 0; k < M->elems; k++) { if (cut_low <= M->j[k] && M->j[k] < cut_high) { map_id_set(M->htable[M->j[k]], M->i[k], M->values[k]); @@ -601,15 +601,15 @@ int GMRFLib_matrix_add_graph_and_hash(GMRFLib_matrix_tp *M, int nt) map_id_set(M->htable[M->i[k]], M->j[k], M->values[k]); } } else { - int lim[nt+1]; + int lim[nt + 1]; lim[0] = 0; - for(int k = 1; k < nt + 1; k++) { + for (int k = 1; k < nt + 1; k++) { lim[k] = (M->nrow * k) / nt; } #pragma omp parallel for num_threads(nt) - for(int kk = 0; kk < nt; kk++) { + for (int kk = 0; kk < nt; kk++) { int cut_low = lim[kk]; - int cut_high = lim[kk+1]; + int cut_high = lim[kk + 1]; for (int k = 0; k < M->elems; k++) { if (cut_low <= M->i[k] && M->i[k] < cut_high) { map_id_set(M->htable[M->i[k]], M->j[k], M->values[k]); @@ -910,8 +910,8 @@ int GMRFLib_idxval_to_matrix(GMRFLib_matrix_tp **M, GMRFLib_idxval_tp **idxval, if (nt <= 0) { nt = GMRFLib_OPENMP_NUM_THREADS_LEVEL(); } - - int nelm = 0; + + int nelm = 0; for (int i = 0; i < nrow; i++) { nelm += idxval[i]->n; } @@ -935,7 +935,7 @@ int GMRFLib_idxval_to_matrix(GMRFLib_matrix_tp **M, GMRFLib_idxval_tp **idxval, } else { int *kk = Calloc(nrow, int); for (int i = 1; i < nrow; i++) { - kk[i] = kk[i-1] + idxval[i-1]->n; + kk[i] = kk[i - 1] + idxval[i - 1]->n; } #pragma omp parallel for num_threads(nt) for (int i = 0; i < nrow; i++) { diff --git a/gmrflib/graph.c b/gmrflib/graph.c index b4927ac1f..1986bcd5b 100644 --- a/gmrflib/graph.c +++ b/gmrflib/graph.c @@ -570,29 +570,29 @@ int *GMRFLib_bsearch(int key, int n, int *array) int GMRFLib_graph_is_nb_ORIG(int node, int nnode, GMRFLib_graph_tp *graph) { - int imin, imax; - if (node < nnode) { - imin = node; - imax = nnode; - } else { - imin = nnode; - imax = node; - } - - int m = graph->lnnbs[imin]; - if (m) { - int *nb = graph->lnbs[imin]; - if (imax <= nb[m - 1]) { - return (GMRFLib_bsearch(imax, m, nb) != NULL); - } - } - - return 0; + int imin, imax; + if (node < nnode) { + imin = node; + imax = nnode; + } else { + imin = nnode; + imax = node; + } + + int m = graph->lnnbs[imin]; + if (m) { + int *nb = graph->lnbs[imin]; + if (imax <= nb[m - 1]) { + return (GMRFLib_bsearch(imax, m, nb) != NULL); + } + } + + return 0; } int GMRFLib_graph_is_nb(int node, int nnode, GMRFLib_graph_tp *graph) { - if (node < nnode) { + if (node < nnode) { if (graph->lnnbs[node] <= graph->lnnbs[nnode]) { int m = graph->lnnbs[node]; if (m) { @@ -620,7 +620,7 @@ int GMRFLib_graph_is_nb(int node, int nnode, GMRFLib_graph_tp *graph) } } - return 0; + return 0; } int GMRFLib_graph_is_nb_g_________NOT_IN_USE(int node, int nnode, GMRFLib_graph_tp *graph, int *g) @@ -1049,10 +1049,10 @@ int GMRFLib_graph_duplicate(GMRFLib_graph_tp **graph_new, GMRFLib_graph_tp *grap } else { int *arr = Calloc(n, int); for (int i = 1; i < n; i++) { - arr[i] = arr[i-1] + g->nnbs[i-1]; + arr[i] = arr[i - 1] + g->nnbs[i - 1]; } #pragma omp parallel for num_threads(NUM_THREADS_GRAPH(g)) - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { if (g->nnbs[i]) { hold_idx = arr[i]; g->nbs[i] = &hold[hold_idx]; diff --git a/gmrflib/idxval.c b/gmrflib/idxval.c index b218784d1..71479c7d3 100644 --- a/gmrflib/idxval.c +++ b/gmrflib/idxval.c @@ -1325,7 +1325,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/idxval.h b/gmrflib/idxval.h index 3998594fd..fde3fcfa8 100644 --- a/gmrflib/idxval.h +++ b/gmrflib/idxval.h @@ -171,7 +171,7 @@ int GMRFLib_idx_uniq(GMRFLib_idx_tp * hold); int GMRFLib_idxval_add(GMRFLib_idxval_tp ** hold, int idx, double val); int GMRFLib_idxval_addto(GMRFLib_idxval_tp ** hold, int idx, double val); int GMRFLib_idxval_create(GMRFLib_idxval_tp ** hold); -int GMRFLib_idxval_create_x(GMRFLib_idxval_tp ** hold, int len); +int GMRFLib_idxval_create_x(GMRFLib_idxval_tp ** hold, int len); int GMRFLib_idxval_free(GMRFLib_idxval_tp * hold); int GMRFLib_idxval_info_printf(FILE * fp, GMRFLib_idxval_tp * hold, const char *msg); int GMRFLib_idxval_nprune(GMRFLib_idxval_tp ** a, int n, int nt); 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 0f4f3b486..718daef0a 100644 --- a/inlaprog/src/inla-likelihood.c +++ b/inlaprog/src/inla-likelihood.c @@ -5857,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.h b/inlaprog/src/inla.h index 21d377956..f468b9b59 100644 --- a/inlaprog/src/inla.h +++ b/inlaprog/src/inla.h @@ -2291,7 +2291,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);