]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/accumulators/statistics/p_square_quantile.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / accumulators / statistics / p_square_quantile.hpp
index 636fea7f23515c632af9f7691848f6a19149cb23..d87c1b3dbe11e9e813be6e824cdea002194dbbe5 100644 (file)
@@ -22,6 +22,7 @@
 #include <boost/accumulators/statistics_fwd.hpp>
 #include <boost/accumulators/statistics/count.hpp>
 #include <boost/accumulators/statistics/parameters/quantile_probability.hpp>
+#include <boost/serialization/boost_array.hpp>
 
 namespace boost { namespace accumulators
 {
@@ -61,7 +62,7 @@ namespace impl
 
         template<typename Args>
         p_square_quantile_impl(Args const &args)
-          : p(is_same<Impl, for_median>::value ? 0.5 : args[quantile_probability | 0.5])
+          : p(is_same<Impl, for_median>::value ? float_type(0.5) : args[quantile_probability | float_type(0.5)])
           , heights()
           , actual_positions()
           , desired_positions()
@@ -69,20 +70,21 @@ namespace impl
         {
             for(std::size_t i = 0; i < 5; ++i)
             {
-                this->actual_positions[i] = i + 1.;
+                this->actual_positions[i] = i + float_type(1.);
             }
 
-            this->desired_positions[0] = 1.;
-            this->desired_positions[1] = 1. + 2. * this->p;
-            this->desired_positions[2] = 1. + 4. * this->p;
-            this->desired_positions[3] = 3. + 2. * this->p;
-            this->desired_positions[4] = 5.;
+            this->desired_positions[0] = float_type(1.);
+            this->desired_positions[1] = float_type(1.) + float_type(2.) * this->p;
+            this->desired_positions[2] = float_type(1.) + float_type(4.) * this->p;
+            this->desired_positions[3] = float_type(3.) + float_type(2.) * this->p;
+            this->desired_positions[4] = float_type(5.);
 
-            this->positions_increments[0] = 0.;
-            this->positions_increments[1] = this->p / 2.;
+
+            this->positions_increments[0] = float_type(0.);
+            this->positions_increments[1] = this->p / float_type(2.);
             this->positions_increments[2] = this->p;
-            this->positions_increments[3] = (1. + this->p) / 2.;
-            this->positions_increments[4] = 1.;
+            this->positions_increments[3] = (float_type(1.) + this->p) / float_type(2.);
+            this->positions_increments[4] = float_type(1.);
         }
 
         template<typename Args>
@@ -156,7 +158,7 @@ namespace impl
                     float_type hp = (this->heights[i + 1] - this->heights[i]) / dp;
                     float_type hm = (this->heights[i - 1] - this->heights[i]) / dm;
 
-                    if((d >= 1. && dp > 1.) || (d <= -1. && dm < -1.))
+                    if((d >= float_type(1.) && dp > float_type(1.)) || (d <= float_type(-1.) && dm < float_type(-1.)))
                     {
                         short sign_d = static_cast<short>(d / std::abs(d));
 
@@ -171,11 +173,11 @@ namespace impl
                         else
                         {
                             // use linear formula
-                            if(d > 0)
+                            if(d > float_type(0))
                             {
                                 this->heights[i] += hp;
                             }
-                            if(d < 0)
+                            if(d < float_type(0))
                             {
                                 this->heights[i] -= hm;
                             }
@@ -191,6 +193,18 @@ namespace impl
             return this->heights[2];
         }
 
+        // make this accumulator serializeable
+        // TODO: do we need to split to load/save and verify that P did not change?
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int file_version)
+        { 
+            ar & p;
+            ar & heights;
+            ar & actual_positions;
+            ar & desired_positions;
+            ar & positions_increments;
+        }
+
     private:
         float_type p;                    // the quantile probability p
         array_type heights;              // q_i