MCPcopy Create free account
hub / github.com/SZAILAB/MaterialDFT-Demo / candidate_integer_rotations

Function candidate_integer_rotations

cpp_core/src/symmetry.cpp:71–93  ·  view source on GitHub ↗

Generate all 3x3 integer matrices with entries in {-1,0,1} and |det|=1. Returns column-major Mat3i (exactly 386 candidates). CONVENTION: We enumerate a_{row,col} values (matching Python's row-major iteration order). Then store in column-major: M[col][row] = a_{row,col}.

Source from the content-addressed store, hash-verified

69// CONVENTION: We enumerate a_{row,col} values (matching Python's row-major
70// iteration order). Then store in column-major: M[col][row] = a_{row,col}.
71std::vector<Mat3i> candidate_integer_rotations() {
72 std::vector<Mat3i> out;
73 out.reserve(386);
74
75 const int vals[] = {-1, 0, 1};
76 for (int a00 : vals) for (int a01 : vals) for (int a02 : vals)
77 for (int a10 : vals) for (int a11 : vals) for (int a12 : vals)
78 for (int a20 : vals) for (int a21 : vals) for (int a22 : vals) {
79 // Determinant in row-major convention:
80 int det = a00*(a11*a22 - a12*a21)
81 - a01*(a10*a22 - a12*a20)
82 + a02*(a10*a21 - a11*a20);
83 if (det != 1 && det != -1) continue;
84
85 // Store column-major: M[col][row] = a_{row,col}
86 Mat3i m{};
87 m[0][0] = a00; m[0][1] = a10; m[0][2] = a20;
88 m[1][0] = a01; m[1][1] = a11; m[1][2] = a21;
89 m[2][0] = a02; m[2][1] = a12; m[2][2] = a22;
90 out.push_back(m);
91 }
92 return out;
93}
94
95// Try to find translation + permutation for a given rotation.
96bool find_atomic_permutation(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected