pairinteraction
A Rydberg Interaction Calculator
id_in_database.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024 Pairinteraction Developers
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#pragma once
5
6#include <string>
7#include <type_traits>
8
10constexpr size_t OFFSET = 500;
11
12// String that can be used in an SQL query to calculate a linearized index ("id_in_database")
13// from the id of a state without quantum number m and the quantum number m. Note that the
14// string must be of the form "id*{2*OFFSET}+(2*m+{OFFSET})::bigint".
15constexpr std::string_view SQL_TERM_FOR_LINEARIZED_ID_IN_DATABASE = "id*1000+(2*m+500)::bigint";
16
17// Method for calculating the linearized index
18inline size_t get_linearized_id_in_database(size_t id, double quantum_number_m) {
19 return id * 2 * OFFSET + static_cast<size_t>(2 * quantum_number_m + OFFSET);
20}
21} // namespace pairinteraction::utils
constexpr std::string_view SQL_TERM_FOR_LINEARIZED_ID_IN_DATABASE
constexpr size_t OFFSET
size_t get_linearized_id_in_database(size_t id, double quantum_number_m)