libqasm
library for handling cQASM files
Classes | Typedefs | Enumerations | Functions
cqasm::v1::primitives Namespace Reference

Detailed Description

Namespace for the primitive types used in trees generated by tree-gen.

Classes

class  Matrix
 Two-dimensional matrix of some kind of type. More...
 

Typedefs

using Str = std::string
 String primitive used within the AST and semantic trees. More...
 
using Bool = bool
 Boolean primitive used within the semantic trees. More...
 
using Int = std::int64_t
 Integer primitive used within the AST and semantic trees. More...
 
using Real = double
 Real number primitive used within the AST and semantic trees. More...
 
using Complex = std::complex< double >
 Complex number primitive used within the semantic trees. More...
 
using RMatrix = Matrix< Real >
 Matrix of real numbers. More...
 
using CMatrix = Matrix< Complex >
 Matrix of complex numbers. More...
 
using Version = version::Version
 Version number primitive used within the AST and semantic trees. More...
 

Enumerations

enum  Axis { Axis::X, Axis::Y, Axis::Z }
 Axis primitive used within the semantic trees. More...
 

Functions

template<>
void serialize (const error_model::ErrorModelRef &obj, ::tree::cbor::MapWriter &map)
 
template<>
error_model::ErrorModelRef deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
void serialize (const instruction::InstructionRef &obj, ::tree::cbor::MapWriter &map)
 
template<>
instruction::InstructionRef deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
Str initialize< Str > ()
 
template<>
void serialize (const Str &obj, ::tree::cbor::MapWriter &map)
 
template<>
Str deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
Bool initialize< Bool > ()
 
template<>
void serialize (const Bool &obj, ::tree::cbor::MapWriter &map)
 
template<>
Bool deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
Axis initialize< Axis > ()
 
template<>
void serialize (const Axis &obj, ::tree::cbor::MapWriter &map)
 
template<>
Axis deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
Int initialize< Int > ()
 
template<>
void serialize (const Int &obj, ::tree::cbor::MapWriter &map)
 
template<>
Int deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
Real initialize< Real > ()
 
template<>
void serialize (const Real &obj, ::tree::cbor::MapWriter &map)
 
template<>
Real deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
void serialize (const Complex &obj, ::tree::cbor::MapWriter &map)
 
template<>
Complex deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
void serialize (const RMatrix &obj, ::tree::cbor::MapWriter &map)
 
template<>
RMatrix deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
void serialize (const CMatrix &obj, ::tree::cbor::MapWriter &map)
 
template<>
CMatrix deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<>
void serialize (const Version &obj, ::tree::cbor::MapWriter &map)
 
template<>
Version deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
std::ostream & operator<< (std::ostream &os, const Axis &axis)
 Stream << overload for axis nodes. More...
 
template<class T >
initialize ()
 Generates a default value for the given primitive type. More...
 
template<typename T >
void serialize (const T &obj, ::tree::cbor::MapWriter &map)
 Serializes the given primitive object to CBOR. More...
 
template<typename T >
deserialize (const ::tree::cbor::MapReader &map)
 Deserializes the given primitive object from CBOR. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Matrix< T > &mat)
 Stream << overload for matrix nodes. More...
 

Typedef Documentation

◆ Str

using cqasm::v1::primitives::Str = typedef std::string

String primitive used within the AST and semantic trees.

Definition at line 48 of file cqasm-v1-primitives.hpp.

◆ Bool

using cqasm::v1::primitives::Bool = typedef bool

Boolean primitive used within the semantic trees.

Defaults to false.

Definition at line 59 of file cqasm-v1-primitives.hpp.

◆ Int

using cqasm::v1::primitives::Int = typedef std::int64_t

Integer primitive used within the AST and semantic trees.

Definition at line 81 of file cqasm-v1-primitives.hpp.

◆ Real

using cqasm::v1::primitives::Real = typedef double

Real number primitive used within the AST and semantic trees.

Definition at line 92 of file cqasm-v1-primitives.hpp.

◆ Complex

using cqasm::v1::primitives::Complex = typedef std::complex<double>

Complex number primitive used within the semantic trees.

Definition at line 103 of file cqasm-v1-primitives.hpp.

◆ RMatrix

Matrix of real numbers.

Definition at line 222 of file cqasm-v1-primitives.hpp.

◆ CMatrix

Matrix of complex numbers.

Definition at line 231 of file cqasm-v1-primitives.hpp.

◆ Version

Version number primitive used within the AST and semantic trees.

Definition at line 240 of file cqasm-v1-primitives.hpp.

Enumeration Type Documentation

◆ Axis

Axis primitive used within the semantic trees.

Defaults to X.

Enumerator

Definition at line 70 of file cqasm-v1-primitives.hpp.

Function Documentation

◆ serialize() [1/12]

