HILA
Loading...
Searching...
No Matches
hila_toy_codes/src/minmax.cpp
1#include "hila.h"
2
3#include <random>
4
5static_assert(NDIM == 3, "NDIM must be 3 here");
6
7
9
10int main(int argc, char *argv[]) {
11
12 // initialize system
13 hila::initialize(argc, argv);
14
15 // set up 32^3 lattice
16
17 lattice.setup({100, 100, 100});
18
19 // Random numbers are used here - use time to seed
21
22 // lattice field
23 Field<double> g = 2.0;
24
25 g[{1, 1, 1}] = 0.9;
26 g[{4, 0, 0}] = 1.0;
27 g[{99,99, 99}] = 5;
28 g[{24,0, 2}] = 2.3;
29 //g.set_element(4,{2,2,1});
30
31 double val1, val2, val3, val4, val5, val6;
32 CoordinateVector loc1, loc2, loc3, loc4, loc5, loc6;
33 for (auto i = 0; i < 1; i++)
34 {
35 val1 = g.min(ODD, loc1);
36 val2 = g.min(EVEN,loc2);
37 val3 = g.max(ODD, loc3);
38 val4 = g.max(EVEN,loc4);
39 val5 = g.min(ALL, loc5);
40 val6 = g.max(ALL, loc6);
41 }
42
43 // val = g.max(loc);
44 hila::out0 << "Min value of ODD sites " << val1 << " at location: " << loc1 << '\n';
45 hila::out0 << "Min value of EVEN sites " << val2 << " at location: " << loc2 << '\n';
46 hila::out0 << "Max value of ODD sites " << val3 << " at location: " << loc3 << '\n';
47 hila::out0 << "Max value of EVEN sites " << val4 << " at location: " << loc4 << '\n';
48 hila::out0 << "Min value of ALL sites " << val5 << " at location: " << loc5 << '\n';
49 hila::out0 << "Max value of ALL sites " << val6 << " at location: " << loc6 << '\n';
50
51
52 //hila::out0 << "Reduction test " << reduced << "\n";
54 return 0;
55}
Complex definition.
Definition cmplx.h:56
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
Definition field.h:61
T max(Parity par=ALL) const
Find maximum value from Field.
Definition reduction.h:424
T min(Parity par=ALL) const
Find minimum value from Field.
Definition reduction.h:404
void setup(const CoordinateVector &siz)
General lattice setup.
Definition lattice.cpp:33
constexpr Parity EVEN
bit pattern: 001
constexpr Parity ODD
bit pattern: 010
constexpr Parity ALL
bit pattern: 011
std::ostream out0
This writes output only from main process (node 0)
void initialize(int argc, char **argv)
Read in command line arguments. Initialise default stream and MPI communication.
void seed_random(uint64_t seed, bool device_rng=true)
Seed random generators with 64-bit unsigned value. On MPI shuffles the seed so that different MPI ran...
Definition random.cpp:86
void finishrun()
Normal, controlled exit - all nodes must call this. Prints timing information and information about c...