Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
matrix_real_float.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 */
20 
21 #include "matrix_real_float.h"
22 #include <cstring>
23 #include <cmath>
24 
25 
27 }
28 
29 Matrix_real_float::Matrix_real_float(float* data_in, int rows_in, int cols_in)
30  : matrix_base<float>(data_in, rows_in, cols_in) {
31 }
32 
33 Matrix_real_float::Matrix_real_float(float* data_in, int rows_in, int cols_in, int stride_in)
34  : matrix_base<float>(data_in, rows_in, cols_in, stride_in) {
35 }
36 
37 Matrix_real_float::Matrix_real_float(int rows_in, int cols_in)
38  : matrix_base<float>(rows_in, cols_in) {
39 }
40 
41 Matrix_real_float::Matrix_real_float(int rows_in, int cols_in, int stride_in)
42  : matrix_base<float>(rows_in, cols_in, stride_in) {
43 }
44 
46  : matrix_base<float>(in) {
47 }
48 
52  return *this;
53 }
54 
57 
59 
60  ret.conjugated = conjugated;
61  ret.transposed = transposed;
62  ret.owner = true;
63 
64  memcpy(ret.data, data, rows * stride * sizeof(float));
65 
66  return ret;
67 
68 }
69 
70 bool
72 
73  for (int idx=0; idx < rows*cols; idx++) {
74  if (std::isnan(data[idx])) {
75  return true;
76  }
77  }
78 
79  return false;
80 
81 }
Class to store single-precision real arrays and properties.
bool owner
logical value indicating whether the class instance is the owner of the stored data or not...
Definition: matrix_base.hpp:57
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
scalar * data
pointer to the stored data
Definition: matrix_base.hpp:48
bool transposed
logical variable indicating whether the matrix needs to be transposed in CBLAS operations ...
Definition: matrix_base.hpp:55
bool conjugated
logical variable indicating whether the matrix needs to be conjugated in CBLAS operations ...
Definition: matrix_base.hpp:53
Matrix_real_float copy() const
Base Class to store data of arrays and its properties.
Definition: matrix_base.hpp:38
void operator=(const matrix_base &mtx)
Assignment operator.
int rows
The number of rows.
Definition: matrix_base.hpp:42
int cols
The number of columns.
Definition: matrix_base.hpp:44
Matrix_real_float & operator=(const Matrix_real_float &mtx)