CASM
AClustersApproachtoStatisticalMechanics
|
#include <SupercellEnumerator.hh>
Given the dimensions of a square matrix and its determinant, HermiteCounter will cycle through every possible matrix that maintains it's Hermite normal form: -Upper triangular matrix -Determinant remains constant -row values to the right of the diagonal will always be smaller than the value of the diagonal
In addition, this class is limited to SQUARE matrices, and NONZERO determinants. The idea is to use it for supcercell enumerations, where these conditions are always met.
For a determinant det, the initial value of the counter will be a n x n identity matrix H with H(0,0)=det. The final position will be a n x n identity matrix with H(n-1,n-1)=det. Once the final position for a particular determinant is reached, the counter starts over with the next integer determinant value.
There are two main steps in the counter: -Incrementing the diagonal of the matrix such that its product remains equal to the determinant -Incrementing the upper triangular values such that they never exceed the diagonal
The diagonal increments are achieved by working only with two adjacent values at a time, distributing factors to the next diagonal element only if it equals 1. If not, the next adjacent pair is selected.
Definition at line 155 of file SupercellEnumerator.hh.
Public Types | |
typedef Eigen::VectorXi::Scalar | value_type |
typedef CASM::Index | Index |
Public Member Functions | |
HermiteCounter (int init_determinant, int init_dim) | |
constructor to satisfy iterator requirements. Do not recommend. More... | |
Index | position () const |
Eigen::VectorXi | diagonal () const |
Eigen::MatrixXi | current () const |
Get the current matrix the counter is on. More... | |
value_type | determinant () const |
Get the current determinant. More... | |
Index | dim () const |
Get the dimensions of *this. More... | |
void | reset_current () |
reset the counter to the first iteration of the current determinant More... | |
void | next_determinant () |
Skip the remaining iterations and start at the next determinant value. More... | |
void | jump_to_determinant (value_type new_det) |
Reset the diagonal to the specified determinant and set the other elements to zero. More... | |
HermiteCounter & | operator++ () |
Jump to the next available HNF matrix. More... | |
Eigen::MatrixXi | operator() () const |
Get the current matrix the counter is on. More... | |
Private Member Functions | |
Index | _increment_diagonal () |
Go to the next values of diagonal elements that keep the same determinant. More... | |
Private Attributes | |
Index | m_pos |
Keeps track of the current diagonal element that needs to be factored. More... | |
Eigen::VectorXi | m_diagonal |
Vector holding diagonal element values. More... | |
EigenVectorXiCounter | m_upper_tri |
unrolled vector of the upper triangle (does not include diagonal elements) More... | |
Definition at line 158 of file SupercellEnumerator.hh.
typedef Eigen::VectorXi::Scalar CASM::HermiteCounter::value_type |
Definition at line 157 of file SupercellEnumerator.hh.
CASM::HermiteCounter::HermiteCounter | ( | int | init_start_determinant, |
int | init_dim | ||
) |
constructor to satisfy iterator requirements. Do not recommend.
constructor given the desired determinant and square matrix dimensions
If you really need a n x m (vs n x n) matrix, or to allow zeros along the longest diagonal, this class won't work.
Definition at line 113 of file SupercellEnumerator.cc.
|
private |
Go to the next values of diagonal elements that keep the same determinant.
Definition at line 155 of file SupercellEnumerator.cc.
Eigen::MatrixXi CASM::HermiteCounter::current | ( | ) | const |
Get the current matrix the counter is on.
Definition at line 129 of file SupercellEnumerator.cc.
HermiteCounter::value_type CASM::HermiteCounter::determinant | ( | ) | const |
Get the current determinant.
Definition at line 141 of file SupercellEnumerator.cc.
Eigen::VectorXi CASM::HermiteCounter::diagonal | ( | ) | const |
Definition at line 125 of file SupercellEnumerator.cc.
HermiteCounter::Index CASM::HermiteCounter::dim | ( | ) | const |
Get the dimensions of *this.
Definition at line 133 of file SupercellEnumerator.cc.
void CASM::HermiteCounter::jump_to_determinant | ( | value_type | new_det | ) |
Reset the diagonal to the specified determinant and set the other elements to zero.
Definition at line 187 of file SupercellEnumerator.cc.
void CASM::HermiteCounter::next_determinant | ( | ) |
Skip the remaining iterations and start at the next determinant value.
Definition at line 150 of file SupercellEnumerator.cc.
Eigen::MatrixXi CASM::HermiteCounter::operator() | ( | ) | const |
Get the current matrix the counter is on.
Definition at line 137 of file SupercellEnumerator.cc.
HermiteCounter & CASM::HermiteCounter::operator++ | ( | ) |
Jump to the next available HNF matrix.
Definition at line 160 of file SupercellEnumerator.cc.
HermiteCounter::Index CASM::HermiteCounter::position | ( | ) | const |
Definition at line 121 of file SupercellEnumerator.cc.
void CASM::HermiteCounter::reset_current | ( | ) |
reset the counter to the first iteration of the current determinant
Definition at line 145 of file SupercellEnumerator.cc.
|
private |
Vector holding diagonal element values.
Definition at line 204 of file SupercellEnumerator.hh.
|
private |
Keeps track of the current diagonal element that needs to be factored.
Definition at line 201 of file SupercellEnumerator.hh.
|
private |
unrolled vector of the upper triangle (does not include diagonal elements)
Definition at line 207 of file SupercellEnumerator.hh.