56 bb_end << d(0), d(1), d(2);
65 VectorXCounter counter(bb_begin, bb_end, bb_incr);
68 for(; counter.valid(); ++counter) {
69 dist =
_dist(counter.current());
70 if(prev_range < dist && dist <=
m_range) {
108 return A.transpose() *
m_W * A;
115 vec.segment(1, 3) = A;
126 return std::lexicographical_compare(A.data(), A.data() + A.size(), B.data(), B.data() + B.size());
147 for(
int i = 0; i < 3; ++i) {
148 for(
int j = 0; j < 3; ++j) {
149 if(!
almost_zero(W(i, j), tol) && std::abs(W(i, j)) < std::abs(min)) {
157 Eigen::LLT<Eigen::MatrixXd> llt(W);
158 if(llt.info() != Eigen::Success) {
164 ((n + 1.0)*W).cwiseAbs().maxCoeff() < max_element_value) {
191 m_prim_grid_size(prim_grid.size()),
192 m_site(prim_grid.size()),
193 m_unitcell(prim_grid.size()) {
204 for(
auto it = prim_nlist.
begin(); it != prim_nlist.
end(); ++it) {
216 m_site[i].push_back((*b_it)*m_prim_grid_size + unitcell_index);
242 std::sort(nlist.begin(), nlist.end());
243 return std::adjacent_find(nlist.begin(), nlist.end()) != nlist.end();
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.
const SublatIndices & sublat_indices() const
pair of const_iterators over a range of indices of sublattices to include
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Index Scalar
size_type m_prim_grid_size
store prim grid size for site index -> unitcell index conversion unitcell_index = site_index % m_prim...
A Counter allows looping over many incrementing variables in one loop.
Scalar _dist(const UnitCell &A) const
Calculate A.transpose()*M*A.
std::unique_ptr< PrimNeighborList > clone() const
Clone.
std::unique_ptr< SuperNeighborList > clone() const
Clone.
const_iterator cend() const
const_iterator over the neighborhood of unit cells
Scalar m_range
the neighborhood, m_neighborhood, contains all UnitCell with r <= m_range
const_iterator cbegin() const
const_iterator over the neighborhood of unit cells
std::vector< std::vector< size_type > > m_unitcell
m_unitcell[unitcell_index][neighbor unitcell index]
NeighborSet::size_type size_type
NeighborSet::const_iterator const_iterator
void expand(UnitCellCoord uccoord)
Expand the neighbor list to include the given UnitCellCoord.
bool _compare_unitcell(const UnitCell &A, const UnitCell &B) const
Convert [i,j,k] -> [r,i,j,k] and then lexicographically compare.
Index find(const Coordinate &_coord) const
SuperNeighborList(const PrimGrid &prim_grid, const PrimNeighborList &prim_nlist)
Constructor.
Helper Functor for Counter container access using operator()
Matrix3Type m_W
Weighting matrix.
void _expand(Scalar prev_range)
Ensure that all intermediate UnitCell are included in our neighborhood.
static bool _compare_vec(const VectorXType &A, const VectorXType &B)
Lexicographical comparison.
Eigen::Matrix< long, Eigen::Dynamic, 1 > VectorXType
NeighborSet m_neighborhood
the neighborhood of [i, j, k]
std::vector< std::vector< size_type > > m_site
m_site[unitcell_index][neighbor site index]
const std::vector< size_type > & unitcells(size_type unitcell_index) const
const Access the list of unitcells neighboring a particular unit cell
EigenIndex Index
For long integer indexing:
Eigen::CwiseUnaryOp< decltype(std::ptr_fun(boost::math::lround< typename Derived::Scalar >)), const Derived > lround(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd to Eigen::MatrixXl.
VectorXType _add_dist(const UnitCell &A) const
Return [r, i, j, k], where r = _dist(A)
T max(const T &A, const T &B)
T min(const T &A, const T &B)
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.
bool is_integer(const Eigen::MatrixBase< Derived > &M, double tol)
Check if Eigen::Matrix is integer.
size_type size() const
size of the neighborhood of unit cells
The PrimNeighborList gives the coordinates of UnitCell that are neighbors of the origin UnitCell...
std::set< int > SublatIndices
SublatIndices m_sublat_indices
the indices of sublattices that should be included
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 unit cell index from site index
bool overlaps() const
Returns true if periodic images of the neighbor list overlap.
const_iterator begin() const
const_iterator over the neighborhood of unit cells
const std::vector< size_type > & sites(size_type unitcell_index) const
const Access the list of sites neighboring a particular unit cell
Eigen::MatrixXd m_Uinv
Cholesky decomposition: W = U.transpose()*U, useful for getting bounding box.
UnitCell unitcell(Index i) const
Matrix3Type weight_matrix() const
Return the weighting matrix W used to define the canonical order.
Eigen::Matrix3l Matrix3Type
const_iterator end() const
const_iterator over the neighborhood of unit cells