CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::xtal::HermiteCounter_impl Namespace Reference

Functions

HermiteCounter::Index _spill_factor (Eigen::VectorXi &diag, HermiteCounter::Index position, HermiteCounter::value_type attempt)
 Find the next factor of the specified position and share with next element. Use attempt as starting point. More...
 
HermiteCounter::Index next_spill_position (Eigen::VectorXi &diag, HermiteCounter::Index position)
 Spill the next factor of the specified element with its neighbor, and return new position. More...
 
HermiteCounter::Index upper_size (HermiteCounter::Index init_dim)
 Determine the number of elements in the upper triangular matrix (excluding diagonal) More...
 
EigenVectorXiCounter _upper_tri_counter (const Eigen::VectorXi &current_diag)
 Create a counter for the elements above the diagonal based on the current diagonal value. More...
 
Eigen::MatrixXi _zip_matrix (const Eigen::VectorXi &current_diag, const Eigen::VectorXi &current_upper_tri)
 Assemble a matrix diagonal and unrolled upper triangle values into a matrix. More...
 
Eigen::MatrixXi _expand_dims_old (const Eigen::MatrixXi &hermit_mat, const Eigen::VectorXi &active_dims)
 Expand a n x n Hermite normal matrix into a m x m one (e.g. for 2D supercells) More...
 
Eigen::MatrixXi _expand_dims (const Eigen::MatrixXi &H, const Eigen::MatrixXi &G)
 Expand a n x n Hermite normal matrix (H) into a m x m one through a m x m generating matrix (G) (e.g. for arbitrary 2D supercells) More...
 
Eigen::VectorXi _canonical_unroll (const Eigen::MatrixXi &hermit_mat)
 Unroll a Hermit normal form square matrix into a vector such that it's canonical form is easy to compare. More...
 
bool _canonical_compare (const Eigen::MatrixXi &H0, const Eigen::MatrixXi &H1)
 Compare two integer matrices and see which one is lexicographically greatest. Returns true if H0<H1. More...
 

Function Documentation

◆ _canonical_compare()

bool CASM::xtal::HermiteCounter_impl::_canonical_compare ( const Eigen::MatrixXi &  H0,
const Eigen::MatrixXi &  H1 
)

Compare two integer matrices and see which one is lexicographically greatest. Returns true if H0<H1.

Unrolls the two matrices in the canonical order and then compares the values element-wise to see which of the two is lexicographically greatest.

For example if M0 is 1 3 3 0 3 1 0 0 2

and M1 is 2 1 1 0 3 4 0 0 1

Then this function will return true because 231411>132133 (i.e. M0<M1) If both are equal then false is returned.

This routine expects your matrices to already be in canonical form.

Definition at line 412 of file HermiteCounter.cc.

◆ _canonical_unroll()

Eigen::VectorXi CASM::xtal::HermiteCounter_impl::_canonical_unroll ( const Eigen::MatrixXi &  hermit_mat)

Unroll a Hermit normal form square matrix into a vector such that it's canonical form is easy to compare.

When comparing two Hermite normal form matrices, the canonical one is determined on which one has larger elements along a particular order. This routine unrolls a matrix in the following manner:

1 6 5 0 2 4 0 0 3

But also works for higher dimensional matrices, such as

1 12 11 10 9 0 2 13 15 8 0 0 3 14 7 0 0 0 4 6 0 0 0 0 5

Definition at line 337 of file HermiteCounter.cc.

◆ _expand_dims()

Eigen::MatrixXi CASM::xtal::HermiteCounter_impl::_expand_dims ( const Eigen::MatrixXi &  H,
const Eigen::MatrixXi &  G 
)

Expand a n x n Hermite normal matrix (H) into a m x m one through a m x m generating matrix (G) (e.g. for arbitrary 2D supercells)

Definition at line 300 of file HermiteCounter.cc.

◆ _expand_dims_old()

Eigen::MatrixXi CASM::xtal::HermiteCounter_impl::_expand_dims_old ( const Eigen::MatrixXi &  hermit_mat,
const Eigen::VectorXi &  active_dims 
)

Expand a n x n Hermite normal matrix into a m x m one (e.g. for 2D supercells)

A particular Hermit normal form matrix can have its dimensions expanded by inserting extra 0s and a 1 in the diagonal. Specify the "active" indexes (n values of 1) and "inactive" indexes (m-n values of 0) in a vector.

For example, you can expand a 4 x 4 matrix 2 1 0 0 0 5 2 2 0 0 6 1 0 0 0 3

into a 6 x 6 matrix by specifying the vector [101110] 2 0 1 0 0 0 0 1 0 0 0 0 0 0 5 2 2 0 0 0 0 6 1 0 0 0 0 0 3 0 0 0 0 0 0 1

Rows/columns where a 0 was specified are all zero except for the diagonal element, which is 1.

Definition at line 215 of file HermiteCounter.cc.

◆ _spill_factor()

HermiteCounter::Index CASM::xtal::HermiteCounter_impl::_spill_factor ( Eigen::VectorXi &  diag,
HermiteCounter::Index  position,
HermiteCounter::value_type  attempt 
)

Find the next factor of the specified position and share with next element. Use attempt as starting point.

Definition at line 87 of file HermiteCounter.cc.

◆ _upper_tri_counter()

EigenVectorXiCounter CASM::xtal::HermiteCounter_impl::_upper_tri_counter ( const Eigen::VectorXi &  current_diag)

Create a counter for the elements above the diagonal based on the current diagonal value.

Definition at line 151 of file HermiteCounter.cc.

◆ _zip_matrix()

Eigen::MatrixXi CASM::xtal::HermiteCounter_impl::_zip_matrix ( const Eigen::VectorXi &  current_diag,
const Eigen::VectorXi &  current_upper_tri 
)

Assemble a matrix diagonal and unrolled upper triangle values into a matrix.

Definition at line 175 of file HermiteCounter.cc.

◆ next_spill_position()

HermiteCounter::Index CASM::xtal::HermiteCounter_impl::next_spill_position ( Eigen::VectorXi &  diag,
HermiteCounter::Index  position 
)

Spill the next factor of the specified element with its neighbor, and return new position.

Definition at line 112 of file HermiteCounter.cc.

◆ upper_size()

HermiteCounter::Index CASM::xtal::HermiteCounter_impl::upper_size ( HermiteCounter::Index  init_dim)

Determine the number of elements in the upper triangular matrix (excluding diagonal)

Definition at line 139 of file HermiteCounter.cc.