// Copyright (c) the JPEG XL Project Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.
// Ensure indices fit into PermutationT
EXPECT_LE(n, 1ULL << (sizeof(PermutationT) * 8));
std::iota(ws->permutation.begin(), ws->permutation.begin() + n, 0);
// For various random permutations: for (size_t rep = 0; rep < 3; ++rep) {
rng.Shuffle(ws->permutation.data(), n);
// Must decode to the same permutation
EXPECT_TRUE(ComputeLehmerCode(ws->permutation.data(), ws->temp.data(), n,
ws->lehmer.data()));
memset(ws->temp.data(), 0, padded_n * 4);
EXPECT_TRUE(DecodeLehmerCode(ws->lehmer.data(), ws->temp.data(), n,
ws->decoded.data()));
for (size_t i = 0; i < n; ++i) {
EXPECT_EQ(ws->permutation[i], ws->decoded[i]);
}
}
}
// Preallocates arrays and tests n = [begin, end). template <typename PermutationT> void RoundtripSizeRange(ThreadPool* pool, uint32_t begin, uint32_t end) {
ASSERT_NE(0u, begin); // n = 0 not allowed.
std::vector<WorkingSet<PermutationT>> working_sets;
constauto init = [&working_sets, end](const size_t num_threads) -> Status { for (size_t i = 0; i < num_threads; i++) {
working_sets.emplace_back(end - 1);
} returntrue;
}; constauto do_roundtrip = [&working_sets](const uint32_t n, const size_t thread) -> Status {
Roundtrip(n, &working_sets[thread]); returntrue;
};
ASSERT_TRUE(RunOnPool(pool, begin, end, init, do_roundtrip, "lehmer test"));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.