@@ -6382,16 +6382,12 @@ struct LinearFitVisitor {
6382
6382
const H &x_begin, const H &x_end,
6383
6383
const H &y_begin, const H &y_end) {
6384
6384
6385
- const size_type col_s = std::distance (x_begin, x_end);
6385
+ const size_type col_s =
6386
+ std::min (std::distance (x_begin, x_end),
6387
+ std::distance (y_begin, y_end));
6386
6388
const auto thread_level = (col_s < ThreadPool::MUL_THR_THHOLD)
6387
6389
? 0L : ThreadGranularity::get_thread_level ();
6388
6390
6389
- #ifdef HMDF_SANITY_EXCEPTIONS
6390
- if (col_s != size_type (std::distance (y_begin, y_end)))
6391
- throw DataFrameError (" LinearFitVisitor: two columns must be "
6392
- " of equal sizes" );
6393
- #endif // HMDF_SANITY_EXCEPTIONS
6394
-
6395
6391
value_type sum_x { 0 }; // Sum of all observed x
6396
6392
value_type sum_y { 0 }; // Sum of all observed y
6397
6393
value_type sum_x2 { 0 }; // Sum of all observed x squared
@@ -7543,30 +7539,32 @@ is_normal(const V &column, double epsl, bool check_for_standard) {
7543
7539
svisit.post ();
7544
7540
7545
7541
const value_type mean = static_cast <value_type>(svisit.get_mean ());
7546
- const value_type std = static_cast <value_type>(svisit.get_std ());
7547
- const value_type high_band_1 = static_cast <value_type>(mean + std );
7548
- const value_type low_band_1 = static_cast <value_type>(mean - std );
7542
+ const value_type stdev = static_cast <value_type>(svisit.get_std ());
7543
+ const value_type high_band_1 = static_cast <value_type>(mean + stdev );
7544
+ const value_type low_band_1 = static_cast <value_type>(mean - stdev );
7549
7545
double count_1 = 0.0 ;
7550
7546
const value_type high_band_2 =
7551
- static_cast <value_type>(mean + std * 2.0 );
7552
- const value_type low_band_2 = static_cast <value_type>(mean - std * 2.0 );
7547
+ static_cast <value_type>(mean + stdev * 2.0 );
7548
+ const value_type low_band_2 =
7549
+ static_cast <value_type>(mean - stdev * 2.0 );
7553
7550
double count_2 = 0.0 ;
7554
7551
const value_type high_band_3 =
7555
- static_cast <value_type>(mean + std * 3.0 );
7556
- const value_type low_band_3 = static_cast <value_type>(mean - std * 3.0 );
7552
+ static_cast <value_type>(mean + stdev * 3.0 );
7553
+ const value_type low_band_3 =
7554
+ static_cast <value_type>(mean - stdev * 3.0 );
7557
7555
double count_3 = 0.0 ;
7558
7556
7559
- for (auto citer : column) [[likely]] {
7560
- if (citer >= low_band_1 && citer < high_band_1) {
7557
+ for (const auto &val : column) [[likely]] {
7558
+ if (val >= low_band_1 && val < high_band_1) {
7561
7559
count_3 += 1 ;
7562
7560
count_2 += 1 ;
7563
7561
count_1 += 1 ;
7564
7562
}
7565
- else if (citer >= low_band_2 && citer < high_band_2) {
7563
+ else if (val >= low_band_2 && val < high_band_2) {
7566
7564
count_3 += 1 ;
7567
7565
count_2 += 1 ;
7568
7566
}
7569
- else if (citer >= low_band_3 && citer < high_band_3) {
7567
+ else if (val >= low_band_3 && val < high_band_3) {
7570
7568
count_3 += 1 ;
7571
7569
}
7572
7570
}
@@ -7578,7 +7576,7 @@ is_normal(const V &column, double epsl, bool check_for_standard) {
7578
7576
std::fabs ((count_3 / col_s) - 0.997 ) <= epsl) {
7579
7577
if (check_for_standard)
7580
7578
return (std::fabs (mean - 0 ) <= epsl &&
7581
- std::fabs (std - 1.0 ) <= epsl);
7579
+ std::fabs (stdev - 1.0 ) <= epsl);
7582
7580
return (true );
7583
7581
}
7584
7582
return (false );
@@ -7597,28 +7595,30 @@ is_lognormal(const V &column, double epsl) {
7597
7595
StatsVisitor<value_type, int > log_visit;
7598
7596
7599
7597
svisit.pre ();
7600
- for (auto citer : column) [[likely]] {
7601
- svisit (dummy_idx, static_cast <value_type>(std::log (citer )));
7602
- log_visit (dummy_idx, citer );
7598
+ for (auto val : column) [[likely]] {
7599
+ svisit (dummy_idx, static_cast <value_type>(std::log (val )));
7600
+ log_visit (dummy_idx, val );
7603
7601
}
7604
7602
svisit.post ();
7605
7603
7606
7604
const value_type mean = static_cast <value_type>(svisit.get_mean ());
7607
- const value_type std = static_cast <value_type>(svisit.get_std ());
7608
- const value_type high_band_1 = static_cast <value_type>(mean + std );
7609
- const value_type low_band_1 = static_cast <value_type>(mean - std );
7605
+ const value_type stdev = static_cast <value_type>(svisit.get_std ());
7606
+ const value_type high_band_1 = static_cast <value_type>(mean + stdev );
7607
+ const value_type low_band_1 = static_cast <value_type>(mean - stdev );
7610
7608
double count_1 = 0.0 ;
7611
7609
const value_type high_band_2 =
7612
- static_cast <value_type>(mean + std * 2.0 );
7613
- const value_type low_band_2 = static_cast <value_type>(mean - std * 2.0 );
7610
+ static_cast <value_type>(mean + stdev * 2.0 );
7611
+ const value_type low_band_2 =
7612
+ static_cast <value_type>(mean - stdev * 2.0 );
7614
7613
double count_2 = 0.0 ;
7615
7614
const value_type high_band_3 =
7616
- static_cast <value_type>(mean + std * 3.0 );
7617
- const value_type low_band_3 = static_cast <value_type>(mean - std * 3.0 );
7615
+ static_cast <value_type>(mean + stdev * 3.0 );
7616
+ const value_type low_band_3 =
7617
+ static_cast <value_type>(mean - stdev * 3.0 );
7618
7618
double count_3 = 0.0 ;
7619
7619
7620
- for (auto citer : column) [[likely]] {
7621
- const auto log_val = std::log (citer );
7620
+ for (const auto &val : column) [[likely]] {
7621
+ const auto log_val = std::log (val );
7622
7622
7623
7623
if (log_val >= low_band_1 && log_val < high_band_1) {
7624
7624
count_3 += 1 ;
0 commit comments