15 using idx_t = std::array<long, 2>;
16 using sym_t = std::tuple<idx_t, nda::operation>;
17 using sym_func_t = std::function<sym_t(idx_t
const &)>;
20 auto h_symmetry = [](idx_t
const &x) {
27 auto grp =
nda::sym_grp{A, std::vector<sym_func_t>{h_symmetry}};
30 std::cout <<
"Number of symmetry classes: " << grp.
num_classes() << std::endl;
33 for (
int i = 1;
auto const &c : grp.get_sym_classes()) {
34 std::cout <<
"Symmetry class " << i <<
":" << std::endl;
35 for (
auto const &x : c) {
36 std::cout <<
" Idx: " << x.first <<
", Sign flip: " << x.second.sgn <<
", Complex conjugation: " << x.second.cc << std::endl;
43 for (
int i = 0;
auto &x : B) x = i++;
44 std::cout << B << std::endl;
48 auto init_func = [&count_eval, &B](idx_t
const &idx) {
50 const double val = B(idx[0], idx[1]);
51 return std::complex<double>{val, val};
55 grp.init(A, init_func);
56 std::cout <<
"A = " << A << std::endl;
59 std::cout <<
"Number of evaluations: " << count_eval << std::endl;
62 auto reps = grp.get_representative_data(A);
64 std::cout <<
"Representative elements = " << reps_view << std::endl;
69 grp.init_from_representative_data(B_sym, reps);
70 std::cout <<
"B_sym = " << B_sym << std::endl;
73 auto v1 = grp.symmetrize(A);
74 std::cout <<
"Symmetrized A = " << A << std::endl;
75 std::cout <<
"Max. violation at index " << v1.second <<
" = " << v1.first << std::endl;
79 std::cout <<
"A = " << A << std::endl;
82 auto v2 = grp.symmetrize(A);
83 std::cout <<
"Symmetrized A = " << A << std::endl;
84 std::cout <<
"Max. violation at index " << v2.second <<
" = " << v2.first << std::endl;
Class representing a symmetry group.
long num_classes() const
Get the number of symmetry classes.
basic_array_view< ValueType, Rank, Layout, 'A', default_accessor, borrowed<> > array_view
Alias template of an nda::basic_array_view with an 'A' algebra, nda::default_accessor and nda::borrow...
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' algebra.
Includes all relevant headers for the core nda library.
A structure to capture combinations of complex conjugation and sign flip operations.
Provides tools to use symmetries with nda objects.