src/heg_solver.cc
// Generate k vectors in ascending order of magnitude, and then x, y, z.
Generate k vectors in ascending order of magnitude, and then x, y, z.
Generate k vectors in ascending order of magnitude and then x y z .
void HEGSolver::generate_k_vectors() {
  const int n_max = floor(heg.r_cutoff);
  heg.n_max = n_max;
  std::vector<std::array<int, 3>> temp_k_vectors;
  std::vector<int> temp_k_length2;
  for (int i = -n_max; i <= n_max; i++) {
    for (int j = -n_max; j <= n_max; j++) {
      for (int k = -n_max; k <= n_max; k++) {
        const int length2 = i * i + j * j + k * k;
        if (length2 > pow(heg.r_cutoff, 2)) continue;
        const Int3 temp_k_vector({i, j, k});
        temp_k_vectors.push_back(temp_k_vector);
        temp_k_length2.push_back(length2);
      }
    }
  }
  const int n_orbs = temp_k_vectors.size();
  std::vector<int> order;
  for (int i = 0; i < n_orbs; i++) order.push_back(i);
  std::stable_sort(
      order.begin(),
      order.end(),
      [&temp_k_length2](const int& a, const int& b) -> bool {
        return temp_k_length2[a] < temp_k_length2[b];
      });
  for (int i = 0; i < n_orbs; i++) {
    heg.k_vectors.push_back(temp_k_vectors[order[i]]);
  }
}
void HEGSolver :: generate_k_vectors ( ) { const int n_max = floor ( heg . r_cutoff ) ; heg . n_max = n_max ; std :: vector < std :: array < int , 3 > > temp_k_vectors ; std :: vector < int > temp_k_length2 ; for ( int i = - n_max ; i <= n_max ; i ++ ) { for ( int j = - n_max ; j <= n_max ; j ++ ) { for ( int k = - n_max ; k <= n_max ; k ++ ) { const int length2 = i * i + j * j + k * k ; if ( length2 > pow ( heg . r_cutoff , 2 ) ) continue ; const Int3 temp_k_vector ( { i , j , k } ) ; temp_k_vectors . push_back ( temp_k_vector ) ; temp_k_length2 . push_back ( length2 ) ; } } } const int n_orbs = temp_k_vectors . size ( ) ; std :: vector < int > order ; for ( int i = 0 ; i < n_orbs ; i ++ ) order . push_back ( i ) ; std :: stable_sort ( order . begin ( ) , order . end ( ) , [ & temp_k_length2 ] ( const int & a , const int & b ) -> bool { return temp_k_length2 [ a ] < temp_k_length2 [ b ] ; } ) ; for ( int i = 0 ; i < n_orbs ; i ++ ) { heg . k_vectors . push_back ( temp_k_vectors [ order [ i ] ] ) ; } }
Generate k vectors in ascending order of magnitude, and then x, y, z.
Generate k vectors in ascending order of magnitude and then x y z .
// Get all valid k vectors and magnitudes. // Sort. // Push to k_vectors.