commit 96f3253a1fd102b0056ff662258efc3225cba159
parent c5ef277973c439a7698525ca44e380eb2f532b38
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 19 Apr 2016 12:42:35 +0200
Make the programming style uniform
Diffstat:
3 files changed, 22 insertions(+), 27 deletions(-)
diff --git a/src/smc.h b/src/smc.h
@@ -179,8 +179,7 @@ smc_device_get_rng_type
/*******************************************************************************
* Integration API
******************************************************************************/
-
-/* Return RES_BAD_OP if auto cancel is enabled and the number of error is reached */
+/* Return RES_BAD_OP if the maximum number of failures is reached */
SMC_API res_T
smc_solve
(struct smc_device* dev,
@@ -188,7 +187,7 @@ smc_solve
void* ctx,
struct smc_estimator** estimator);
-/* Return RES_BAD_OP if auto cancel is enabled and the number of error is reached */
+/* Return RES_BAD_OP if the maximum number of failures is reached */
SMC_API res_T
smc_solve_N
(struct smc_device* dev,
@@ -214,10 +213,9 @@ smc_estimator_get_status
/*******************************************************************************
* Accumulation API
******************************************************************************/
-/* Raw integration.
- * The realisations must be accumulated by the user defined integrand
- * Return RES_BAD_OP if auto cancel is enabled and the number of error is reached
- */
+/* Raw integration. The realisations must be accumulated by the user defined
+ * integrand. Return RES_BAD_OP if auto cancel is enabled and the number of
+ * error is reached */
SMC_API res_T
smc_integrate
(struct smc_device* dev,
diff --git a/src/smc_accumulator.c b/src/smc_accumulator.c
@@ -170,18 +170,17 @@ smc_integrate
const int ithread = omp_get_thread_num();
#pragma omp for schedule(static)
for(i=0; i < (int64_t)integrator->max_steps; ++i) {
- if(!cancel) {
+ if(!cancel) {
if(integrator->integrand(accums[ithread], dev->rngs[ithread], ctx) == RES_OK) {
/* call succeded */
++nsamples[ithread];
- }
- else {
-#pragma omp atomic
+ } else {
+ #pragma omp atomic
++nfailed;
if (nfailed > integrator->max_failures) {
cancel = 1;
- res = RES_BAD_OP;
- }
+ res = RES_BAD_OP;
+ }
}
}
}
diff --git a/src/smc_estimator.c b/src/smc_estimator.c
@@ -203,21 +203,20 @@ smc_solve
const int ithread = omp_get_thread_num();
#pragma omp for schedule(static)
for(i = 0; i < (int64_t)integrator->max_steps; ++i) {
- if (! cancel) {
+ if(!cancel) {
if(integrator->integrand(vals[ithread], dev->rngs[ithread], ctx) == RES_OK) {
/* call succeded */
integrator->type->add(accums[ithread], accums[ithread], vals[ithread]);
integrator->type->mul(vals[ithread], vals[ithread], vals[ithread]);
integrator->type->add(accums_sqr[ithread], accums_sqr[ithread], vals[ithread]);
++nsamples[ithread];
- }
- else {
-#pragma omp atomic
- ++nfailed;
+ } else {
+ #pragma omp atomic
+ ++nfailed;
if (nfailed > integrator->max_failures) {
cancel = 1;
- res = RES_BAD_OP;
- }
+ res = RES_BAD_OP;
+ }
}
}
}
@@ -304,9 +303,9 @@ smc_solve_N
for(i = 0; i < (int64_t)count; ++i) {
size_t istep;
FOR_EACH(istep, 0, integrator->max_steps) {
- if (! cancel) {
+ if(!cancel) {
if(integrator->integrand
- (vals[ithread], dev->rngs[ithread], (char*)ctx + (size_t)i*sizeof_ctx)
+ (vals[ithread], dev->rngs[ithread], (char*)ctx + (size_t)i*sizeof_ctx)
== RES_OK) {
/* call succeded */
integrator->type->add
@@ -315,14 +314,13 @@ smc_solve_N
integrator->type->add
(estimators[i]->square_value, estimators[i]->square_value, vals[ithread]);
++estimators[i]->nsamples;
- }
- else {
-#pragma omp atomic
- ++estimators[i]->nfailed;
+ } else {
+ #pragma omp atomic
+ ++estimators[i]->nfailed;
if (estimators[i]->nfailed > integrator->max_failures) {
cancel = 1;
res = RES_BAD_OP;
- }
+ }
}
}
}