Skip to content

Commit 42c14f8

Browse files
committed
Resolve misleading-indentation warnings from gcc 6
1 parent fa58dc2 commit 42c14f8

File tree

5 files changed

+119
-120
lines changed

5 files changed

+119
-120
lines changed

inst/include/Rcpp/stats/exp.h

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,46 +27,45 @@
2727

2828
namespace Rcpp {
2929
namespace stats {
30-
inline double d_exp_0( double x, int give_log){
30+
inline double d_exp_0(double x, int give_log) {
3131

3232
#ifdef IEEE_754
33-
/* NaNs propagated correctly */
34-
if (ISNAN(x) ) return x + 1.0 ;
33+
/* NaNs propagated correctly */
34+
if (ISNAN(x)) return x + 1.0;
3535
#endif
3636

37-
if (x < 0.)
38-
return R_D__0;
37+
if (x < 0.)
38+
return R_D__0;
3939
return give_log ? (-x) : ::exp(-x);
4040
}
41-
inline double q_exp_0( double p, int lower_tail, int log_p){
41+
inline double q_exp_0(double p, int lower_tail, int log_p) {
4242
#ifdef IEEE_754
4343
if (ISNAN(p)) return p + 1.0;
4444
#endif
4545

46-
if ((log_p && p > 0) || (!log_p && (p < 0 || p > 1)) ) return R_NaN ;
46+
if ((log_p && p > 0) || (!log_p && (p < 0 || p > 1))) return R_NaN;
4747
if (p == R_DT_0)
48-
return 0;
48+
return 0;
4949

5050
return - R_DT_Clog(p);
5151
}
5252
inline double p_exp_0(double x, int lower_tail, int log_p) {
53-
#ifdef IEEE_754
54-
if (ISNAN(x) )
55-
return x + 1.0 ;
56-
#endif
53+
#ifdef IEEE_754
54+
if (ISNAN(x)) return x + 1.0;
55+
#endif
5756

58-
if (x <= 0.)
59-
return R_DT_0;
60-
/* same as weibull( shape = 1): */
61-
x = -x;
62-
if (lower_tail)
63-
return (log_p
64-
/* log(1 - exp(x)) for x < 0 : */
65-
? (x > -M_LN2 ? ::log(-::expm1(x)) : ::log1p(-::exp(x)))
66-
: -::expm1(x));
67-
/* else: !lower_tail */
68-
return R_D_exp(x);
69-
}
57+
if (x <= 0.)
58+
return R_DT_0;
59+
/* same as weibull(shape = 1): */
60+
x = -x;
61+
if (lower_tail)
62+
return (log_p
63+
/* log(1 - exp(x)) for x < 0 : */
64+
? (x > -M_LN2 ? ::log(-::expm1(x)) : ::log1p(-::exp(x)))
65+
: -::expm1(x));
66+
/* else: !lower_tail */
67+
return R_D_exp(x);
68+
}
7069

7170
} // stats
7271
} // Rcpp

inst/include/Rcpp/stats/lnorm.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ inline double dlnorm_0(double x, int log_p){
3333

3434
#ifdef IEEE_754
3535
if (ISNAN(x))
36-
return x + 1.0 ;
36+
return x + 1.0;
3737
#endif
3838

39-
if(x <= 0) return R_D__0;
39+
if (x <= 0) return R_D__0;
4040

41-
y = ::log(x) ;
41+
y = ::log(x);
4242
return (log_p ?
43-
-(M_LN_SQRT_2PI + 0.5 * y * y + ::log(x)) :
44-
M_1_SQRT_2PI * ::exp(-0.5 * y * y) / x );
43+
-(M_LN_SQRT_2PI + 0.5 * y * y + ::log(x)) :
44+
M_1_SQRT_2PI * ::exp(-0.5 * y * y) / x);
4545
/* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */
4646

4747
}
@@ -50,47 +50,47 @@ inline double dlnorm_1(double x, double meanlog, int log_p){
5050
double y;
5151

5252
#ifdef IEEE_754
53-
if (ISNAN(x) || ISNAN(meanlog) )
54-
return x + meanlog + 1.0 ;
53+
if (ISNAN(x) || ISNAN(meanlog))
54+
return x + meanlog + 1.0;
5555
#endif
5656

57-
if(x <= 0) return R_D__0;
57+
if (x <= 0) return R_D__0;
5858

5959
y = (::log(x) - meanlog);
6060
return (log_p ?
61-
-(M_LN_SQRT_2PI + 0.5 * y * y + ::log(x)) :
62-
M_1_SQRT_2PI * ::exp(-0.5 * y * y) / x );
61+
-(M_LN_SQRT_2PI + 0.5 * y * y + ::log(x)) :
62+
M_1_SQRT_2PI * ::exp(-0.5 * y * y) / x);
6363
/* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */
6464

