Skip to content

Commit 6312b70

Browse files
jacobsacopybara-github
authored andcommitted
absl/random: run clang-format.
In order to avoid unrelated diffs in future changes that touch this code. PiperOrigin-RevId: 694625990 Change-Id: I51ac54438a977f38c54c7638701d9ff3a259a58b
1 parent dee1b6c commit 6312b70

22 files changed

+46
-53
lines changed

absl/random/benchmarks.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ void BM_Thread(benchmark::State& state) {
359359

360360
// ABSL Recommended interfaces.
361361
BM_BASIC(absl::InsecureBitGen); // === pcg64_2018_engine
362-
BM_BASIC(absl::BitGen); // === randen_engine<uint64_t>.
362+
BM_BASIC(absl::BitGen); // === randen_engine<uint64_t>.
363363
BM_THREAD(absl::BitGen);
364364
BM_EXTENDED(absl::BitGen);
365365

absl/random/distributions_test.cc

+5-6
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,16 @@ void CheckArgsInferType() {
9797

9898
template <typename A, typename B, typename ExplicitRet>
9999
auto ExplicitUniformReturnT(int) -> decltype(absl::Uniform<ExplicitRet>(
100-
std::declval<absl::InsecureBitGen&>(),
101-
std::declval<A>(), std::declval<B>()));
100+
std::declval<absl::InsecureBitGen&>(), std::declval<A>(),
101+
std::declval<B>()));
102102

103103
template <typename, typename, typename ExplicitRet>
104104
Invalid ExplicitUniformReturnT(...);
105105

106106
template <typename TagType, typename A, typename B, typename ExplicitRet>
107-
auto ExplicitTaggedUniformReturnT(int)
108-
-> decltype(absl::Uniform<ExplicitRet>(
109-
std::declval<TagType>(), std::declval<absl::InsecureBitGen&>(),
110-
std::declval<A>(), std::declval<B>()));
107+
auto ExplicitTaggedUniformReturnT(int) -> decltype(absl::Uniform<ExplicitRet>(
108+
std::declval<TagType>(), std::declval<absl::InsecureBitGen&>(),
109+
std::declval<A>(), std::declval<B>()));
111110

112111
template <typename, typename, typename, typename ExplicitRet>
113112
Invalid ExplicitTaggedUniformReturnT(...);

absl/random/examples_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,3 @@ TEST(Examples, CreateingCorrelatedVariateSequences) {
9696
EXPECT_EQ(absl::Uniform<uint32_t>(gen_1), absl::Uniform<uint32_t>(gen_2));
9797
}
9898
}
99-

absl/random/gaussian_distribution.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ABSL_DLL gaussian_distribution_base {
5757
bool neg);
5858

5959
// Constants used for the gaussian distribution.
60-
static constexpr double kR = 3.442619855899; // Start of the tail.
60+
static constexpr double kR = 3.442619855899; // Start of the tail.
6161
static constexpr double kRInv = 0.29047645161474317; // ~= (1.0 / kR) .
6262
static constexpr double kV = 9.91256303526217e-3;
6363
static constexpr uint64_t kMask = 0x07f;

absl/random/generators_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ void TestBernoulli(URBG* gen) {
117117
absl::Bernoulli(*gen, 0.5);
118118
}
119119

