https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Functions
Hashing.C File Reference

Go to the source code of this file.

Functions

 TEST (FunctionalExpansionsTest, hashPoint)
 
 TEST (FunctionalExpansionsTest, hashPointAndTime)
 
 TEST (FunctionalExpansionsTest, hashIntVector)
 
 TEST (FunctionalExpansionsTest, hashRealVector)
 
 TEST (FunctionalExpansionsTest, hashVararg)
 

Function Documentation

◆ TEST() [1/5]

TEST ( FunctionalExpansionsTest  ,
hashIntVector   
)

Definition at line 58 of file Hashing.C.

59{
60 const std::vector<int> vector = {{351, 456, 49, 140, 491, -482, 86, 314, -442, 154,
61 430, 231, 47, -261, -64, -126, -187, 12, 61, -171,
62 -145, 76, -470, -100, 367, 1, 485, 458, 88, 112,
63 -212, 357, -403, 467, 127, 138, 388, -244, -479, -239,
64 -354, 475, -453, -36, -365, -248, -95, 93, -286, 436}};
65 const std::vector<int> vector_mirror(vector.begin(), vector.end());
66 const std::vector<int> vector_chopped(vector.begin(), --vector.end());
67 std::vector<int> vector_twiddle(vector.begin(), vector.end());
68 ++vector_twiddle[0];
69
71 const hashing::HashValue result_mirror = hashing::hashLargeContainer(vector_mirror);
72 const hashing::HashValue result_chopped = hashing::hashLargeContainer(vector_chopped);
73 const hashing::HashValue result_twiddle = hashing::hashLargeContainer(vector_twiddle);
74
75 EXPECT_EQ(result, result_mirror);
76 EXPECT_NE(result, result_chopped);
77 EXPECT_NE(result, result_twiddle);
78}
std::size_t HashValue
Definition Hashing.h:22
HashValue hashLargeContainer(Container const &container)
Hash function for sampling 10 points from a large container and hashing see: https://stackoverflow....
Definition Hashing.h:52

◆ TEST() [2/5]

TEST ( FunctionalExpansionsTest  ,
hashPoint   
)

Definition at line 14 of file Hashing.C.

15{
16 const Point location(0.9780619323, 0.2136556650, 0.3509044429);
17 const Point location_mirror(location);
18 Point location_twiddle_limit(location);
19 Point location_twiddle_nochange(location);
20
21 location_twiddle_limit(0) += 6e-17;
22 location_twiddle_nochange(0) += 5e-17;
23
24 const hashing::HashValue result = hashing::hashCombine(location);
25 const hashing::HashValue result_mirror = hashing::hashCombine(location_mirror);
26 const hashing::HashValue result_twiddle_limit = hashing::hashCombine(location_twiddle_limit);
27 const hashing::HashValue result_twiddle_nochange =
28 hashing::hashCombine(location_twiddle_nochange);
29
30 EXPECT_EQ(result, result_mirror);
31 EXPECT_NE(result, result_twiddle_limit);
32 EXPECT_EQ(result, result_twiddle_nochange);
33}
void hashCombine(HashValue &)
Final iteration of the variadic template with no additional arguments.
Definition Hashing.h:28

◆ TEST() [3/5]

TEST ( FunctionalExpansionsTest  ,
hashPointAndTime   
)

Definition at line 35 of file Hashing.C.

36{
37 const Real time = 0.5049258208;
38 const Point location(0.8392988091, 0.8482835642, 0.2509438471);
39 const Point location_mirror(location);
40 Point location_twiddle_limit(location);
41 Point location_twiddle_nochange(location);
42
43 location_twiddle_limit(0) += 6e-17;
44 location_twiddle_nochange(0) += 5e-17;
45
46 const hashing::HashValue result = hashing::hashCombine(time, location);
47 const hashing::HashValue result_mirror = hashing::hashCombine(time, location_mirror);
48 const hashing::HashValue result_twiddle_limit =
49 hashing::hashCombine(time, location_twiddle_limit);
50 const hashing::HashValue result_twiddle_nochange =
51 hashing::hashCombine(time, location_twiddle_nochange);
52
53 EXPECT_EQ(result, result_mirror);
54 EXPECT_NE(result, result_twiddle_limit);
55 EXPECT_EQ(result, result_twiddle_nochange);
56}
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ TEST() [4/5]

TEST ( FunctionalExpansionsTest  ,
hashRealVector   
)

