<commit_before>inline void K_point::initialize()
{
    PROFILE_WITH_TIMER("sirius::K_point::initialize");
    
    zil_.resize(ctx_.lmax_apw() + 1);
    for (int l = 0; l <= ctx_.lmax_apw(); l++) {
        zil_[l] = std::pow(double_complex(0, 1), l);
    }
   
    l_by_lm_ = Utils::l_by_lm(ctx_.lmax_apw());

    int bs = ctx_.cyclic_block_size();

    /* In case of collinear magnetism we store only non-zero spinor components.
     *
     * non magnetic case: 
     * +---+
     * |   |
     * +---+
     *
     * collinear case:
     * +---+
     * |uu |
     * +---+---+
     *     |dd |
     *     +---+
     *
     * non collinear case:
     * +-------+
     * |       |
     * +-------+
     * |       |
     * +-------+
     */
    int nst = (ctx_.num_mag_dims() == 3) ? ctx_.num_bands() : ctx_.num_fv_states();

    if (use_second_variation && ctx_.need_sv()) {
        /* in case of collinear magnetism store pure up and pure dn components, otherwise store the full matrix */
        sv_eigen_vectors_[0] = dmatrix<double_complex>(nst, nst, ctx_.blacs_grid(), bs, bs);
        if (ctx_.num_mag_dims() == 1) {
            sv_eigen_vectors_[1] = dmatrix<double_complex>(nst, nst, ctx_.blacs_grid(), bs, bs);
        }
    }

    if (use_second_variation) {
        fv_eigen_values_.resize(ctx_.num_fv_states());
    }

    /* Find the cutoff for G+k vectors. For pseudopotential calculations this comes 
     * form the input whereas for full-potential calculations this is derived 
     * from rgkmax (aw_cutoff here) and minimal MT radius. */
    double gk_cutoff = 0;
    switch (ctx_.esm_type())
    {
        case electronic_structure_method_t::paw_pseudopotential:
        case electronic_structure_method_t::ultrasoft_pseudopotential:
        case electronic_structure_method_t::norm_conserving_pseudopotential:
        {
            gk_cutoff = ctx_.gk_cutoff();
            break;
        }
        case electronic_structure_method_t::full_potential_lapwlo:
        {
            //gk_cutoff = ctx_.aw_cutoff() / unit_cell_.min_mt_radius();
            gk_cutoff = ctx_.aw_cutoff() / unit_cell_.max_mt_radius();
            break;
        }
        default:
        {
            STOP();
        }
    }

    /* Build a full list of G+k vectors for all MPI ranks */
    generate_gkvec(gk_cutoff);
    /* build a list of basis functions */
    build_gklo_basis_descriptors();
    /* distribute basis functions */
    distribute_basis_index();
    
    if (ctx_.full_potential())
    {
        atom_lo_cols_.clear();
        atom_lo_cols_.resize(unit_cell_.num_atoms());

        atom_lo_rows_.clear();
        atom_lo_rows_.resize(unit_cell_.num_atoms());

        for (int icol = num_gkvec_col(); icol < gklo_basis_size_col(); icol++)
        {
            int ia = gklo_basis_descriptor_col(icol).ia;
            atom_lo_cols_[ia].push_back(icol);
        }
        
        for (int irow = num_gkvec_row(); irow < gklo_basis_size_row(); irow++)
        {
            int ia = gklo_basis_descriptor_row(irow).ia;
            atom_lo_rows_[ia].push_back(irow);
        }
    }<commit_msg>simplification<commit_after>inline void K_point::initialize()
{
    PROFILE_WITH_TIMER("sirius::K_point::initialize");
    
    zil_.resize(ctx_.lmax_apw() + 1);
    for (int l = 0; l <= ctx_.lmax_apw(); l++) {
        zil_[l] = std::pow(double_complex(0, 1), l);
    }
   
    l_by_lm_ = Utils::l_by_lm(ctx_.lmax_apw());

    int bs = ctx_.cyclic_block_size();

    /* In case of collinear magnetism we store only non-zero spinor components.
     *
     * non magnetic case: 
     * +---+
     * |   |
     * +---+
     *
     * collinear case:
     * +---+
     * |uu |
     * +---+---+
     *     |dd |
     *     +---+
     *
     * non collinear case:
     * +-------+
     * |       |
     * +-------+
     * |       |
     * +-------+
     */
    int nst = (ctx_.num_mag_dims() == 3) ? ctx_.num_bands() : ctx_.num_fv_states();

    if (use_second_variation && ctx_.need_sv()) {
        /* in case of collinear magnetism store pure up and pure dn components, otherwise store the full matrix */
        sv_eigen_vectors_[0] = dmatrix<double_complex>(nst, nst, ctx_.blacs_grid(), bs, bs);
        if (ctx_.num_mag_dims() == 1) {
            sv_eigen_vectors_[1] = dmatrix<double_complex>(nst, nst, ctx_.blacs_grid(), bs, bs);
        }
    }

    if (use_second_variation) {
        fv_eigen_values_.resize(ctx_.num_fv_states());
    }

    /* Build a full list of G+k vectors for all MPI ranks */
    generate_gkvec(ctx_.gk_cutoff());
    /* build a list of basis functions */
    build_gklo_basis_descriptors();
    /* distribute basis functions */
    distribute_basis_index();
    
    if (ctx_.full_potential())
    {
        atom_lo_cols_.clear();
        atom_lo_cols_.resize(unit_cell_.num_atoms());

        atom_lo_rows_.clear();
        atom_lo_rows_.resize(unit_cell_.num_atoms());

        for (int icol = num_gkvec_col(); icol < gklo_basis_size_col(); icol++)
        {
            int ia = gklo_basis_descriptor_col(icol).ia;
            atom_lo_cols_[ia].push_back(icol);
        }
        
        for (int irow = num_gkvec_row(); irow < gklo_basis_size_row(); irow++)
        {
            int ia = gklo_basis_descriptor_row(irow).ia;
            atom_lo_rows_[ia].push_back(irow);
        }
    }
{'fraction_non_alphanumeric': 0.14178403755868543, 'fraction_numerical': 0.003192488262910798, 'mean_word_length': 2.10011641443539, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2821080', 'n_tokens_mistral': 1923, 'n_tokens_neox': 1839, 'n_words': 330}