6565
}
6666

6767

6868
inline double plnorm_0(double x, int lower_tail, int log_p){
6969
#ifdef IEEE_754
70-
if (ISNAN(x) )
71-
return x + 1.0 ;
70+
if (ISNAN(x))
71+
return x + 1.0;
7272
#endif
7373

7474
if (x > 0)
75-
return Rcpp::stats::pnorm_0(::log(x), lower_tail, log_p);
75+
return Rcpp::stats::pnorm_0(::log(x), lower_tail, log_p);
7676
return R_DT_0;
7777
}
7878

7979
inline double plnorm_1(double x, double meanlog, int lower_tail, int log_p) {
8080
#ifdef IEEE_754
81-
if (ISNAN(x) || ISNAN(meanlog) )
82-
return x + meanlog + 1.0 ;
81+
if (ISNAN(x) || ISNAN(meanlog))
82+
return x + meanlog + 1.0;
8383
#endif
8484

85-
if (x > 0)
86-
return Rcpp::stats::pnorm_1(::log(x), meanlog, lower_tail, log_p);
85+
if (x > 0)
86+
return Rcpp::stats::pnorm_1(::log(x), meanlog, lower_tail, log_p);
8787
return R_DT_0;
8888
}
8989

9090
inline double qlnorm_0(double p, int lower_tail, int log_p){
9191
#ifdef IEEE_754
92-
if (ISNAN(p) )
93-
return p + 1.0 ;
92+
if (ISNAN(p))
93+
return p + 1.0;
9494
#endif
9595
R_Q_P01_boundaries(p, 0, ML_POSINF);
9696

@@ -100,7 +100,7 @@ inline double qlnorm_0(double p, int lower_tail, int log_p){
100100
inline double qlnorm_1(double p, double meanlog, int lower_tail, int log_p){
101101
#ifdef IEEE_754
102102
if (ISNAN(p) || ISNAN(meanlog))
103-
return p + meanlog + 1.0 ;
103+
return p + meanlog + 1.0;
104104
#endif
105105
R_Q_P01_boundaries(p, 0, ML_POSINF);
106106

inst/include/Rcpp/stats/logis.h

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,36 @@ inline double dlogis_0(double x /*, double location [=0.0], double scale [=1.0]
2929
double e, f;
3030
#ifdef IEEE_754
3131
if (ISNAN(x))
32-
return x + 1.0 ;
32+
return x + 1.0;
3333
#endif
3434

35-
e = ::exp(-::fabs(x));
36-
f = 1.0 + e ;
35+
e = ::exp(-::fabs(x));
36+
f = 1.0 + e;
3737
return give_log ? -(x + ::log(f * f)) : e / (f * f);
3838
}
3939

4040
inline double dlogis_1(double x, double location /*, double scale [=1.0] */, int give_log){
4141
double e, f;
4242
#ifdef IEEE_754
4343
if (ISNAN(x) || ISNAN(location))
44-
return x + location + 1.0;
44+
return x + location + 1.0;
4545
#endif
4646

47-
x = ::fabs((x - location) );
47+
x = ::fabs((x - location));
4848
e = ::exp(-x);
4949
f = 1.0 + e;
5050
return give_log ? -(x + ::log(f * f)) : e / (f * f);
5151
}
5252

5353

5454
inline double plogis_0(double x /*, double location [=0.0] , double scale [=1.0] */,
55-
int lower_tail, int log_p) {
55+
int lower_tail, int log_p) {
5656
#ifdef IEEE_754
57-
if (ISNAN(x) )
58-
return x + 1.0 ;
57+
if (ISNAN(x))
58+
return x + 1.0;
5959
#endif
6060

61-
if (ISNAN(x)) return R_NaN ;
61+
if (ISNAN(x)) return R_NaN;
6262
R_P_bounds_Inf_01(x);
6363

6464
x = ::exp(lower_tail ? -x : x);
@@ -67,14 +67,14 @@ inline double plogis_0(double x /*, double location [=0.0] , double scale [=1.0]
6767

6868

6969
inline double plogis_1(double x, double location /*, double scale [=1.0] */,
70-
int lower_tail, int log_p) {
70+
int lower_tail, int log_p) {
7171
#ifdef IEEE_754
72-
if (ISNAN(x) || ISNAN(location) )
73-
return x + location + 1.0 ;
72+
if (ISNAN(x) || ISNAN(location))
73+
return x + location + 1.0;
7474
#endif
7575

76-
x = (x - location) ;
77-
if (ISNAN(x)) return R_NaN ;
76+
x = (x - location);
77+
if (ISNAN(x)) return R_NaN;
7878
R_P_bounds_Inf_01(x);
7979

8080
x = ::exp(lower_tail ? -x : x);
@@ -86,19 +86,19 @@ inline double qlogis_0(double p /*, double location [=0.0], double scale [=1.0]
8686
{
8787
#ifdef IEEE_754
8888
if (ISNAN(p))
89-
return p + 1.0 ;
89+
return p + 1.0;
9090
#endif
9191
R_Q_P01_boundaries(p, ML_NEGINF, ML_POSINF);
9292

93-
/* p := logit(p) = log( p / (1-p) ) : */
94-
if(log_p) {
95-
if(lower_tail)
96-
p = p - ::log1p(- ::exp(p));
97-
else
98-
p = ::log1p(- ::exp(p)) - p;
93+
/* p := logit(p) = log(p / (1. - p)) : */
94+
if (log_p) {
95+
if (lower_tail)
96+
p = p - ::log1p(- ::exp(p));
97+
else
98+
p = ::log1p(- ::exp(p)) - p;
9999
}
100100
else
101-
p = ::log(lower_tail ? (p / (1. - p)) : ((1. - p) / p));
101+
p = ::log(lower_tail ? (p / (1. - p)) : ((1. - p) / p));
102102

103103
return p;
104104
}
@@ -108,19 +108,19 @@ inline double qlogis_1(double p, double location /*, double scale [=1.0] */, int
108108
{
109109
#ifdef IEEE_754
110110
if (ISNAN(p) || ISNAN(location))
111-
return p + location + 1.0 ;
111+
return p + location + 1.0;
112112
#endif
113113
R_Q_P01_boundaries(p, ML_NEGINF, ML_POSINF);
114114

115-
/* p := logit(p) = log( p / (1-p) ) : */
116-
if(log_p) {
117-
if(lower_tail)
118-
p = p - ::log1p(- ::exp(p));
119-
else
120-
p = ::log1p(- ::exp(p)) - p;
115+
/* p := logit(p) = log(p / (1. - p)) : */
116+
if (log_p) {
117+
if (lower_tail)
118+
p = p - ::log1p(- ::exp(p));
119+
else
120+
p = ::log1p(- ::exp(p)) - p;
121121
}
122122
else
123-
p = ::log(lower_tail ? (p / (1. - p)) : ((1. - p) / p));
123+
p = ::log(lower_tail ? (p / (1. - p)) : ((1. - p) / p));
124124

125125
return location + p;
126126
}

inst/include/Rcpp/stats/norm.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@ namespace stats {
2727

2828
inline double dnorm_1(double x, double mu /*, double sigma [=1.0]*/ , int give_log) {
2929
#ifdef IEEE_754
30-
if (ISNAN(x) || ISNAN(mu) )
31-
return x + mu + 1.0 ;
30+
if (ISNAN(x) || ISNAN(mu))
31+
return x + mu + 1.0;
3232
#endif
33-
if(!R_FINITE(x) && mu == x) return ML_NAN;/* x-mu is NaN */
34-
x = (x - mu) ;
33+
if (!R_FINITE(x) && mu == x) return ML_NAN; /* x-mu is NaN */
34+
x = (x - mu);
3535

36-
if(!R_FINITE(x)) return R_D__0;
36+
if (!R_FINITE(x)) return R_D__0;
3737
return (give_log ?
38-
-(M_LN_SQRT_2PI + 0.5 * x * x ) :
39-
M_1_SQRT_2PI * ::exp(-0.5 * x * x) );
38+
-(M_LN_SQRT_2PI + 0.5 * x * x) :
39+
M_1_SQRT_2PI * ::exp(-0.5 * x * x));
4040
/* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */
4141
}
4242

4343
inline double dnorm_0(double x /*, double mu [=0.0], double sigma [=1.0]*/ , int give_log) {
4444
#ifdef IEEE_754
45-
if (ISNAN(x) )
46-
return x + 1.0 ;
45+
if (ISNAN(x))
46+
return x + 1.0;
4747
#endif
48-
if(!R_FINITE(x)) return R_D__0;
48+
if (!R_FINITE(x)) return R_D__0;
4949
return (give_log ?
50-
-(M_LN_SQRT_2PI + 0.5 * x * x ) :
51-
M_1_SQRT_2PI * ::exp(-0.5 * x * x) );
50+
-(M_LN_SQRT_2PI + 0.5 * x * x) :
51+
M_1_SQRT_2PI * ::exp(-0.5 * x * x));
5252
/* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */
5353
}
5454

@@ -59,13 +59,13 @@ inline double pnorm_1(double x, double mu /*, double sigma [=1.]*/ , int lower_t
5959
* For example, if x == mu and sigma == 0, we get the correct answer 1.
6060
*/
6161
#ifdef IEEE_754
62-
if(ISNAN(x) || ISNAN(mu) )
63-
return x + mu + 1.0 ;
62+
if (ISNAN(x) || ISNAN(mu))
63+
return x + mu + 1.0;
6464
#endif
65-
if(!R_FINITE(x) && mu == x) return ML_NAN;/* x-mu is NaN */
66-
p = (x - mu) ;
67-
if(!R_FINITE(p))
68-
return (x < mu) ? R_DT_0 : R_DT_1;
65+
if (!R_FINITE(x) && mu == x) return ML_NAN; /* x-mu is NaN */
66+
p = (x - mu);
67+
if (!R_FINITE(p))
68+
return (x < mu) ? R_DT_0 : R_DT_1;
6969
x = p;
7070

7171
::Rf_pnorm_both(x, &p, &cp, (lower_tail ? 0 : 1), log_p);
@@ -80,12 +80,12 @@ inline double pnorm_0(double x /*, double mu [=0.] , double sigma [=1.]*/ , int
8080
* For example, if x == mu and sigma == 0, we get the correct answer 1.
8181
*/
8282
#ifdef IEEE_754
83-
if(ISNAN(x) )
84-
return x + 1.0 ;
83+
if (ISNAN(x))
84+
return x + 1.0;
8585
#endif
86-
p = x ;
87-
if(!R_FINITE(p))
88-
return (x < 0.0 ) ? R_DT_0 : R_DT_1;
86+
p = x;
87+
if (!R_FINITE(p))
88+
return (x < 0.0) ? R_DT_0 : R_DT_1;
8989
x = p;
9090

9191
::Rf_pnorm_both(x, &p, &cp, (lower_tail ? 0 : 1), log_p);
@@ -94,17 +94,17 @@ inline double pnorm_0(double x /*, double mu [=0.] , double sigma [=1.]*/ , int
9494
}
9595

9696
inline double qnorm_1(double p, double mu /*, double sigma [=1.] */, int lower_tail, int log_p){
97-
return ::Rf_qnorm5(p, mu, 1.0, lower_tail, log_p ) ;
97+
return ::Rf_qnorm5(p, mu, 1.0, lower_tail, log_p);
9898
}
9999
inline double qnorm_0(double p /*, double mu [=0.], double sigma [=1.] */, int lower_tail, int log_p){
100-
return ::Rf_qnorm5(p, 0.0, 1.0, lower_tail, log_p ) ;
100+
return ::Rf_qnorm5(p, 0.0, 1.0, lower_tail, log_p);
101101
}
102102

103103
} // stats
104104
} // Rcpp
105105

106-
RCPP_DPQ_0(norm, Rcpp::stats::dnorm_0, Rcpp::stats::pnorm_0, Rcpp::stats::qnorm_0 )
107-
RCPP_DPQ_1(norm, Rcpp::stats::dnorm_1, Rcpp::stats::pnorm_1, Rcpp::stats::qnorm_1 )
108-
RCPP_DPQ_2(norm, ::Rf_dnorm4, ::Rf_pnorm5, ::Rf_qnorm5 )
106+
RCPP_DPQ_0(norm, Rcpp::stats::dnorm_0, Rcpp::stats::pnorm_0, Rcpp::stats::qnorm_0)
107+
RCPP_DPQ_1(norm, Rcpp::stats::dnorm_1, Rcpp::stats::pnorm_1, Rcpp::stats::qnorm_1)
108+
RCPP_DPQ_2(norm, ::Rf_dnorm4, ::Rf_pnorm5, ::Rf_qnorm5)
109109

110110
#endif

0 commit comments

Comments
 (0)