32 #ifndef CLASSES_EXCEPTION1_H_ 33 #define CLASSES_EXCEPTION1_H_ 71 class Exception :
public std::exception {
74 mutable std::string msg_;
82 explicit Exception(
const std::string& where) : where_{where}, msg_{} {}
89 const char* what() const noexcept
override {
94 msg_ += description();
105 virtual std::string description()
const = 0;
108 inline std::string Exception::description()
const {
109 return "qpp::exception::Exception";
119 class Unknown :
public Exception {
121 std::string description()
const override {
return "UNKNOWN EXCEPTION"; }
123 using Exception::Exception;
132 class ZeroSize :
public Exception {
134 std::string description()
const override {
return "Object has zero size"; }
136 using Exception::Exception;
145 class MatrixNotSquare :
public Exception {
147 std::string description()
const override {
return "Matrix is not square"; }
149 using Exception::Exception;
158 class MatrixNotCvector :
public Exception {
160 std::string description()
const override {
161 return "Matrix is not a column vector";
164 using Exception::Exception;
173 class MatrixNotRvector :
public Exception {
175 std::string description()
const override {
176 return "Matrix is not a row vector";
179 using Exception::Exception;
188 class MatrixNotVector :
public Exception {
190 std::string description()
const override {
191 return "Matrix is not a vector";
194 using Exception::Exception;
203 class MatrixNotSquareNorCvector :
public Exception {
205 std::string description()
const override {
206 return "Matrix is not square nor column vector";
209 using Exception::Exception;
218 class MatrixNotSquareNorRvector :
public Exception {
220 std::string description()
const override {
221 return "Matrix is not square nor row vector";
224 using Exception::Exception;
233 class MatrixNotSquareNorVector :
public Exception {
235 std::string description()
const override {
236 return "Matrix is not square nor vector";
239 using Exception::Exception;
248 class MatrixMismatchSubsys :
public Exception {
250 std::string description()
const override {
251 return "Matrix mismatch subsystems";
254 using Exception::Exception;
263 class DimsInvalid :
public Exception {
265 std::string description()
const override {
return "Invalid dimension(s)"; }
267 using Exception::Exception;
276 class DimsNotEqual :
public Exception {
278 std::string description()
const override {
return "Dimensions not equal"; }
280 using Exception::Exception;
290 class DimsMismatchMatrix :
public Exception {
292 std::string description()
const override {
293 return "Dimension(s) mismatch matrix size";
296 using Exception::Exception;
306 class DimsMismatchCvector :
public Exception {
308 std::string description()
const override {
309 return "Dimension(s) mismatch column vector size";
312 using Exception::Exception;
322 class DimsMismatchRvector :
public Exception {
324 std::string description()
const override {
325 return "Dimension(s) mismatch row vector size";
328 using Exception::Exception;
339 class DimsMismatchVector :
public Exception {
341 std::string description()
const override {
342 return "Dimension(s) mismatch vector size";
345 using Exception::Exception;
355 class SubsysMismatchDims :
public Exception {
357 std::string description()
const override {
358 return "Subsystems mismatch dimensions";
361 using Exception::Exception;
370 class PermInvalid :
public Exception {
372 std::string description()
const override {
return "Invalid permutation"; }
374 using Exception::Exception;
384 class PermMismatchDims :
public Exception {
386 std::string description()
const override {
387 return "Permutation mismatch dimensions";
390 using Exception::Exception;
399 class NotQubitMatrix :
public Exception {
401 std::string description()
const override {
return "Matrix is not 2 x 2"; }
403 using Exception::Exception;
412 class NotQubitCvector :
public Exception {
414 std::string description()
const override {
415 return "Column vector is not 2 x 1";
418 using Exception::Exception;
427 class NotQubitRvector :
public Exception {
429 std::string description()
const override {
430 return "Row vector is not 1 x 2";
433 using Exception::Exception;
442 class NotQubitVector :
public Exception {
444 std::string description()
const override {
445 return "Vector is not 2 x 1 nor 1 x 2";
448 using Exception::Exception;
457 class NotQubitSubsys :
public Exception {
459 std::string description()
const override {
460 return "Subsystems are not qubits";
463 using Exception::Exception;
472 class NotBipartite :
public Exception {
474 std::string description()
const override {
return "Not bi-partite"; }
476 using Exception::Exception;
486 class NoCodeword :
public Exception {
488 std::string description()
const override {
489 return "Codeword does not exist";
492 using Exception::Exception;
501 class OutOfRange :
public Exception {
503 std::string description()
const override {
return "Argument out of range"; }
505 using Exception::Exception;
514 class TypeMismatch :
public Exception {
516 std::string description()
const override {
return "Type mismatch"; }
518 using Exception::Exception;
527 class SizeMismatch :
public Exception {
529 std::string description()
const override {
return "Size mismatch"; }
531 using Exception::Exception;
540 class UndefinedType :
public Exception {
542 std::string description()
const override {
543 return "Not defined for this type";
546 using Exception::Exception;
555 class QuditAlreadyMeasured :
public Exception {
557 std::string description()
const override {
558 return "Qudit was already measured (destructively)";
561 using Exception::Exception;
571 class Duplicates :
public Exception {
573 std::string description()
const override {
574 return "System (e.g. std::vector) contains duplicates";
577 using Exception::Exception;
586 class CustomException :
public Exception {
589 std::string description()
const override {
590 return "CUSTOM EXCEPTION " + what_;
594 CustomException(
const std::string& where,
const std::string& what)
595 : Exception{where}, what_{what} {}
602 class NotImplemented :
public Exception {
604 std::string description()
const override {
return "Not yet implemented"; }
606 using Exception::Exception;
613 class InvalidIterator :
public Exception {
615 std::string description()
const override {
return "Invalid iterator"; }
617 using Exception::Exception;
624 class FileNotFound :
public Exception {
626 std::string description()
const override {
return "File not found"; }
628 using Exception::Exception;
635 class LexicalError :
public Exception {
637 std::string description()
const override {
return "Lexical error"; }
639 using Exception::Exception;
646 class ParseError :
public Exception {
648 std::string description()
const override {
return "Parse error"; }
650 using Exception::Exception;
657 class SemanticError :
public Exception {
659 std::string description()
const override {
return "Semantic error"; }
661 using Exception::Exception;
668 class Undeclared :
public Exception {
670 std::string description()
const override {
return "Undeclared variable"; }
672 using Exception::Exception;
Quantum++ main namespace.
Definition: circuits.h:35