3434#include "statsR.h"
3535#include "statsErr.h"
3636
37- static SEXP corcov (SEXP x , SEXP y , SEXP na_method , SEXP kendall , Rboolean cor );
37+ static SEXP corcov (SEXP x , SEXP y , SEXP na_method , SEXP kendall , bool cor );
3838
3939
4040SEXP cor (SEXP x , SEXP y , SEXP na_method , SEXP kendall )
4141{
42- return corcov (x , y , na_method , kendall , TRUE );
42+ return corcov (x , y , na_method , kendall , true );
4343}
4444SEXP cov (SEXP x , SEXP y , SEXP na_method , SEXP kendall )
4545{
46- return corcov (x , y , na_method , kendall , FALSE );
46+ return corcov (x , y , na_method , kendall , false );
4747}
4848
4949
@@ -112,7 +112,7 @@ SEXP cov(SEXP x, SEXP y, SEXP na_method, SEXP kendall)
112112 } \
113113 if (cor ) { \
114114 if (xsd == 0. || ysd == 0. ) { \
115- * sd_0 = TRUE ; \
115+ * sd_0 = true ; \
116116 sum = NA_REAL ; \
117117 } \
118118 else { \
@@ -135,8 +135,8 @@ SEXP cov(SEXP x, SEXP y, SEXP na_method, SEXP kendall)
135135
136136
137137static void cov_pairwise1 (int n , int ncx , double * x ,
138- double * ans , Rboolean * sd_0 , Rboolean cor ,
139- Rboolean kendall )
138+ double * ans , bool * sd_0 , bool cor ,
139+ bool kendall )
140140{
141141 for (int i = 0 ; i < ncx ; i ++ ) {
142142 double * xx = & x [i * n ];
@@ -151,8 +151,8 @@ static void cov_pairwise1(int n, int ncx, double *x,
151151}
152152
153153static void cov_pairwise2 (int n , int ncx , int ncy , double * x , double * y ,
154- double * ans , Rboolean * sd_0 , Rboolean cor ,
155- Rboolean kendall )
154+ double * ans , bool * sd_0 , bool cor ,
155+ bool kendall )
156156{
157157 for (int i = 0 ; i < ncx ; i ++ ) {
158158 double * xx = & x [i * n ];
@@ -242,8 +242,8 @@ static void cov_pairwise2(int n, int ncx, int ncy, double *x, double *y,
242242
243243static void
244244cov_complete1 (int n , int ncx , double * x , double * xm ,
245- int * ind , double * ans , Rboolean * sd_0 , Rboolean cor ,
246- Rboolean kendall )
245+ int * ind , double * ans , bool * sd_0 , bool cor ,
246+ bool kendall )
247247{
248248 COV_init (ncx );
249249
@@ -287,7 +287,7 @@ cov_complete1(int n, int ncx, double *x, double *xm,
287287 for (i = 0 ; i < ncx ; i ++ ) {
288288 for (j = 0 ; j < i ; j ++ ) {
289289 if (xm [i ] == 0 || xm [j ] == 0 ) {
290- * sd_0 = TRUE ;
290+ * sd_0 = true ;
291291 ANS (j ,i ) = ANS (i ,j ) = NA_REAL ;
292292 }
293293 else {
@@ -302,8 +302,8 @@ cov_complete1(int n, int ncx, double *x, double *xm,
302302
303303static void
304304cov_na_1 (int n , int ncx , double * x , double * xm ,
305- int * has_na , double * ans , Rboolean * sd_0 , Rboolean cor ,
306- Rboolean kendall )
305+ int * has_na , double * ans , bool * sd_0 , bool cor ,
306+ bool kendall )
307307{
308308
309309 COV_ini_na (ncx );
@@ -356,7 +356,7 @@ cov_na_1(int n, int ncx, double *x, double *xm,
356356 for (i = 0 ; i < ncx ; i ++ ) {
357357 if (!has_na [i ]) for (j = 0 ; j < i ; j ++ ) {
358358 if (xm [i ] == 0 || xm [j ] == 0 ) {
359- * sd_0 = TRUE ;
359+ * sd_0 = true ;
360360 ANS (j ,i ) = ANS (i ,j ) = NA_REAL ;
361361 }
362362 else {
@@ -372,7 +372,7 @@ cov_na_1(int n, int ncx, double *x, double *xm,
372372static void
373373cov_complete2 (int n , int ncx , int ncy , double * x , double * y ,
374374 double * xm , double * ym , int * ind ,
375- double * ans , Rboolean * sd_0 , Rboolean cor , Rboolean kendall )
375+ double * ans , bool * sd_0 , bool cor , bool kendall )
376376{
377377 COV_init (ncy );
378378
@@ -439,7 +439,7 @@ cov_complete2(int n, int ncx, int ncy, double *x, double *y,
439439 for (i = 0 ; i < ncx ; i ++ )
440440 for (j = 0 ; j < ncy ; j ++ )
441441 if (xm [i ] == 0. || ym [j ] == 0. ) {
442- * sd_0 = TRUE ;
442+ * sd_0 = true ;
443443 ANS (i ,j ) = NA_REAL ;
444444 }
445445 else {
@@ -454,7 +454,7 @@ cov_complete2(int n, int ncx, int ncy, double *x, double *y,
454454static void
455455cov_na_2 (int n , int ncx , int ncy , double * x , double * y ,
456456 double * xm , double * ym , int * has_na_x , int * has_na_y ,
457- double * ans , Rboolean * sd_0 , Rboolean cor , Rboolean kendall )
457+ double * ans , bool * sd_0 , bool cor , bool kendall )
458458{
459459 COV_ini_na (ncy );
460460
@@ -530,7 +530,7 @@ cov_na_2(int n, int ncx, int ncy, double *x, double *y,
530530 for (j = 0 ; j < ncy ; j ++ )
531531 if (!has_na_y [j ]) {
532532 if (xm [i ] == 0. || ym [j ] == 0. ) {
533- * sd_0 = TRUE ;
533+ * sd_0 = true ;
534534 ANS (i ,j ) = NA_REAL ;
535535 }
536536 else {
@@ -574,13 +574,13 @@ cov_na_2(int n, int ncx, int ncy, double *x, double *y,
574574 NA_LOOP \
575575 }
576576
577- static void complete1 (int n , int ncx , double * x , int * ind , Rboolean na_fail )
577+ static void complete1 (int n , int ncx , double * x , int * ind , bool na_fail )
578578{
579579 COMPLETE_1
580580}
581581
582582static void
583- complete2 (int n , int ncx , int ncy , double * x , double * y , int * ind , Rboolean na_fail )
583+ complete2 (int n , int ncx , int ncy , double * x , double * y , int * ind , bool na_fail )
584584{
585585 COMPLETE_1
586586
@@ -626,10 +626,10 @@ find_na_2(int n, int ncx, int ncy, double *x, double *y, int *has_na_x, int *has
626626 "all.obs", "complete.obs", "pairwise.complete", "everything", "na.or.complete"
627627 kendall = TRUE/FALSE)
628628*/
629- static SEXP corcov (SEXP x , SEXP y , SEXP na_method , SEXP skendall , Rboolean cor )
629+ static SEXP corcov (SEXP x , SEXP y , SEXP na_method , SEXP skendall , bool cor )
630630{
631631 SEXP ans , xm , ym , ind ;
632- Rboolean ansmat , kendall , pair , na_fail , everything , sd_0 , empty_err ;
632+ bool ansmat , kendall , pair , na_fail , everything , sd_0 , empty_err ;
633633 int i , method , n , ncx , ncy , nprotect = 2 ;
634634
635635#define DEFUNCT_VAR_FACTOR
@@ -675,7 +675,7 @@ static SEXP corcov(SEXP x, SEXP y, SEXP na_method, SEXP skendall, Rboolean cor)
675675 if (nrows (y ) != n )
676676 error (_ ("incompatible dimensions" ));
677677 ncy = ncols (y );
678- ansmat = TRUE ;
678+ ansmat = true ;
679679 }
680680 else {
681681 if (length (y ) != n )
@@ -687,28 +687,28 @@ static SEXP corcov(SEXP x, SEXP y, SEXP na_method, SEXP skendall, Rboolean cor)
687687 method = asInteger (na_method );
688688
689689 /* Arg.4: kendall */
690- kendall = asRboolean (skendall );
690+ kendall = asBool (skendall );
691691
692692 /* "default: complete" (easier for -Wall) */
693- na_fail = FALSE ; everything = FALSE; empty_err = TRUE ;
694- pair = FALSE ;
693+ na_fail = false ; everything = FALSE; empty_err = true ;
694+ pair = false ;
695695 switch (method ) {
696696 case 1 : /* use all : no NAs */
697- na_fail = TRUE ;
697+ na_fail = true ;
698698 break ;
699699 case 2 : /* complete */
700700 /* did na.omit in R */
701701 if (!LENGTH (x )) error (_ ("no complete element pairs" ));
702702 break ;
703703 case 3 : /* pairwise.complete */
704- pair = TRUE ;
704+ pair = true ;
705705 break ;
706706 case 4 : /* "everything": NAs are propagated */
707- everything = TRUE ;
708- empty_err = FALSE ;
707+ everything = true ;
708+ empty_err = false ;
709709 break ;
710710 case 5 : /* "na.or.complete": NAs are propagated */
711- empty_err = FALSE ;
711+ empty_err = false ;
712712 break ;
713713 default :
714714 error (_ ("invalid 'use' (computational method)" ));
@@ -718,7 +718,7 @@ static SEXP corcov(SEXP x, SEXP y, SEXP na_method, SEXP skendall, Rboolean cor)
718718
719719 if (ansmat ) PROTECT (ans = allocMatrix (REALSXP , ncx , ncy ));
720720 else PROTECT (ans = allocVector (REALSXP , ncx * ncy ));
721- sd_0 = FALSE ;
721+ sd_0 = false ;
722722 if (isNull (y )) {
723723 if (everything ) { /* NA's are propagated */
724724 PROTECT (xm = allocVector (REALSXP , ncx ));
@@ -735,9 +735,9 @@ static SEXP corcov(SEXP x, SEXP y, SEXP na_method, SEXP skendall, Rboolean cor)
735735 cov_complete1 (n , ncx , REAL (x ), REAL (xm ),
736736 INTEGER (ind ), REAL (ans ), & sd_0 , cor , kendall );
737737 if (empty_err ) {
738- Rboolean indany = FALSE ;
738+ bool indany = false ;
739739 for (i = 0 ; i < n ; i ++ ) {
740- if (INTEGER (ind )[i ] == 1 ) { indany = TRUE ; break ; }
740+ if (INTEGER (ind )[i ] == 1 ) { indany = true ; break ; }
741741 }
742742 if (!indany ) error (_ ("no complete element pairs" ));
743743 }
@@ -768,9 +768,9 @@ static SEXP corcov(SEXP x, SEXP y, SEXP na_method, SEXP skendall, Rboolean cor)
768768 cov_complete2 (n , ncx , ncy , REAL (x ), REAL (y ), REAL (xm ), REAL (ym ),
769769 INTEGER (ind ), REAL (ans ), & sd_0 , cor , kendall );
770770 if (empty_err ) {
771- Rboolean indany = FALSE ;
771+ bool indany = false ;
772772 for (i = 0 ; i < n ; i ++ ) {
773- if (INTEGER (ind )[i ] == 1 ) { indany = TRUE ; break ; }
773+ if (INTEGER (ind )[i ] == 1 ) { indany = true ; break ; }
774774 }
775775 if (!indany ) error (_ ("no complete element pairs" ));
776776 }
0 commit comments