120-
121120
template <typename URBG>
122121
void TestZipf(URBG* gen) {
123122
absl::Zipf<int>(*gen, 100);

absl/random/internal/chi_square.cc

+3-6
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ namespace {
2525

2626
#if defined(__EMSCRIPTEN__)
2727
// Workaround __EMSCRIPTEN__ error: llvm_fma_f64 not found.
28-
inline double fma(double x, double y, double z) {
29-
return (x * y) + z;
30-
}
28+
inline double fma(double x, double y, double z) { return (x * y) + z; }
3129
#endif
3230

3331
// Use Horner's method to evaluate a polynomial.
@@ -105,9 +103,8 @@ double normal_survival(double z) {
105103
// p-value, usually using bisection. Also known by the name CRITCHI.
106104
double ChiSquareValue(int dof, double p) {
107105
static constexpr double kChiEpsilon =
108-
0.000001; // Accuracy of the approximation.
109-
static constexpr double kChiMax =
110-
99999.0; // Maximum chi-squared value.
106+
0.000001; // Accuracy of the approximation.
107+
static constexpr double kChiMax = 99999.0; // Maximum chi-squared value.
111108

112109
const double p_value = 1.0 - p;
113110
if (dof < 1 || p_value > 1.0) {

absl/random/internal/chi_square_test.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ TEST(ChiSquareTest, TableData) {
291291
/*97*/ {115.223, 120.990, 126.141, 132.309, 145.789},
292292
/*98*/ {116.315, 122.108, 127.282, 133.476, 147.010},
293293
/*99*/ {117.407, 123.225, 128.422, 134.642, 148.230},
294-
/*100*/ {118.498, 124.342, 129.561, 135.807, 149.449}
295-
/**/};
294+
/*100*/ {118.498, 124.342, 129.561, 135.807, 149.449} /**/};
296295

297296
// 0.90 0.95 0.975 0.99 0.999
298297
for (int i = 0; i < ABSL_ARRAYSIZE(data); i++) {

absl/random/internal/distribution_caller.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#ifndef ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_
1818
#define ABSL_RANDOM_INTERNAL_DISTRIBUTION_CALLER_H_
1919

20-
#include <utility>
2120
#include <type_traits>
21+
#include <utility>
2222

2323
#include "absl/base/config.h"
2424
#include "absl/base/internal/fast_type_id.h"

absl/random/internal/explicit_seed_seq_test.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ using ::absl::random_internal::ExplicitSeedSeq;
2929
template <typename Sseq>
3030
bool ConformsToInterface() {
3131
// Check that the SeedSequence can be default-constructed.
32-
{ Sseq default_constructed_seq; }
32+
{
33+
Sseq default_constructed_seq;
34+
}
3335
// Check that the SeedSequence can be constructed with two iterators.
3436
{
3537
uint32_t init_array[] = {1, 3, 5, 7, 9};
3638
Sseq iterator_constructed_seq(init_array, &init_array[5]);
3739
}
3840
// Check that the SeedSequence can be std::initializer_list-constructed.
39-
{ Sseq list_constructed_seq = {1, 3, 5, 7, 9, 11, 13}; }
41+
{
42+
Sseq list_constructed_seq = {1, 3, 5, 7, 9, 11, 13};
43+
}
4044
// Check that param() and size() return state provided to constructor.
4145
{
4246
uint32_t init_array[] = {1, 2, 3, 4, 5};

absl/random/internal/gaussian_distribution_gentables.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
//
1717
// $ blaze run :gaussian_distribution_gentables > gaussian_distribution.cc
1818
//
19-
#include "absl/random/gaussian_distribution.h"
20-
2119
#include <cmath>
2220
#include <cstddef>
2321
#include <iostream>
2422
#include <limits>
2523
#include <string>
2624

2725
#include "absl/base/macros.h"
26+
#include "absl/random/gaussian_distribution.h"
2827

2928
namespace absl {
3029
ABSL_NAMESPACE_BEGIN

absl/random/internal/randen_benchmarks.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
//
15-
#include "absl/random/internal/randen.h"
16-
1715
#include <cstdint>
1816
#include <cstdio>
1917
#include <cstring>
2018

2119
#include "absl/base/internal/raw_logging.h"
2220
#include "absl/random/internal/nanobenchmark.h"
2321
#include "absl/random/internal/platform.h"
22+
#include "absl/random/internal/randen.h"
2423
#include "absl/random/internal/randen_engine.h"
2524
#include "absl/random/internal/randen_hwaes.h"
2625
#include "absl/random/internal/randen_slow.h"

absl/random/internal/salted_seed_seq_test.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ namespace {
3333
template <typename Sseq>
3434
void ConformsToInterface() {
3535
// Check that the SeedSequence can be default-constructed.
36-
{ Sseq default_constructed_seq; }
36+
{
37+
Sseq default_constructed_seq;
38+
}
3739
// Check that the SeedSequence can be constructed with two iterators.
3840
{
3941
uint32_t init_array[] = {1, 3, 5, 7, 9};
4042
Sseq iterator_constructed_seq(std::begin(init_array), std::end(init_array));
4143
}
4244
// Check that the SeedSequence can be std::initializer_list-constructed.
43-
{ Sseq list_constructed_seq = {1, 3, 5, 7, 9, 11, 13}; }
45+
{
46+
Sseq list_constructed_seq = {1, 3, 5, 7, 9, 11, 13};
47+
}
4448
// Check that param() and size() return state provided to constructor.
4549
{
4650
uint32_t init_array[] = {1, 2, 3, 4, 5};

absl/random/internal/traits_test.cc

+5-8
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,11 @@ void CheckWideningConvertsTo() {
104104
TEST(TraitsTest, IsWideningConvertibleTest) {
105105
constexpr bool kInvalid = false;
106106

107-
CheckWideningConvertsToSelf<
108-
uint8_t, uint16_t, uint32_t, uint64_t,
109-
int8_t, int16_t, int32_t, int64_t,
110-
float, double>();
111-
CheckNotWideningConvertibleWithSigned<
112-
uint8_t, uint16_t, uint32_t, uint64_t>();
113-
CheckWideningConvertsToLargerTypes<
114-
uint8_t, uint16_t, uint32_t, uint64_t>();
107+
CheckWideningConvertsToSelf<uint8_t, uint16_t, uint32_t, uint64_t, int8_t,
108+
int16_t, int32_t, int64_t, float, double>();
109+
CheckNotWideningConvertibleWithSigned<uint8_t, uint16_t, uint32_t,
110+
uint64_t>();
111+
CheckWideningConvertsToLargerTypes<uint8_t, uint16_t, uint32_t, uint64_t>();
115112

116113
CheckWideningConvertsTo<float, double>();
117114
CheckWideningConvertsTo<uint16_t, float>();

absl/random/internal/uniform_helper.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ is_uniform_range_valid(FloatType a, FloatType b) {
201201
}
202202

203203
template <typename IntType>
204-
absl::enable_if_t<IsIntegral<IntType>::value, bool>
205-
is_uniform_range_valid(IntType a, IntType b) {
204+
absl::enable_if_t<IsIntegral<IntType>::value, bool> is_uniform_range_valid(
205+
IntType a, IntType b) {
206206
return a <= b;
207207
}
208208

absl/random/internal/wide_multiply.h

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ inline U256 MultiplyU128ToU256(uint128 a, uint128 b) {
7575
c00 + (c64a << 64) + (c64b << 64)};
7676
}
7777

78-
7978
template <>
8079
struct wide_multiply<uint128> {
8180
using input_type = uint128;

absl/random/log_uniform_int_distribution_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ double LogUniformIntChiSquaredTest::ChiSquaredTestImpl() {
148148
const auto bucket_index = [base_log, is_2, &param](int32_t x) {
149149
uint64_t y = static_cast<uint64_t>(x) - param.min();
150150
return (y == 0) ? 0
151-
: is_2 ? static_cast<int>(1 + std::log2(y))
152-
: static_cast<int>(1 + std::log(y) * base_log);
151+
: is_2 ? static_cast<int>(1 + std::log2(y))
152+
: static_cast<int>(1 + std::log(y) * base_log);
153153
};
154154
const int max_bucket = bucket_index(param.max()); // inclusive
155155
const size_t trials = 15 + (max_bucket + 1) * 10;

absl/random/poisson_distribution_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ TYPED_TEST(PoissonDistributionInterfaceTest, SerializeTest) {
106106
0.0), // denorm_max
107107
};
108108

109-
110109
constexpr int kCount = 1000;
111110
absl::InsecureBitGen gen;
112111
for (const double m : kParams) {

absl/random/seed_sequences.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ using SeedSeq = random_internal::SaltedSeedSeq<std::seed_seq>;
8080
//
8181
template <typename URBG>
8282
SeedSeq CreateSeedSeqFrom(URBG* urbg) {
83-
SeedSeq::result_type
84-
seed_material[random_internal::kEntropyBlocksNeeded];
83+
SeedSeq::result_type seed_material[random_internal::kEntropyBlocksNeeded];
8584

8685
if (!random_internal::ReadSeedMaterialFromURBG(
8786
urbg, absl::MakeSpan(seed_material))) {

absl/random/uniform_int_distribution_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ TYPED_TEST(UniformIntDistributionTest, ParamSerializeTest) {
114114
TYPED_TEST(UniformIntDistributionTest, ViolatesPreconditionsDeathTest) {
115115
#if GTEST_HAS_DEATH_TEST
116116
// Hi < Lo
117-
EXPECT_DEBUG_DEATH({ absl::uniform_int_distribution<TypeParam> dist(10, 1); },
118-
"");
117+
EXPECT_DEBUG_DEATH(
118+
{ absl::uniform_int_distribution<TypeParam> dist(10, 1); }, "");
119119
#endif // GTEST_HAS_DEATH_TEST
120120
#if defined(NDEBUG)
121121
// opt-mode, for invalid parameters, will generate a garbage value,

absl/random/uniform_real_distribution_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ TYPED_TEST(UniformRealDistributionTest, ParamSerializeTest) {
190190

191191
#ifdef _MSC_VER
192192
#pragma warning(push)
193-
#pragma warning(disable:4756) // Constant arithmetic overflow.
193+
#pragma warning(disable : 4756) // Constant arithmetic overflow.
194194
#endif
195195
TYPED_TEST(UniformRealDistributionTest, ViolatesPreconditionsDeathTest) {
196196
using DistributionType = absl::uniform_real_distribution<TypeParam>;

absl/random/zipf_distribution.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ zipf_distribution<IntType>::operator()(
221221
const double v = uniform_double(g);
222222
const double u = p.hxm_ + v * p.hx0_minus_hxm_;
223223
const double x = p.hinv(u);
224-
k = rint(x); // std::floor(x + 0.5);
224+
k = rint(x); // std::floor(x + 0.5);
225225
if (k > static_cast<double>(p.k())) continue; // reject k > max_k
226226
if (k - x <= p.s_) break;
227227
const double h = p.h(k + 0.5);

absl/random/zipf_distribution_test.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ class ZipfModel {
176176
const double x = v_ + i;
177177

178178
// H(n, q-1)
179-
const double hnqm1 =
180-
(q_ == 2.0) ? (1.0 / x)
181-
: (q_ == 3.0) ? (1.0 / (x * x)) : std::pow(x, -qm1);
179+
const double hnqm1 = (q_ == 2.0) ? (1.0 / x)
180+
: (q_ == 3.0) ? (1.0 / (x * x))
181+
: std::pow(x, -qm1);
182182
sum_hnq_m1 += hnqm1;
183183

184184
// H(n, q)
185-
const double hnq =
186-
(q_ == 2.0) ? (1.0 / (x * x))
187-
: (q_ == 3.0) ? (1.0 / (x * x * x)) : std::pow(x, -q_);
185+
const double hnq = (q_ == 2.0) ? (1.0 / (x * x))
186+
: (q_ == 3.0) ? (1.0 / (x * x * x))
187+
: std::pow(x, -q_);
188188
sum_hnq_ += hnq;
189189
hnq_.push_back(hnq);
190190
if (i > 1000 && hnq <= 1e-10) {

0 commit comments

Comments
 (0)