# HG changeset patch # User Rik # Date 1630511924 25200 # Node ID da3659538d163fda635acf603d6cbd836abeac53 # Parent b9ccf2213a1abefa68cbbf183d7ea0b0b07cf463 maint: use "m_" prefix for member variables in oct-norm.cc accumulator classes. oct-norm.cc: use "m_" prefix for member variables in accumulator classes. diff -r b9ccf2213a1a -r da3659538d16 liboctave/numeric/oct-norm.cc --- a/liboctave/numeric/oct-norm.cc Wed Sep 01 07:28:49 2021 -0700 +++ b/liboctave/numeric/oct-norm.cc Wed Sep 01 08:58:44 2021 -0700 @@ -74,80 +74,80 @@ template class norm_accumulator_p { - R p,scl,sum; + R m_p,m_scl,m_sum; public: norm_accumulator_p () { } // we need this one for Array - norm_accumulator_p (R pp) : p(pp), scl(0), sum(1) { } + norm_accumulator_p (R pp) : m_p(pp), m_scl(0), m_sum(1) { } template void accum (U val) { octave_quit (); R t = std::abs (val); - if (scl == t) // we need this to handle Infs properly - sum += 1; - else if (scl < t) + if (m_scl == t) // we need this to handle Infs properly + m_sum += 1; + else if (m_scl < t) { - sum *= std::pow (scl/t, p); - sum += 1; - scl = t; + m_sum *= std::pow (m_scl/t, m_p); + m_sum += 1; + m_scl = t; } else if (t != 0) - sum += std::pow (t/scl, p); + m_sum += std::pow (t/m_scl, m_p); } - operator R () { return scl * std::pow (sum, 1/p); } + operator R () { return m_scl * std::pow (m_sum, 1/m_p); } }; // norm accumulator for the minus p-pseudonorm template class norm_accumulator_mp { - R p,scl,sum; + R m_p,m_scl,m_sum; public: norm_accumulator_mp () { } // we need this one for Array - norm_accumulator_mp (R pp) : p(pp), scl(0), sum(1) { } + norm_accumulator_mp (R pp) : m_p(pp), m_scl(0), m_sum(1) { } template void accum (U val) { octave_quit (); R t = 1 / std::abs (val); - if (scl == t) - sum += 1; - else if (scl < t) + if (m_scl == t) + m_sum += 1; + else if (m_scl < t) { - sum *= std::pow (scl/t, p); - sum += 1; - scl = t; + m_sum *= std::pow (m_scl/t, m_p); + m_sum += 1; + m_scl = t; } else if (t != 0) - sum += std::pow (t/scl, p); + m_sum += std::pow (t/m_scl, m_p); } - operator R () { return scl * std::pow (sum, -1/p); } + operator R () { return m_scl * std::pow (m_sum, -1/m_p); } }; // norm accumulator for the 2-norm (euclidean) template class norm_accumulator_2 { - R scl,sum; + R m_scl,m_sum; static R pow2 (R x) { return x*x; } public: - norm_accumulator_2 () : scl(0), sum(1) { } + norm_accumulator_2 () : m_scl(0), m_sum(1) { } void accum (R val) { R t = std::abs (val); - if (scl == t) - sum += 1; - else if (scl < t) + if (m_scl == t) + m_sum += 1; + else if (m_scl < t) { - sum *= pow2 (scl/t); - sum += 1; - scl = t; + m_sum *= pow2 (m_scl/t); + m_sum += 1; + m_scl = t; } else if (t != 0) - sum += pow2 (t/scl); + m_sum += pow2 (t/m_scl); } void accum (std::complex val) @@ -156,22 +156,22 @@ accum (val.imag ()); } - operator R () { return scl * std::sqrt (sum); } + operator R () { return m_scl * std::sqrt (m_sum); } }; // norm accumulator for the 1-norm (city metric) template class norm_accumulator_1 { - R sum; + R m_sum; public: - norm_accumulator_1 () : sum (0) { } + norm_accumulator_1 () : m_sum (0) { } template void accum (U val) { - sum += std::abs (val); + m_sum += std::abs (val); } - operator R () { return sum; } + operator R () { return m_sum; } }; // norm accumulator for the inf-norm (max metric) @@ -328,8 +328,9 @@ DEFINE_DISPATCHER (column_norms, MSparse, MArray) DEFINE_DISPATCHER (row_norms, MSparse, MArray) - // The approximate subproblem in Higham's method. Find lambda and mu such that - // norm ([lambda, mu], p) == 1 and norm (y*lambda + col*mu, p) is maximized. + // The approximate subproblem in Higham's method. Find lambda and mu such + // that norm ([lambda, mu], p) == 1 and norm (y*lambda + col*mu, p) is + // maximized. // Real version. As in Higham's paper. template static void @@ -356,9 +357,9 @@ } } - // Complex version. Higham's paper does not deal with complex case, so we use - // a simple extension. First, guess the magnitudes as in real version, then - // try to rotate lambda to improve further. + // Complex version. Higham's paper does not deal with complex case, so we + // use a simple extension. First, guess the magnitudes as in real version, + // then try to rotate lambda to improve further. template static void higham_subp (const ColVectorT& y, const ColVectorT& col,