mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: noexcept size_bytes() method for lists
- for use when the is_contiguous check has already been done outside the loop. Naming as per std::span. STYLE: use data/cdata instead of begin ENH: replace random_shuffle with shuffle, fix OSX int64 ambiguity
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
||||
std::for_each(test6.begin(), test6.end(), [](label& x){ x *= 3; });
|
||||
|
||||
// Randomize the list
|
||||
std::random_shuffle(test6.begin(), test6.end());
|
||||
Foam::shuffle(test6);
|
||||
|
||||
Info<< "randomized input list: " << flatOutput(test6) << nl;
|
||||
|
||||
@ -160,7 +160,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// List reorder
|
||||
labelList oldToNew(identity(40));
|
||||
std::random_shuffle(oldToNew.begin(), oldToNew.end());
|
||||
Foam::shuffle(oldToNew);
|
||||
|
||||
// Force a few -1:
|
||||
oldToNew[4] = oldToNew[8] = -1;
|
||||
@ -192,9 +192,9 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
Info<<"packed input: " << flatOutput(packed) << nl;
|
||||
Info<< "packed input: " << packed << nl;
|
||||
inplaceReorder(oldToNew, packed);
|
||||
Info<<" reorder: " << flatOutput(packed) << nl << nl;
|
||||
Info<<" reorder: " << packed << nl << nl;
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,6 +34,7 @@ Description
|
||||
#include "vector.H"
|
||||
#include "IOstreams.H"
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -115,9 +116,8 @@ void testData(const VecSpace& vs)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<<"normalised: " << vector(1,2,3).normalise() << nl;
|
||||
Info<<"normalised: " << vector(VSMALL,VSMALL,VSMALL).normalise() << nl;
|
||||
Info<<"normalised: " <<
|
||||
vector(ROOTVSMALL,ROOTVSMALL,ROOTVSMALL).normalise() << nl;
|
||||
Info<<"normalised: " << vector::uniform(VSMALL).normalise() << nl;
|
||||
Info<<"normalised: " << vector::uniform(ROOTVSMALL).normalise() << nl;
|
||||
|
||||
{
|
||||
vector vec1(0.5, 0.5, 0.5);
|
||||
@ -134,7 +134,7 @@ int main(int argc, char *argv[])
|
||||
std::sort(vec2.begin(), vec2.end());
|
||||
Info<< "sorted: " << vec2 << nl;
|
||||
|
||||
std::random_shuffle(vec2.begin(), vec2.end());
|
||||
std::shuffle(vec2.begin(), vec2.end(), std::default_random_engine());
|
||||
Info<< "shuffled: " << vec2 << nl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user