Ticket #9898: 0001-random-fix-GCC-Wshadow-warnings.patch

File 0001-random-fix-GCC-Wshadow-warnings.patch, 6.0 KB (added by mstahl@…, 9 years ago)
  • include/boost/random/binomial_distribution.hpp

    From 18fe275e6e8ba312315ad11015edccf3eb0fbbf2 Mon Sep 17 00:00:00 2001
    From: Tor Lillqvist <tml@iki.fi>
    Date: Mon, 14 Apr 2014 12:30:31 +0200
    Subject: [PATCH 1/2] random: fix GCC -Wshadow warnings
    
    Signed-off-by: Michael Stahl <mstahl@redhat.com>
    ---
     include/boost/random/binomial_distribution.hpp | 36 +++++++++++++-------------
     include/boost/random/shuffle_order.hpp         |  4 +--
     include/boost/random/subtract_with_carry.hpp   | 20 +++++++-------
     3 files changed, 30 insertions(+), 30 deletions(-)
    
    diff --git a/include/boost/random/binomial_distribution.hpp b/include/boost/random/binomial_distribution.hpp
    index 8c880e8..8612eca 100644
    a b private:  
    272272        using std::sqrt;
    273273        using std::pow;
    274274
    275         RealType p = (0.5 < _p)? (1 - _p) : _p;
    276         IntType t = _t;
     275        RealType p_lcl = (0.5 < _p)? (1 - _p) : _p;
     276        IntType t_lcl = _t;
    277277       
    278         m = static_cast<IntType>((t+1)*p);
     278        m = static_cast<IntType>((t_lcl+1)*p_lcl);
    279279
    280280        if(use_inversion()) {
    281             q_n = pow((1 - p), static_cast<RealType>(t));
     281            q_n = pow((1 - p_lcl), static_cast<RealType>(t_lcl));
    282282        } else {
    283             btrd.r = p/(1-p);
    284             btrd.nr = (t+1)*btrd.r;
    285             btrd.npq = t*p*(1-p);
     283            btrd.r = p_lcl/(1-p_lcl);
     284            btrd.nr = (t_lcl+1)*btrd.r;
     285            btrd.npq = t_lcl*p_lcl*(1-p_lcl);
    286286            RealType sqrt_npq = sqrt(btrd.npq);
    287287            btrd.b = 1.15 + 2.53 * sqrt_npq;
    288             btrd.a = -0.0873 + 0.0248*btrd.b + 0.01*p;
    289             btrd.c = t*p + 0.5;
     288            btrd.a = -0.0873 + 0.0248*btrd.b + 0.01*p_lcl;
     289            btrd.c = t_lcl*p_lcl + 0.5;
    290290            btrd.alpha = (2.83 + 5.1/btrd.b) * sqrt_npq;
    291291            btrd.v_r = 0.92 - 4.2/btrd.b;
    292292            btrd.u_rv_r = 0.86*btrd.v_r;
    private:  
    304304            RealType u;
    305305            RealType v = uniform_01<RealType>()(urng);
    306306            if(v <= btrd.u_rv_r) {
    307                 RealType u = v/btrd.v_r - 0.43;
     307                RealType u_lcl = v/btrd.v_r - 0.43;
    308308                return static_cast<IntType>(floor(
    309                     (2*btrd.a/(0.5 - abs(u)) + btrd.b)*u + btrd.c));
     309                    (2*btrd.a/(0.5 - abs(u_lcl)) + btrd.b)*u_lcl + btrd.c));
    310310            }
    311311
    312312            if(v >= btrd.v_r) {
    private:  
    344344                v = log(v);
    345345                RealType rho =
    346346                    (km/btrd.npq)*(((km/3. + 0.625)*km + 1./6)/btrd.npq + 0.5);
    347                 RealType t = -km*km/(2*btrd.npq);
    348                 if(v < t - rho) return k;
    349                 if(v > t + rho) continue;
     347                RealType t_lcl = -km*km/(2*btrd.npq);
     348                if(v < t_lcl - rho) return k;
     349                if(v > t_lcl + rho) continue;
    350350
    351351                IntType nm = _t - m + 1;
    352352                RealType h = (m + 0.5)*log((m + 1)/(btrd.r*nm))
    private:  
    367367    }
    368368
    369369    template<class URNG>
    370     IntType invert(IntType t, RealType p, URNG& urng) const
     370    IntType invert(IntType t_arg, RealType p_arg, URNG& urng) const
    371371    {
    372         RealType q = 1 - p;
    373         RealType s = p / q;
    374         RealType a = (t + 1) * s;
     372        RealType q = 1 - p_arg;
     373        RealType s = p_arg / q;
     374        RealType a = (t_arg + 1) * s;
    375375        RealType r = q_n;
    376376        RealType u = uniform_01<RealType>()(urng);
    377377        IntType x = 0;
  • include/boost/random/shuffle_order.hpp

    diff --git a/include/boost/random/shuffle_order.hpp b/include/boost/random/shuffle_order.hpp
    index 646c09b..e775dd0 100644
    a b public:  
    200200    }
    201201
    202202    /** Returns true if the two generators will produce identical sequences. */
    203     BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(shuffle_order_engine, x, y)
    204     { return x._rng == y._rng && x.y == y.y && std::equal(x.v, x.v+k, y.v); }
     203    BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(shuffle_order_engine, x, y_arg)
     204    { return x._rng == y_arg._rng && x.y == y_arg.y && std::equal(x.v, x.v+k, y_arg.v); }
    205205    /** Returns true if the two generators will produce different sequences. */
    206206    BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(shuffle_order_engine)
    207207
  • include/boost/random/subtract_with_carry.hpp

    diff --git a/include/boost/random/subtract_with_carry.hpp b/include/boost/random/subtract_with_carry.hpp
    index dc430e6..927ee72 100644
    a b private:  
    268268
    269269    friend struct detail::subtract_with_carry_discard;
    270270
    271     IntType do_update(std::size_t current, std::size_t short_index, IntType carry)
     271    IntType do_update(std::size_t current, std::size_t short_index, IntType carry_arg)
    272272    {
    273273        IntType delta;
    274         IntType temp = x[current] + carry;
     274        IntType temp = x[current] + carry_arg;
    275275        if (x[short_index] >= temp) {
    276276            // x(n) >= 0
    277277            delta =  x[short_index] - temp;
    278             carry = 0;
     278            carry_arg = 0;
    279279        } else {
    280280            // x(n) < 0
    281281            delta = modulus - temp + x[short_index];
    282             carry = 1;
     282            carry_arg = 1;
    283283        }
    284284        x[current] = delta;
    285         return carry;
     285        return carry_arg;
    286286    }
    287287    /// \endcond
    288288
    private:  
    498498
    499499    friend struct detail::subtract_with_carry_discard;
    500500
    501     RealType do_update(std::size_t current, std::size_t short_index, RealType carry)
     501    RealType do_update(std::size_t current, std::size_t short_index, RealType carry_arg)
    502502    {
    503         RealType delta = x[short_index] - x[current] - carry;
     503        RealType delta = x[short_index] - x[current] - carry_arg;
    504504        if(delta < 0) {
    505505            delta += RealType(1);
    506             carry = RealType(1)/_modulus;
     506            carry_arg = RealType(1)/_modulus;
    507507        } else {
    508             carry = 0;
     508            carry_arg = 0;
    509509        }
    510510        x[current] = delta;
    511         return carry;
     511        return carry_arg;
    512512    }
    513513    /// \endcond
    514514    std::size_t k;