Quantum++  v1.0.0-beta1
C++11 quantum computing library
qpp::Exception Class Reference

Generates custom exceptions, used when validating function parameters. More...

#include <classes/exception.h>

Inheritance diagram for qpp::Exception:
Collaboration diagram for qpp::Exception:

Public Types

enum  Type {
  Type::UNKNOWN_EXCEPTION = 1, Type::ZERO_SIZE, Type::MATRIX_NOT_SQUARE, Type::MATRIX_NOT_CVECTOR,
  Type::MATRIX_NOT_RVECTOR, Type::MATRIX_NOT_VECTOR, Type::MATRIX_NOT_SQUARE_OR_CVECTOR, Type::MATRIX_NOT_SQUARE_OR_RVECTOR,
  Type::MATRIX_NOT_SQUARE_OR_VECTOR, Type::MATRIX_MISMATCH_SUBSYS, Type::DIMS_INVALID, Type::DIMS_NOT_EQUAL,
  Type::DIMS_MISMATCH_MATRIX, Type::DIMS_MISMATCH_CVECTOR, Type::DIMS_MISMATCH_RVECTOR, Type::DIMS_MISMATCH_VECTOR,
  Type::SUBSYS_MISMATCH_DIMS, Type::PERM_INVALID, Type::PERM_MISMATCH_DIMS, Type::NOT_QUBIT_MATRIX,
  Type::NOT_QUBIT_CVECTOR, Type::NOT_QUBIT_RVECTOR, Type::NOT_QUBIT_VECTOR, Type::NOT_QUBIT_SUBSYS,
  Type::NOT_BIPARTITE, Type::NO_CODEWORD, Type::OUT_OF_RANGE, Type::TYPE_MISMATCH,
  Type::SIZE_MISMATCH, Type::UNDEFINED_TYPE, Type::CUSTOM_EXCEPTION
}
 Exception types, add more here if needed. More...
 

Public Member Functions

 Exception (const std::string &where, const Type &type)
 Constructs an exception. More...
 
 Exception (const std::string &where, const std::string &custom)
 Constructs an exception. More...
 
virtual const char * what () const noexceptoverride
 Overrides std::exception::what() More...
 

Private Member Functions

void construct_exception_msg_ ()
 Constructs the exception description from its type. More...
 

Private Attributes

std::string where_
 
std::string msg_
 
Type type_
 
std::string custom_
 

Detailed Description

Generates custom exceptions, used when validating function parameters.

Customize this class if more exceptions are needed

Member Enumeration Documentation

enum qpp::Exception::Type
strong

Exception types, add more here if needed.

See also
qpp::Exception::construct_exception_msg_()
Enumerator
UNKNOWN_EXCEPTION 

Unknown exception

ZERO_SIZE 

Zero sized object, e.g. empty Eigen::Matrix or std::vector<> with no elements

MATRIX_NOT_SQUARE 

Eigen::Matrix is not square

MATRIX_NOT_CVECTOR 

Eigen::Matrix is not a column vector

MATRIX_NOT_RVECTOR 

Eigen::Matrix is not a row vector

MATRIX_NOT_VECTOR 

Eigen::Matrix is not a row/column vector

MATRIX_NOT_SQUARE_OR_CVECTOR 

Eigen::Matrix is not square nor a column vector

MATRIX_NOT_SQUARE_OR_RVECTOR 

Eigen::Matrix is not square nor a row vector

MATRIX_NOT_SQUARE_OR_VECTOR 

Eigen::Matrix is not square nor a row/column vector

MATRIX_MISMATCH_SUBSYS 

Matrix size mismatch subsystem sizes (e.g. in qpp::apply())

DIMS_INVALID 

std::vector<idx> of dimensions has zero size or contains zeros

DIMS_NOT_EQUAL 

Local/global dimensions are not equal

DIMS_MISMATCH_MATRIX 

Product of the elements of std::vector<idx> of dimensions is not equal to the number of rows of Eigen::Matrix (assumed to be a square matrix)

DIMS_MISMATCH_CVECTOR 

Product of the elements of std::vector<idx> of dimensions is not equal to the number of elements of Eigen::Matrix (assumed to be a column vector)

DIMS_MISMATCH_RVECTOR 

Product of the elements of std::vector<idx> of dimensions is not equal to the number of elements of Eigen::Matrix (assumed to be a row vector)

DIMS_MISMATCH_VECTOR 

Product of the elements of std::vector<idx> of dimensions is not equal to the number of elements of Eigen::Matrix (assumed to be a row/column vector)

SUBSYS_MISMATCH_DIMS 

std::vector<idx> of subsystem labels has duplicates, or has entries that are larger than the size of the std::vector<idx> of dimensions

PERM_INVALID 

std::vector<idx> does note represent a valid permutation

PERM_MISMATCH_DIMS 

Size of the std::vector<idx> representing the permutation is different from the size of the std::vector<idx> of dimensions

NOT_QUBIT_MATRIX 

Eigen::Matrix is not 2 x 2

NOT_QUBIT_CVECTOR 

Eigen::Matrix is not 2 x 1

NOT_QUBIT_RVECTOR 

Eigen::Matrix is not 1 x 2

NOT_QUBIT_VECTOR 

Eigen::Matrix is not 1 x 2 nor 2 x 1

NOT_QUBIT_SUBSYS 

Subsystems are not 2-dimensional

NOT_BIPARTITE 

std::vector<idx> of dimensions has size different from 2

NO_CODEWORD 

Codeword does not exist, thrown when calling qpp::Codes::codeword() with invalid index i

OUT_OF_RANGE 

Parameter out of range

TYPE_MISMATCH 

Scalar types do not match

SIZE_MISMATCH 

Sizes do not match

UNDEFINED_TYPE 

Templated specialization not defined for this type

CUSTOM_EXCEPTION 

Custom exception, user must provide a custom message

Constructor & Destructor Documentation

qpp::Exception::Exception ( const std::string &  where,
const Type type 
)
inline

Constructs an exception.

Parameters
whereText representing where the exception occured
typeException type, defined in qpp::Exception::Type
qpp::Exception::Exception ( const std::string &  where,
const std::string &  custom 
)
inline

Constructs an exception.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
whereText representing where the exception occured
customException description

Member Function Documentation

void qpp::Exception::construct_exception_msg_ ( )
inlineprivate

Constructs the exception description from its type.

See also
qpp::Exception::Type

Must modify the code of this function if more exceptions are added

virtual const char* qpp::Exception::what ( ) const
inlineoverridevirtualnoexcept

Overrides std::exception::what()

Returns
Exception description

Member Data Documentation

std::string qpp::Exception::custom_
private
std::string qpp::Exception::msg_
private
Type qpp::Exception::type_
private
std::string qpp::Exception::where_
private

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