libqasm
library for handling cQASM files
Public Member Functions | List of all members
cqasm::v1::primitives::Matrix< T > Class Template Reference

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

Public Member Functions

 Matrix ()
 Creates an empty matrix. More...
 
 Matrix (size_t ncols)
 Creates a vector. More...
 
 Matrix (size_t nrows, size_t ncols)
 Creates a zero-initialized matrix of the given size. More...
 
 Matrix (const std::vector< T > &data)
 Creates a column vector with the given data. More...
 
 Matrix (const std::vector< T > &data, size_t ncols)
 Creates a matrix with the given data. More...
 
size_t size_rows () const
 Returns the number of rows. More...
 
size_t size_cols () const
 Returns the number of columns. More...
 
const std::vector< T > & get_data () const
 Returns access to the raw data vector. More...
 
at (size_t row, size_t col) const
 Returns the value at the given position. More...
 
T & at (size_t row, size_t col)
 Returns a mutable reference to the value at the given position. More...
 
bool operator== (const Matrix< T > &rhs) const
 Equality operator for matrices. More...
 
bool operator!= (const Matrix< T > &rhs) const
 Inequality operator for matrices. More...
 

Detailed Description

template<typename T>
class cqasm::v1::primitives::Matrix< T >

Two-dimensional matrix of some kind of type.

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

#include <cqasm-v1-primitives.hpp>

Constructor & Destructor Documentation

◆ Matrix() [1/5]

template<typename T>
cqasm::v1::primitives::Matrix< T >::Matrix ( )
inline

Creates an empty matrix.

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

◆ Matrix() [2/5]

template<typename T>
cqasm::v1::primitives::Matrix< T >::Matrix ( size_t  ncols)
inline

Creates a vector.

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

◆ Matrix() [3/5]

template<typename T>
cqasm::v1::primitives::Matrix< T >::Matrix ( size_t  nrows,
size_t  ncols 
)
inline

Creates a zero-initialized matrix of the given size.

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

◆ Matrix() [4/5]

template<typename T>
cqasm::v1::primitives::Matrix< T >::Matrix ( const std::vector< T > &  data)
inline

Creates a column vector with the given data.

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

◆ Matrix() [5/5]

template<typename T>
cqasm::v1::primitives::Matrix< T >::Matrix ( const std::vector< T > &  data,
size_t  ncols 
)
inline

Creates a matrix with the given data.

The number of rows is inferred. If the number of data elements is not divisible by the number of columns, a range error is thrown.

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

Member Function Documentation

◆ size_rows()

template<typename T>
size_t cqasm::v1::primitives::Matrix< T >::size_rows ( ) const
inline

Returns the number of rows.

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

◆ size_cols()

template<typename T>
size_t cqasm::v1::primitives::Matrix< T >::size_cols ( ) const
inline

Returns the number of columns.

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

◆ get_data()

template<typename T>
const std::vector<T>& cqasm::v1::primitives::Matrix< T >::get_data ( ) const
inline

Returns access to the raw data vector.

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

◆ at() [1/2]

template<typename T>
T cqasm::v1::primitives::Matrix< T >::at ( size_t  row,
size_t  col 
) const
inline

Returns the value at the given position.

row and col start at 1. Throws a std::range_error when either or both indices are out of range.

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

◆ at() [2/2]

template<typename T>
T& cqasm::v1::primitives::Matrix< T >::at ( size_t  row,
size_t  col 
)
inline

Returns a mutable reference to the value at the given position.

row and col start at 1. Throws a std::range_error when either or both indices are out of range.

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

◆ operator==()

template<typename T>
bool cqasm::v1::primitives::Matrix< T >::operator== ( const Matrix< T > &  rhs) const
inline

Equality operator for matrices.

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

◆ operator!=()

template<typename T>
bool cqasm::v1::primitives::Matrix< T >::operator!= ( const Matrix< T > &  rhs) const
inline

Inequality operator for matrices.

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


The documentation for this class was generated from the following file: