69 auto d = [&](
int i) {
return std::lround(std::ceil(M.row(i).norm())); };
72 bb_end << d(0), d(1), d(2);
80 VectorXCounter counter(bb_begin, bb_end, bb_incr);
83 for (; counter.valid(); ++counter) {
84 dist =
_dist(counter.current());
85 if (prev_range < dist && dist <=
m_range) {
142 return A.transpose() *
m_W * A;
150 vec.segment(1, 3) = A;
163 return std::lexicographical_compare(A.data(), A.data() + A.size(), B.data(),
164 B.data() + B.size());
188 for (
int i = 0; i < 3; ++i) {
189 for (
int j = 0; j < 3; ++j) {
190 if (!
almost_zero(W(i, j), tol) && std::abs(W(i, j)) < std::abs(
min)) {
198 Eigen::LLT<Eigen::MatrixXd> llt(W);
199 if (llt.info() != Eigen::Success) {
205 ((n + 1.0) * W).cwiseAbs().maxCoeff() < max_element_value) {
250 for (
auto it = prim_nlist.
begin(); it != prim_nlist.
end(); ++it) {
252 UnitCell neighbor_unitcell = ijk_index_converter(i) + *it;
254 ijk_index_converter(neighbor_unitcell);
257 m_unitcell[i].push_back(neighbor_unitcell_index);
267 neighbor_unitcell_index);
315 std::sort(nlist.begin(), nlist.end());
316 return std::adjacent_find(nlist.begin(), nlist.end()) != nlist.end();
A Counter allows looping over many incrementing variables in one loop.
The PrimNeighborList gives the coordinates of UnitCell that are neighbors of the origin UnitCell.
bool _expand(UnitCell const &uc)
Expand the neighbor list to include the given UnitCell, but do not do additional updates returns true...
Scalar m_range
the neighborhood, m_neighborhood, contains all UnitCell with r <= m_range
NeighborSet m_neighborhood
the neighborhood of [i, j, k]
Scalar _neighbor_index(UnitCellCoord const &_ucc) const
Get neighborlist index of UnitCellCoord.
Scalar _dist(const UnitCell &A) const
Calculate A.transpose()*M*A.
Scalar neighbor_index(UnitCellCoord const &_ucc)
Get neighborlist index of UnitCellCoord.
const_iterator cend() const
const_iterator over the neighborhood of unit cells
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Index Scalar
std::unique_ptr< PrimNeighborList > clone() const
Clone.
void expand(UnitCell const &uc)
Expand the neighbor list to include the given UnitCellCoord.
const_iterator cbegin() const
const_iterator over the neighborhood of unit cells
size_type size() const
size of the neighborhood of unit cells
std::set< int > SublatIndices
const_iterator end() const
const_iterator over the neighborhood of unit cells
const_iterator begin() const
const_iterator over the neighborhood of unit cells
NeighborSet::size_type size_type
Eigen::MatrixXd m_Uinv
Cholesky decomposition: W = U.transpose()*U, useful for getting bounding box.
const SublatIndices & sublat_indices() const
pair of const_iterators over a range of indices of sublattices to include
SublatIndices m_sublat_indices
the indices of sublattices that should be included
bool _compare_unitcell(const UnitCell &A, const UnitCell &B) const
Convert [i,j,k] -> [r,i,j,k] and then lexicographically compare.
Matrix3Type m_W
Weighting matrix.
Matrix3Type weight_matrix() const
Return the weighting matrix W used to define the canonical order.
static bool _compare_vec(const VectorXType &A, const VectorXType &B)
Lexicographical comparison.
Eigen::Matrix< long, Eigen::Dynamic, 1 > VectorXType
Eigen::Matrix3l Matrix3Type
NeighborSet::const_iterator const_iterator
static Matrix3Type make_weight_matrix(const Eigen::Matrix3d lat_column_mat, Index max_element_value, double tol)
Returns a NeighborList weighting matrix appropriate for a particular lattice.
VectorXType _add_dist(const UnitCell &A) const
Return [r, i, j, k], where r = _dist(A)
PrimNeighborList(const Matrix3Type &W, SublatIterator begin, SublatIterator end)
Constructor, specifying the weighting matrix to use and the indices of sublattices to include.
size_type unitcell_index(size_type site_index) const
Get unitcell_index from site_index.
std::vector< std::vector< size_type > > m_site
m_site[unitcell_index][neighbor site index]
std::vector< std::vector< size_type > > m_unitcell
m_unitcell[unitcell_index][neighbor unitcell index]
const std::vector< size_type > & unitcells(size_type unitcell_index) const
const Access the list of unitcells neighboring a particular unit cell
bool overlaps() const
Returns true if periodic images of the neighbor list overlap.
std::unique_ptr< SuperNeighborList > clone() const
Clone.
SuperNeighborList(Eigen::Matrix3l const &transformation_matrix_to_super, PrimNeighborList const &prim_nlist)
Constructor.
size_type m_prim_grid_size
store prim grid size for site index -> unitcell index conversion unitcell_index = site_index % m_prim...
const std::vector< size_type > & sites(size_type unitcell_index) const
const Access the list of sites neighboring a particular unit cell
const UnitCell & unitcell() const
Eigen::CwiseUnaryOp< decltype(Local::lround_l< typename Derived::Scalar >), const Derived > lround(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd to Eigen::MatrixXl.
bool is_integer(const Eigen::MatrixBase< Derived > &M, double tol)
Check if Eigen::Matrix is integer.
Index find_index(Iterator begin, Iterator end, const T &value)
Equivalent to std::distance(begin, std::find(begin, end, value))
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.
T min(const T &A, const T &B)
INDEX_TYPE Index
For long integer indexing:
T max(const T &A, const T &B)
Matrix< long int, 3, 3 > Matrix3l
Helper Functor for Counter container access using operator()