Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
matrix_real_any.h
Go to the documentation of this file.
1 /*
2 Copyright 2026
3 
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 */
10 
11 #ifndef MATRIX_REAL_ANY_H
12 #define MATRIX_REAL_ANY_H
13 
14 #include "matrix_real.h"
15 #include "matrix_real_float.h"
16 #include <string>
17 
19  float64 = 0,
20  float32 = 1
21 };
22 
27 public:
29  : precision_(matrix_real_precision::float64), m64_(&m), m32_(NULL) {}
30 
32  : precision_(matrix_real_precision::float32), m64_(NULL), m32_(&m) {}
33 
34  matrix_real_precision precision() const { return precision_; }
35 
36  bool is_float32() const { return precision_ == matrix_real_precision::float32; }
37  bool is_float64() const { return precision_ == matrix_real_precision::float64; }
38 
39  int rows() const { return is_float64() ? m64_->rows : m32_->rows; }
40  int cols() const { return is_float64() ? m64_->cols : m32_->cols; }
41  int stride() const { return is_float64() ? m64_->stride : m32_->stride; }
42 
44  if (!m64_) {
45  throw std::string("Matrix_real_any::as_float64 called on float32 matrix");
46  }
47  return *m64_;
48  }
49 
51  if (!m32_) {
52  throw std::string("Matrix_real_any::as_float32 called on float64 matrix");
53  }
54  return *m32_;
55  }
56 
57 private:
61 };
62 
63 #endif
int stride() const
Class to store single-precision real arrays and properties.
matrix_real_precision precision_
bool is_float32() const
int cols() const
Matrix_real * m64_
bool is_float64() const
Non-owning carrier that can reference either Matrix_real or Matrix_real_float.
matrix_real_precision
Matrix_real_any(Matrix_real_float &m)
Matrix_real & as_float64()
int rows() const
Matrix_real_any(Matrix_real &m)
Matrix_real_float & as_float32()
matrix_real_precision precision() const
Matrix_real_float * m32_
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:41