Namespace na¶
-
namespace na¶
-
Functions
-
auto writeJSONSchema(std::ostream &os) -> void¶
Writes a JSON schema with default values for the device configuration to the specified output stream.
- Parameters:
os – is the output stream to write the JSON schema to.
- Throws:
std::runtime_error – if the JSON conversion fails.
-
auto writeJSONSchema(const std::string &path) -> void¶
Writes a JSON schema with default values for the device configuration to the specified path.
- Parameters:
path – The path to write the JSON schema to.
- Throws:
std::runtime_error – if the JSON conversion fails or the file cannot be opened.
-
auto readJSON(std::istream &is) -> Device¶
Parses the device configuration from an input stream.
- Parameters:
is – is the input stream containing the JSON representation of the device configuration.
- Throws:
std::runtime_error – if the JSON cannot be parsed.
- Returns:
The parsed device configuration as a Protobuf message.
-
auto readJSON(const std::string &path) -> Device¶
Parses the device configuration from a JSON file.
- Parameters:
path – is the path to the JSON file containing the device configuration.
- Throws:
std::runtime_error – if the JSON file does not exist, or the JSON file cannot be parsed.
- Returns:
The parsed device configuration as a Protobuf message.
-
auto writeHeader(const Device &device, std::ostream &os) -> void¶
Writes a header file with the device configuration to the specified output stream.
Note
This implementation only supports multi-qubit gates up to two qubits.
- Parameters:
device – is the protobuf representation of the device.
os – is the output stream to write the header file to.
- Throws:
std::runtime_error – if the file cannot be opened or written to.
-
auto writeHeader(const Device &device, const std::string &path) -> void¶
Writes a header file with the device configuration to the specified path.
Note
This implementation only supports multi-qubit gates up to two qubits.
- Parameters:
device – is the protobuf representation of the device.
path – is the path to write the header file to.
- Throws:
std::runtime_error – if the file cannot be opened or written to.
-
auto forEachRegularSites(const std::vector<Device::Lattice> &lattices, const std::function<void(const SiteInfo&)> &f, size_t startId = 0) -> void¶
Iterates over all regular sites created by the given lattices and calls the given function for each site.
- Parameters:
lattices – is the list of lattices to iterate over.
f – is the function to call for each regular site, receiving a SiteInfo struct containing all site information.
startId – is the starting identifier for the sites. Default is 0.
- Throws:
std::runtime_error – if lattice vectors are degenerate (i.e., the determinant of the lattice vector matrix is near zero, causing the system of equations to have no unique solution).
-
class Atom¶
- #include <Atom.hpp>
Represents an atom in the NAComputation.
The name of the atom is used for printing the NAComputation. To maintain the uniqueness of atoms, the name of the atom should be unique.
Public Functions
-
inline explicit Atom(std::string name)¶
Creates a new atom with the given name.
- Parameters:
name – The name of the atom.
-
inline auto getName() const -> std::string¶
Returns the name of the atom.
-
inline explicit Atom(std::string name)¶
-
struct Device¶
- #include <Generator.hpp>
Represents a neutral atom device configuration.
This struct defines the schema for the JSON representation of a neutral atom device configuration. This struct, including all its sub-structs, implements functions to serialize and deserialize to and from JSON using the nlohmann::json library.
Note
All duration and length values are in multiples of the time unit and the length unit, respectively.
Subclassed by na::Session::Device
Public Members
-
std::string name¶
The name of the device.
-
uint64_t numQubits = 0¶
The number of qubits in the device.
-
uint64_t minAtomDistance = 0¶
The minimum distance between atoms in the device that must be respected.
-
std::vector<GlobalSingleQubitOperation> globalSingleQubitOperations¶
The list of global single-qubit operations supported by the device.
-
std::vector<GlobalMultiQubitOperation> globalMultiQubitOperations¶
The list of global multi-qubit operations supported by the device.
-
std::vector<LocalSingleQubitOperation> localSingleQubitOperations¶
The list of local single-qubit operations supported by the device.
-
std::vector<LocalMultiQubitOperation> localMultiQubitOperations¶
The list of local multi-qubit operations supported by the device.
-
std::vector<ShuttlingUnit> shuttlingUnits¶
The list of shuttling units supported by the device.
-
DecoherenceTimes decoherenceTimes¶
The decoherence times of the device.
- Unit lengthUnit = {.unit = "um",.scaleFactor = 1.0}
The unit of measurement for lengths in the device.
- Unit durationUnit = {.unit = "us",.scaleFactor = 1.0}
The unit of measurement for time in the device.
-
struct DecoherenceTimes¶
- #include <Generator.hpp>
Represents the decoherence times of the device.
-
struct GlobalMultiQubitOperation : public na::Device::Operation¶
- #include <Generator.hpp>
Represents a global multi-qubit operation.
Public Members
-
uint64_t interactionRadius = 0¶
The interaction radius of the operation within which two qubits can interact.
-
uint64_t blockingRadius = 0¶
The blocking radius of the operation within which no other operation can be performed to avoid interference.
-
double idlingFidelity = 0.0¶
The fidelity of the operation when no qubits are interacting.
-
uint64_t numQubits = 0¶
The number of qubits involved in the operation.
-
uint64_t interactionRadius = 0¶
-
struct GlobalSingleQubitOperation : public na::Device::Operation¶
- #include <Generator.hpp>
Represents a global single-qubit operation.
-
struct Lattice¶
- #include <Generator.hpp>
Represents a lattice of traps in the device.
Public Members
-
Vector latticeVector1¶
The first lattice vector.
Multiples of this vector are added to the lattice origin to create the lattice structure.
-
Vector latticeVector2¶
The second lattice vector.
Multiples of this vector are added to the lattice origin and multiples of the first lattice vector to create the lattice structure.
-
std::vector<Vector> sublatticeOffsets¶
The offsets for each sublattice.
The actual locations of traps are calculated by adding the each offset to the points in the lattice defined by the lattice vectors, i.e., for each sublattice offset
offsetand indicesiandj, the trap location islatticeOrigin + i * latticeVector1 + j * latticeVector2 + offset.
-
Vector latticeVector1¶
-
struct LocalMultiQubitOperation : public na::Device::Operation¶
- #include <Generator.hpp>
Represents a local multi-qubit operation.
Public Members
-
uint64_t interactionRadius = 0¶
The interaction radius of the operation within which two qubits can interact.
-
uint64_t blockingRadius = 0¶
The blocking radius of the operation within which no other operation can be performed to avoid interference.
-
uint64_t numQubits = 0¶
The number of qubits involved in the operation.
-
uint64_t interactionRadius = 0¶
-
struct LocalSingleQubitOperation : public na::Device::Operation¶
- #include <Generator.hpp>
Represents a local single-qubit operation.
-
struct Region¶
- #include <Generator.hpp>
Represents a region in the device.
-
struct Size¶
- #include <Generator.hpp>
The size of the region.
-
struct Size¶
-
struct ShuttlingUnit¶
- #include <Generator.hpp>
Represents a shuttling unit in the device.
Public Members
-
size_t id = 0¶
Unique identifier for the shuttling unit.
-
uint64_t loadDuration = 0¶
The duration of the load operation in the shuttling unit.
-
uint64_t storeDuration = 0¶
The duration of the store operation in the shuttling unit.
-
double loadFidelity = 0.0¶
The fidelity of the load operation in the shuttling unit.
-
double storeFidelity = 0.0¶
The fidelity of the store operation in the shuttling unit.
-
uint64_t numParameters = 0¶
The number of parameters the shuttling unit takes.
-
uint64_t meanShuttlingSpeed = 0¶
The mean shuttling speed.
Note
Only for shuttling operations.
-
size_t id = 0¶
-
struct Unit¶
- #include <Generator.hpp>
Represents a unit of measurement for length and time.
-
struct Vector¶
- #include <Generator.hpp>
Represents a 2D-vector.
-
std::string name¶
-
class GlobalCZOp : public na::GlobalOp¶
- #include <GlobalCZOp.hpp>
Represents a global CZ operation in the NAComputation.
-
class GlobalOp : public na::Op¶
- #include <GlobalOp.hpp>
Represents a global operation in the NAComputation.
Global operations are applied to entire zones instead of to individual atoms.
Subclassed by na::GlobalCZOp, na::GlobalRYOp
-
class GlobalRYOp : public na::GlobalOp¶
- #include <GlobalRYOp.hpp>
Represents a global RY operation in the NAComputation.
-
class LoadOp : public na::ShuttlingOp¶
- #include <LoadOp.hpp>
Represents a load operation in the NAComputation.
Before an atom can be moved, it must be loaded, i.e., transferred from a static SLM to an adjustable AOD trap.
Public Functions
-
inline LoadOp(std::vector<const Atom*> atoms, std::vector<Location> targetLocations)¶
Creates a new load operation with the given atoms and target locations.
The target locations can be set if the loading operation contains a certain offset.
- Parameters:
atoms – The atoms to load.
targetLocations – The target locations to load the atoms to.
-
inline explicit LoadOp(std::vector<const Atom*> atoms)¶
Creates a new load operation with the given atoms.
This constructor is used if the target locations are not set, i.e., the load operation does not incorporate any offset.
- Parameters:
atoms – The atoms to load.
-
inline LoadOp(const Atom &atom, const Location &targetLocation)¶
Creates a new load operation with the given atom and target location.
The target locations can be set if the loading operation contains a certain offset.
- Parameters:
atom – The atom to load.
targetLocation – The target location to load the atom to.
-
inline explicit LoadOp(const Atom &atom)¶
Creates a new load operation with the given atom.
This constructor is used if the target locations are not set, i.e., the load operation does not incorporate any offset.
- Parameters:
atom – The atom to load.
-
inline virtual auto hasTargetLocations() const -> bool override¶
Returns whether the load operation has target locations set.
-
inline virtual auto getTargetLocations() const -> const std::vector<Location>& override¶
Returns the target locations of the load operation.
-
virtual auto toString() const -> std::string override¶
Returns a string representation of the load operation.
-
inline LoadOp(std::vector<const Atom*> atoms, std::vector<Location> targetLocations)¶
-
class LocalOp : public na::Op¶
- #include <LocalOp.hpp>
Represents a local operation in the NAComputation.
A local operation is applied to individual atoms.
Subclassed by na::LocalRZOp, na::LocalUOp
-
class LocalRZOp : public na::LocalOp¶
- #include <LocalRZOp.hpp>
Represents a local RZ operation in the NAComputation.
-
class LocalUOp : public na::LocalOp¶
- #include <LocalUOp.hpp>
Represents a local U3 operation in the NAComputation.
Public Functions
-
inline LocalUOp(std::vector<const Atom*> atoms, const qc::fp theta, const qc::fp phi, const qc::fp lambda)¶
Creates a new U3 operation with the given atoms and angles.
- Parameters:
atoms – The atoms the operation is applied to.
theta – The first parameter of the operation.
phi – The second parameter of the operation.
lambda – The third parameter of the operation.
-
inline LocalUOp(const Atom &atom, const qc::fp theta, const qc::fp phi, const qc::fp lambda)¶
Creates a new U3 operation with the given atom and angle.
- Parameters:
atom – The atom the operation is applied to.
theta – The first parameter of the operation.
phi – The second parameter of the operation.
lambda – The third parameter of the operation.
-
inline LocalUOp(std::vector<const Atom*> atoms, const qc::fp theta, const qc::fp phi, const qc::fp lambda)¶
-
struct Location¶
- #include <Location.hpp>
Class to store two-dimensional coordinates of type double.
Public Functions
-
inline Location operator-(const Location &loc) const¶
Subtracts the coordinates of the given location from this location.
- Parameters:
loc – The location to subtract.
- Returns:
The location resulting from the subtraction.
-
inline Location operator+(const Location &loc) const¶
Adds the coordinates of the given location to this location.
- Parameters:
loc – The location to add.
- Returns:
The location resulting from the addition.
-
inline auto length() const -> double¶
Returns the length of the vector from the origin to this location.
-
inline auto toString() const -> std::string¶
Returns a string representation of the location in the format “(x, y)”.
-
inline auto operator==(const Location &other) const -> bool¶
Compares two locations for equality.
- Parameters:
other – The location to compare with.
- Returns:
True if the locations are equal, false otherwise.
-
inline auto operator!=(const Location &other) const -> bool¶
Compares two locations for inequality.
- Parameters:
other – The location to compare with.
- Returns:
True if the locations are not equal, false otherwise.
-
inline auto operator<(const Location &other) const -> bool¶
Compares two locations for less than.
- Parameters:
other – The location to compare with.
- Returns:
True if this location is less than the other location, false
-
inline auto operator>(const Location &other) const -> bool¶
Compares two locations for greater than.
- Parameters:
other – The location to compare with.
- Returns:
True if this location is greater than the other location, false
-
inline auto operator>=(const Location &other) const -> bool¶
Compares two locations for greater than or equal.
- Parameters:
other – The location to compare with.
- Returns:
True if this location is greater than or equal to the other
-
inline auto operator<=(const Location &other) const -> bool¶
Compares two locations for less than or equal.
- Parameters:
other – The location to compare with.
- Returns:
True if this location is less than or equal to the other location,
-
inline auto getEuclideanDistance(const Location &loc) const -> double¶
Computes the Euclidean distance between this location and the given location.
- Parameters:
loc – The location to compute the distance to.
- Returns:
The Euclidean distance between the two locations.
Public Members
-
double x = 0¶
The x-coordinate of the location.
-
double y = 0¶
The y-coordinate of the location.
Public Static Functions
-
inline Location operator-(const Location &loc) const¶
-
class MoveOp : public na::ShuttlingOp¶
- #include <MoveOp.hpp>
Represents a move operation in the NAComputation.
Public Functions
-
inline MoveOp(std::vector<const Atom*> atoms, std::vector<Location> targetLocations)¶
Creates a new move operation with the given atoms and target locations.
- Parameters:
atoms – The atoms to move.
targetLocations – The target locations to move the atoms to.
-
inline MoveOp(const Atom &atom, const Location &targetLocation)¶
Creates a new move operation with the given atom and target location.
- Parameters:
atom – The atom to move.
targetLocation – The target location to move the atom to.
-
inline virtual auto hasTargetLocations() const -> bool override¶
Returns whether the move operation has target locations set.
-
inline virtual auto getTargetLocations() const -> const decltype(targetLocations_)& override¶
Returns the target locations of the move operation.
-
virtual auto toString() const -> std::string override¶
Returns a string representation of the operation.
-
inline MoveOp(std::vector<const Atom*> atoms, std::vector<Location> targetLocations)¶
-
class NAComputation¶
- #include <NAComputation.hpp>
Represents a neutral atom computation.
Public Functions
-
inline auto begin() -> auto¶
Returns an iterator to the beginning of the operations.
-
inline auto begin() const -> auto¶
Returns an iterator to the beginning of the operations.
-
inline auto end() -> auto¶
Returns an iterator to the end of the operations.
-
inline auto end() const -> auto¶
Returns an iterator to the end of the operations.
-
inline auto size() const -> std::size_t¶
Returns the number of operations in the NAComputation.
-
inline auto operator[](const std::size_t i) -> Op&¶
Returns a reference to the operation at the given index.
- Parameters:
i – The index of the operation.
- Returns:
A reference to the operation at the given index.
-
inline auto operator[](const std::size_t i) const -> const Op&¶
Returns a const reference to the operation at the given index.
- Parameters:
i – The index of the operation.
- Returns:
A const reference to the operation at the given index.
-
inline auto clear() -> void¶
Clears the operations in the NAComputation.
-
inline auto getAtomsSize() const -> std::size_t¶
Returns the number of atoms used in the NAComputation.
-
inline auto getAtoms() const -> auto&¶
Returns the atoms used in the NAComputation.
-
inline auto getZones() const -> auto&¶
Returns the zones used in global operations within the NAComputation.
-
inline auto getInitialLocations() const -> auto&¶
Returns the initial locations of the atoms.
-
auto getLocationOfAtomAfterOperation(const Atom &atom, const Op &op) const -> Location¶
Returns the location of the given atom after the given operation.
- Parameters:
atom – The atom to get the location for.
op – The operation to get the location after.
- Returns:
The location of the atom after the operation.
-
inline auto emplaceBackAtom(std::string name) -> const Atom&¶
Emplaces a new atom with the given name and returns a reference to the newly created atom.
- Parameters:
name – The name of the atom.
- Returns:
A reference to the newly created atom.
-
template<typename ...Args>
inline auto emplaceBackZone(Args&&... args) -> const Zone&¶ Emplaces a new zone with the given name and returns a reference to the newly created zone.
- Parameters:
args – The name of the zone and, optionally, the extent of the zone.
- Returns:
A reference to the newly created zone.
-
inline auto emplaceInitialLocation(const Atom &atom, const Location &loc) -> const Location&¶
Emplaces a new initial location for the given atom with the given location and returns a reference to the newly created location.
- Parameters:
atom – The atom to set the initial location for.
loc – The location of the atom.
- Returns:
A reference to the newly created location.
-
template<typename ...Args>
inline auto emplaceInitialLocation(const Atom &atom, Args&&... loc) -> const Location&¶ Emplaces a new initial location for the given atom with the given arguments and returns a reference to the newly created location.
- Parameters:
atom – The atom to set the initial location for.
loc – The parameters for the location of the atom.
- Returns:
A reference to the newly created location.
-
template<class T>
inline auto emplaceBack(T &&op) -> const Op&¶ Emplaces a new operation of type T with the given operation and returns a reference to the newly created operation.
- Template Parameters:
T – The concrete type of the operation.
- Parameters:
op – The operation to emplace.
- Returns:
A reference to the newly created operation.
-
template<class T, typename ...Args>
inline auto emplaceBack(Args&&... args) -> const Op&¶ Emplaces a new operation of type T with the given arguments and returns a reference to the newly created operation.
- Template Parameters:
T – The concrete type of the operation.
- Parameters:
args – The arguments for the operation.
- Returns:
A reference to the newly created operation.
-
auto toString() const -> std::string¶
Returns a string representation of the NAComputation.
-
auto validate() const -> std::pair<bool, std::string>¶
Validates the NAComputation and checks whether all AOD constraints are fulfilled. Specifically,
each atom is loaded before it is moved
the relative order of loaded atoms is preserved
each atom is loaded before it is stored
each atom is stored before it is loaded (again)
- Returns:
a pair of a Boolean indicating whether the NAComputation is valid and a string containing the error message if the NAComputation is invalid.
Friends
-
inline friend auto operator<<(std::ostream &os, const NAComputation &qc) -> std::ostream&¶
Outputs the NAComputation to the given output stream, i.e., the string returned by toString().
- Parameters:
os – The output stream to print the NAComputation to.
qc – The NAComputation to print.
- Returns:
The output stream after printing the NAComputation.
-
inline auto begin() -> auto¶
-
class Op¶
- #include <Op.hpp>
This is the base class for all operations in the NAComputation.
Subclassed by na::GlobalOp, na::LocalOp, na::ShuttlingOp
Public Functions
-
Op() = default¶
Default constructor.
-
virtual ~Op() = default¶
Virtual destructor.
-
virtual auto toString() const -> std::string = 0¶
Returns a string representation of the operation.
-
template<class T>
inline auto is() const -> bool¶ Checks if the operation is of the given type.
- Template Parameters:
T – The type to check for.
- Returns:
True if the operation is of the given type, false otherwise.
-
Op() = default¶
-
class Session : public fomac::Session¶
- #include <Device.hpp>
Class representing the Session library with neutral atom extensions.
See also
Public Functions
-
Session() = delete¶
Deleted default constructor to prevent instantiation.
Public Static Functions
-
class Device : public fomac::Session::Device, private na::Device¶
- #include <Device.hpp>
Class representing a quantum device with neutral atom extensions.
See also
Note
Since it inherits from na::Device, Device objects can be converted to
nlohmann::jsonobjects.Public Functions
-
inline auto getLengthUnit() const -> const Unit&¶
- Returns:
the length unit of the device.
-
inline auto getDurationUnit() const -> const Unit&¶
- Returns:
the duration unit of the device.
-
inline auto getDecoherenceTimes() const -> const DecoherenceTimes&¶
- Returns:
the decoherence times of the device.
-
inline auto getTraps() const -> const std::vector<Lattice>&¶
- Returns:
the list of trap lattices of the device.
Public Static Functions
-
static inline auto tryCreateFromDevice(const fomac::Session::Device &device) -> std::optional<Device>¶
Try to create a Device object from a fomac::Session::Device object.
This method attempts to create a Device object by initializing all necessary fields from the provided fomac::Session::Device object. If any required information is missing or invalid, the method returns
std::nullopt.- Parameters:
device – is the fomac::Session::Device object to wrap.
- Returns:
An optional containing the instantiated device if compatible, std::nullopt otherwise.
-
inline auto getLengthUnit() const -> const Unit&¶
-
Session() = delete¶
-
class ShuttlingOp : public na::Op¶
- #include <ShuttlingOp.hpp>
Represents a shuttling operation in the NAComputation.
A shuttling operation is the super class for all shuttling-related operations, i.e., load, store, and move operations.
Subclassed by na::LoadOp, na::MoveOp, na::StoreOp
-
struct SingleOperation¶
-
struct SiteInfo¶
- #include <Generator.hpp>
Information about a regular site in a lattice.
This struct encapsulates all relevant information about a site for use in the forEachRegularSites callback.
Public Members
-
uint64_t id¶
The unique identifier of the site.
-
int64_t x¶
The x-coordinate of the site.
-
int64_t y¶
The y-coordinate of the site.
-
uint64_t moduleId¶
The identifier of the lattice (module) the site belongs to.
-
uint64_t subModuleId¶
The identifier of the sublattice (submodule) the site belongs to.
-
uint64_t id¶
-
class StoreOp : public na::ShuttlingOp¶
- #include <StoreOp.hpp>
Represents a store operation in the NAComputation.
Public Functions
-
inline StoreOp(std::vector<const Atom*> atoms, std::vector<Location> targetLocations)¶
Creates a new store operation with the given atoms and target locations.
The target locations can be used if the store operation incorporates some offset.
- Parameters:
atoms – The atoms to store.
targetLocations – The target locations to store the atoms to.
-
inline explicit StoreOp(std::vector<const Atom*> atoms)¶
Creates a new store operation with the given atoms and target locations.
Here, the target locations are not used, i.e., this store does not contain any offset.
- Parameters:
atoms – The atoms to store.
-
inline StoreOp(const Atom &atom, const Location &targetLocation)¶
Creates a new store operation with the given atom and target location.
The target location can be used if the store operation incorporates some offset.
- Parameters:
atom – The atom to store.
targetLocation – The target location to store the atom to.
-
inline explicit StoreOp(const Atom &atom)¶
Creates a new store operation with the given atom and target locations.
Here, the target locations are not used, i.e., this store does not contain any offset.
- Parameters:
atom – The atom to store.
-
inline virtual auto hasTargetLocations() const -> bool override¶
Returns whether the store operation has target locations set.
-
inline virtual auto getTargetLocations() const -> const std::vector<Location>& override¶
Returns the target locations of the store operation.
-
virtual auto toString() const -> std::string override¶
Returns a string representation of the operation.
-
inline StoreOp(std::vector<const Atom*> atoms, std::vector<Location> targetLocations)¶
-
class Zone¶
- #include <Zone.hpp>
Represents a zone in the NAComputation.
The name of the zone is used for printing the NAComputation. To maintain the uniqueness of zones, the name of the zone should be unique for this zone.
Public Functions
-
inline explicit Zone(std::string name)¶
Creates a new zone with the given name.
- Parameters:
name – The name of the zone.
-
inline Zone(std::string name, const Extent &extent)¶
Creates a new zone with the given name.
- Parameters:
name – The name of the zone.
extent – The extent of the zone.
-
inline auto getName() const -> std::string¶
Returns the name of the zone.
Friends
-
struct Extent¶
- #include <Zone.hpp>
A simple struct to represent the extent of a zone.
-
inline explicit Zone(std::string name)¶
-
auto writeJSONSchema(std::ostream &os) -> void¶