10template <
typename Scalar>
13 :
Basis<
BasisAtom<Scalar>>(std::move(kets)), id_of_kets(std::move(id_of_kets)),
15 for (
size_t i = 0; i < this->
kets.size(); ++i) {
16 ket_id_to_ket_index[this->
kets[i]->get_id_in_database()] = i;
20template <
typename Scalar>
25template <
typename Scalar>
27 return this->kets[0]->get_species();
30template <
typename Scalar>
32 if (ket_id_to_ket_index.count(ket_id) == 0) {
35 return ket_id_to_ket_index.at(ket_id);
38template <
typename Scalar>
43template <
typename Scalar>
46 auto final = this->get_canonical_state_from_ket(ket);
47 auto matrix_elements =
48 this->get_database().get_matrix_elements(this->shared_from_this(),
final, type, q);
50 assert(
static_cast<size_t>(matrix_elements.rows()) == 1);
51 assert(
static_cast<size_t>(matrix_elements.cols()) == this->get_number_of_states());
53 return matrix_elements.row(0);
56template <
typename Scalar>
57Eigen::SparseMatrix<Scalar, Eigen::RowMajor>
60 auto matrix_elements =
61 this->get_database().get_matrix_elements(this->shared_from_this(), other, type, q);
63 assert(
static_cast<size_t>(matrix_elements.rows()) == other->get_number_of_states());
64 assert(
static_cast<size_t>(matrix_elements.cols()) == this->get_number_of_states());
66 return matrix_elements;
Class for creating a basis of atomic kets.
int get_ket_index_from_id(size_t ket_id) const
const std::string & get_id_of_kets() const
BasisAtom(Private, ketvec_t &&kets, std::string &&id_of_kets, Database &database)
typename traits::CrtpTraits< Type >::ketvec_t ketvec_t
const std::string & get_species() const
Database & get_database() const
Eigen::VectorX< Scalar > get_matrix_elements(std::shared_ptr< const ket_t > ket, OperatorType type, int q=0) const override
Matrix< Type, Dynamic, 1 > VectorX