Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
matrix.cpp
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright 2020 Peter Rakyta, Ph.D.
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 
17 
18 @author: Peter Rakyta, Ph.D.
19 */
24 #include "matrix.h"
25 
26 #include "matrix_float.h"
27 
34  for (int row = 0; row < rows; row++) {
35  for (int col = 0; col < cols; col++) {
36  int idx = row * stride + col;
37  ret.data[idx].real = static_cast<float>(data[idx].real);
38  ret.data[idx].imag = static_cast<float>(data[idx].imag);
39  }
40  }
41  if (is_conjugated()) ret.conjugate();
42  if (is_transposed()) ret.transpose();
43  return ret;
44 }
45 
Header file of single-precision complex array storage with automatic and thread safe reference counti...
Matrix_float to_float32() const
Convert to single precision.
Definition: matrix.cpp:32
int stride
The column stride of the array. (The array elements in one row are a_0, a_1, ... a_{cols-1}, 0, 0, 0, 0. The number of zeros is stride-cols)
Definition: matrix_base.hpp:46
float real
real part
Definition: QGDTypes.h:47
scalar * data
pointer to the stored data
Definition: matrix_base.hpp:48
float imag
imaginary part
Definition: QGDTypes.h:48
int rows
The number of rows.
Definition: matrix_base.hpp:42
int cols
The number of columns.
Definition: matrix_base.hpp:44
Header file of complex array storage array with automatic and thread safe reference counting...
void transpose()
Call to transpose (or un-transpose) the matrix for CBLAS functions.
Single-precision complex matrix (float32).
Definition: matrix_float.h:41
bool is_conjugated() const
Call to get whether the matrix should be conjugated in CBLAS functions or not.
double real
the real part of a complex number
Definition: QGDTypes.h:40
void conjugate()
Call to conjugate (or un-conjugate) the matrix for CBLAS functions.
bool is_transposed() const
Call to get whether the matrix should be conjugated in CBLAS functions or not.
double imag
the imaginary part of a complex number
Definition: QGDTypes.h:42