Definition at line 80 of file Hashing.C.

81{
82 const std::vector<Real> vector = {
83 {0.7436426667, 0.6962231856, 0.7257906803, 0.8084661009, 0.2137680124, 0.1470705959,
84 0.3657163957, 0.8818058481, 0.5513600342, 0.1984376524, 0.4276321100, 0.4177158632,
85 0.5599816732, 0.5976773302, 0.0534853375, 0.7162077056, 0.9344288478, 0.4947189992,
86 0.6393245755, 0.6877651005, 0.9567775877, 0.8757637166, 0.3850183877, 0.6800440879,
87 0.5090953855, 0.7779340857, 0.2310272569, 0.7807447395, 0.3012011716, 0.2879436719,
88 0.9785884888, 0.1201041026, 0.6422951422, 0.8657404100, 0.2686119524, 0.4199450789,
89 0.2437974613, 0.3544349330, 0.5725840559, 0.2903856081, 0.0055479019, 0.6819050123,
90 0.5512080507, 0.7301519914, 0.0077125671, 0.5284511770, 0.6894292950, 0.5014027958,
91 0.9773264137, 0.8477810277}};
92 const std::vector<Real> vector_mirror(vector.begin(), vector.end());
93 const std::vector<Real> vector_chopped(vector.begin(), --vector.end());
94 std::vector<Real> vector_twiddle_limit(vector.begin(), vector.end());
95 std::vector<Real> vector_twiddle_nochange(vector.begin(), vector.end());
96
97 vector_twiddle_limit[0] += 6e-17;
98 vector_twiddle_nochange[0] += 5e-17;
99
100 const hashing::HashValue result = hashing::hashLargeContainer(vector);
101 const hashing::HashValue result_mirror = hashing::hashLargeContainer(vector_mirror);
102 const hashing::HashValue result_chopped = hashing::hashLargeContainer(vector_chopped);
103 const hashing::HashValue result_twiddle_limit = hashing::hashLargeContainer(vector_twiddle_limit);
104 const hashing::HashValue result_twiddle_nochange =
105 hashing::hashLargeContainer(vector_twiddle_nochange);
106
107 EXPECT_EQ(result, result_mirror);
108 EXPECT_NE(result, result_chopped);
109 EXPECT_NE(result, result_twiddle_limit);
110 EXPECT_EQ(result, result_twiddle_nochange);
111}

◆ TEST() [5/5]

TEST ( FunctionalExpansionsTest  ,
hashVararg   
)

Definition at line 113 of file Hashing.C.

114{
115 hashing::HashValue original = 42;
116 hashing::HashValue additional_small, additional_regular, additional_large, original_mirror;
117
118 hashing::hashCombine(original,
119 0.9873791320,
120 0.1953364838,
121 0.8116485930,
122 0.1863965161,
123 0.5928596550,
124 0.2295234343,
125 0.6904344651,
126 0.0045536257,
127 0.1940171658,
128 0.4950894997,
129 0.8079496584,
130 0.8060619760,
131 0.7486861178,
132 0.5493002792,
133 0.1596405782,
134 0.4023849890,
135 0.2782852666,
136 0.6461232825,
137 0.1064983494,
138 0.8130189389,
139 0.5726072736,
140 0.3327263263,
141 0.1472734104,
142 0.0234982033,
143 0.6812964288,
144 0.3276164827,
145 0.6911670346,
146 0.8299179444,
147 0.6484517577,
148 0.7986116002,
149 0.8813936466,
150 0.0049727250,
151 0.2010708901,
152 0.4933756641,
153 0.8354504016,
154 0.9452099799,
155 0.4643204087,
156 0.7382737011,
157 0.8045729776,
158 0.7870302766,
159 0.3384656050,
160 0.3401508297,
161 0.1595941894,
162 0.0673033342,
163 0.7483309385,
164 0.8940644866,
165 0.7948297883,
166 0.1890952442,
167 0.6151646001,
168 0.1672976625);
169
170 additional_small = additional_regular = additional_large = original_mirror = original;
171 hashing::hashCombine(additional_small, 3.9e-120);
172 hashing::hashCombine(additional_regular, 0.3971072909);
173 hashing::hashCombine(additional_large, 3.9e120);
174
175 EXPECT_EQ(original, original_mirror);
176 EXPECT_NE(original, additional_small);
177 EXPECT_NE(original, additional_regular);
178 EXPECT_NE(original, additional_large);
179}