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

Detailed Description

Namespace for the classes representing the types available within cQASM.

Namespace for the various classes representing the types of values available in cQASM.

dot_inline_dotgraph_3.png

Classes

class  Axis
 Type of an axis (x, y, or z). More...
 
class  Bool
 Type of a boolean/bit. More...
 
class  Complex
 Type of a complex number (2x IEEE double). More...
 
class  ComplexMatrix
 Type of a complex matrix. More...
 
class  Dumper
 Visitor class that debug-dumps a tree to a stream. More...
 
class  Int
 Type of an integer (signed 64-bit). More...
 
class  Json
 Type of a JSON string. More...
 
class  Node
 Main class for all nodes. More...
 
class  Qubit
 Type of one or more qubit references. More...
 
class  Real
 Type of a real number (IEEE double). More...
 
class  RealMatrix
 Type of a real matrix. More...
 
class  RecursiveVisitor
 Visitor base class defaulting to DFS pre-order traversal. More...
 
class  String
 Type of an arbitrary string. More...
 
class  TypeBase
 Base for all types, with a member indicating whether values of this type are assignable (references) or not (constants, expression results). More...
 
class  Visitor
 Base class for the visitor pattern for the tree. More...
 
class  VisitorBase
 Internal class for implementing the visitor pattern. More...
 

Typedefs

using Type = tree::One< TypeBase >
 A cQASM type. More...
 
using Types = tree::Any< TypeBase >
 Zero or more cQASM types. More...
 
using Base = cqasm::tree::Base
 
template<class T >
using Maybe = cqasm::tree::Maybe< T >
 
template<class T >
using One = cqasm::tree::One< T >
 
template<class T >
using Any = cqasm::tree::Any< T >
 
template<class T >
using Many = cqasm::tree::Many< T >
 
template<class T >
using OptLink = cqasm::tree::OptLink< T >
 
template<class T >
using Link = cqasm::tree::Link< T >
 

Enumerations

enum  NodeType {
  NodeType::Axis, NodeType::Bool, NodeType::Complex, NodeType::ComplexMatrix,
  NodeType::Int, NodeType::Json, NodeType::Qubit, NodeType::Real,
  NodeType::RealMatrix, NodeType::String
}
 Enumeration of all node types. More...
 

Functions

Types from_spec (const std::string &spec)
 Constructs a set of types from a shorthand string representation. More...
 
bool type_check (const Type &expected, const Type &actual)
 Returns whether the actual type matches the constraints of the expected type. More...
 
std::ostream & operator<< (std::ostream &os, const Type &type)
 Stream << overload for a single type. More...
 
std::ostream & operator<< (std::ostream &os, const Types &types)
 Stream << overload for zero or more types. More...
 
std::ostream & operator<< (std::ostream &os, const Node &object)
 Stream << overload for tree nodes (writes debug dump). More...
 

Typedef Documentation

◆ Type

A cQASM type.

Definition at line 21 of file cqasm-v1-types.hpp.

◆ Types

Zero or more cQASM types.

Definition at line 26 of file cqasm-v1-types.hpp.

◆ Base

Definition at line 61 of file cqasm-v1-types-gen.hpp.

◆ Maybe

template<class T >
using cqasm::v1::types::Maybe = typedef cqasm::tree::Maybe<T>

Definition at line 62 of file cqasm-v1-types-gen.hpp.

◆ One

template<class T >
using cqasm::v1::types::One = typedef cqasm::tree::One<T>

Definition at line 63 of file cqasm-v1-types-gen.hpp.

◆ Any

template<class T >
using cqasm::v1::types::Any = typedef cqasm::tree::Any<T>

Definition at line 64 of file cqasm-v1-types-gen.hpp.

◆ Many

template<class T >
using cqasm::v1::types::Many = typedef cqasm::tree::Many<T>

Definition at line 65 of file cqasm-v1-types-gen.hpp.

◆ OptLink

template<class T >
using cqasm::v1::types::OptLink = typedef cqasm::tree::OptLink<T>

Definition at line 66 of file cqasm-v1-types-gen.hpp.

◆ Link

template<class T >
using cqasm::v1::types::Link = typedef cqasm::tree::Link<T>

Definition at line 67 of file cqasm-v1-types-gen.hpp.

Enumeration Type Documentation

◆ NodeType

Enumeration of all node types.

Enumerator
Axis 
Bool 
Complex 
ComplexMatrix 
Int 
Json 
Qubit 
Real 
RealMatrix 
String 

Definition at line 91 of file cqasm-v1-types-gen.hpp.

Function Documentation

◆ from_spec()

Types cqasm::v1::types::from_spec ( const std::string &  spec)

Constructs a set of types from a shorthand string representation.

In it, each character represents one type. The supported characters are as follows:

  • Q = qubit
  • B = assignable bit/boolean (measurement register)
  • b = bit/boolean
  • a = axis (x, y, or z)
  • i = integer
  • r = real
  • c = complex
  • u = complex matrix of size 4^n, where n is the number of qubits in the parameter list (automatically deduced)
  • s = (quoted) string
  • j = json

In general, lowercase means the parameter is only read and can thus be a constant, while uppercase means it is mutated.

Note that complex matrices with different constraints and real matrices of any kind cannot be specified this way. You'll have to construct and add those manually.

Definition at line 35 of file cqasm-v1-types.cpp.

◆ type_check()

bool cqasm::v1::types::type_check ( const Type expected,
const Type actual 
)

Returns whether the actual type matches the constraints of the expected type.

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

◆ operator<<() [1/3]

std::ostream & cqasm::v1::types::operator<< ( std::ostream &  os,
const Type type 
)

Stream << overload for a single type.

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

◆ operator<<() [2/3]

std::ostream & cqasm::v1::types::operator<< ( std::ostream &  os,
const Types types 
)

Stream << overload for zero or more types.

Definition at line 203 of file cqasm-v1-types.cpp.

◆ operator<<() [3/3]

std::ostream & cqasm::v1::types::operator<< ( std::ostream &  os,
const Node object 
)

Stream << overload for tree nodes (writes debug dump).

Definition at line 2227 of file cqasm-v1-types-gen.cpp.