template<>
void cqasm::v1::primitives::serialize ( const error_model::ErrorModelRef obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 58 of file cqasm-v1-error-model.cpp.

◆ deserialize() [1/12]

template<>
error_model::ErrorModelRef cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 71 of file cqasm-v1-error-model.cpp.

◆ serialize() [2/12]

template<>
void cqasm::v1::primitives::serialize ( const instruction::InstructionRef obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 78 of file cqasm-v1-instruction.cpp.

◆ deserialize() [2/12]

template<>
instruction::InstructionRef cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 95 of file cqasm-v1-instruction.cpp.

◆ initialize< Str >()

Definition at line 12 of file cqasm-v1-primitives.cpp.

◆ serialize() [3/12]

template<>
void cqasm::v1::primitives::serialize ( const Str obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 15 of file cqasm-v1-primitives.cpp.

◆ deserialize() [3/12]

template<>
Str cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 20 of file cqasm-v1-primitives.cpp.

◆ initialize< Bool >()

Definition at line 25 of file cqasm-v1-primitives.cpp.

◆ serialize() [4/12]

template<>
void cqasm::v1::primitives::serialize ( const Bool obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 28 of file cqasm-v1-primitives.cpp.

◆ deserialize() [4/12]

template<>
Bool cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 33 of file cqasm-v1-primitives.cpp.

◆ initialize< Axis >()

Definition at line 38 of file cqasm-v1-primitives.cpp.

◆ serialize() [5/12]

template<>
void cqasm::v1::primitives::serialize ( const Axis obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 41 of file cqasm-v1-primitives.cpp.

◆ deserialize() [5/12]

template<>
Axis cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 50 of file cqasm-v1-primitives.cpp.

◆ initialize< Int >()

Definition at line 60 of file cqasm-v1-primitives.cpp.

◆ serialize() [6/12]

template<>
void cqasm::v1::primitives::serialize ( const Int obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 63 of file cqasm-v1-primitives.cpp.

◆ deserialize() [6/12]

template<>
Int cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 68 of file cqasm-v1-primitives.cpp.

◆ initialize< Real >()

Definition at line 73 of file cqasm-v1-primitives.cpp.

◆ serialize() [7/12]

template<>
void cqasm::v1::primitives::serialize ( const Real obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 76 of file cqasm-v1-primitives.cpp.

◆ deserialize() [7/12]

template<>
Real cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 81 of file cqasm-v1-primitives.cpp.

◆ serialize() [8/12]

template<>
void cqasm::v1::primitives::serialize ( const Complex obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 86 of file cqasm-v1-primitives.cpp.

◆ deserialize() [8/12]

template<>
Complex cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 92 of file cqasm-v1-primitives.cpp.

◆ serialize() [9/12]

template<>
void cqasm::v1::primitives::serialize ( const RMatrix obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 97 of file cqasm-v1-primitives.cpp.

◆ deserialize() [9/12]

template<>
RMatrix cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 107 of file cqasm-v1-primitives.cpp.

◆ serialize() [10/12]

template<>
void cqasm::v1::primitives::serialize ( const CMatrix obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 119 of file cqasm-v1-primitives.cpp.

◆ deserialize() [10/12]

template<>
CMatrix cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 130 of file cqasm-v1-primitives.cpp.

◆ serialize() [11/12]

template<>
void cqasm::v1::primitives::serialize ( const Version obj,
::tree::cbor::MapWriter &  map 
)

Definition at line 142 of file cqasm-v1-primitives.cpp.

◆ deserialize() [11/12]

template<>
Version cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 151 of file cqasm-v1-primitives.cpp.

◆ operator<<() [1/2]

std::ostream & cqasm::v1::primitives::operator<< ( std::ostream &  os,
const Axis axis 
)

Stream << overload for axis nodes.

Definition at line 164 of file cqasm-v1-primitives.cpp.

◆ initialize()

template<class T >
T cqasm::v1::primitives::initialize ( )

Generates a default value for the given primitive type.

This is specialized for the primitives mapping to builtin types (int, bool, etc, for which the "constructor" doesn't initialize the value at all) such that they actually initialize with a sane default. Used in the default constructors of the generated tree nodes to ensure that there's no garbage in the nodes.

Definition at line 31 of file cqasm-v1-primitives.hpp.

◆ serialize() [12/12]

template<typename T >
void cqasm::v1::primitives::serialize ( const T &  obj,
::tree::cbor::MapWriter &  map 
)

Serializes the given primitive object to CBOR.

◆ deserialize() [12/12]

template<typename T >
T cqasm::v1::primitives::deserialize ( const ::tree::cbor::MapReader &  map)

Deserializes the given primitive object from CBOR.

Definition at line 71 of file cqasm-v1-error-model.cpp.

◆ operator<<() [2/2]

template<typename T >
std::ostream& cqasm::v1::primitives::operator<< ( std::ostream &  os,
const Matrix< T > &  mat 
)

Stream << overload for matrix nodes.

Definition at line 255 of file cqasm-v1-primitives.hpp.