Skip to content

Commit

Permalink
Indent only
Browse files Browse the repository at this point in the history
  • Loading branch information
hrue committed Nov 17, 2024
1 parent 9c0dc99 commit 2603885
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion gmrflib/idxval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions gmrflib/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
19 changes: 9 additions & 10 deletions inlaprog/src/inla-likelihood.c
Original file line number Diff line number Diff line change
Expand Up @@ -2981,27 +2981,26 @@ 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);

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];

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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));
Expand Down
28 changes: 14 additions & 14 deletions inlaprog/src/inla.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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),
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion inlaprog/src/inla.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2603885

Please sign in to comment.