Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
matrix_real.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_real.h"
25 #include <cstring>
26 #include <iostream>
27 #include "tbb/tbb.h"
28 #include <math.h>
29 
30 
36 
37 }
38 
46 Matrix_real::Matrix_real( double* data_in, int rows_in, int cols_in) : matrix_base<double>(data_in, rows_in, cols_in) {
47 
48 }
49 
50 
59 Matrix_real::Matrix_real( double* data_in, int rows_in, int cols_in, int stride_in) : matrix_base<double>(data_in, rows_in, cols_in, stride_in) {
60 
61 }
62 
63 
70 Matrix_real::Matrix_real( int rows_in, int cols_in) : matrix_base<double>(rows_in, cols_in) {
71 
72 
73 }
74 
75 
83 Matrix_real::Matrix_real( int rows_in, int cols_in, int stride_in) : matrix_base<double>(rows_in, cols_in, stride_in) {
84 
85 }
86 
87 
88 
94 
95 }
96 
97 
98 
105 
107 
108  // logical variable indicating whether the matrix needs to be conjugated in CBLAS operations
109  ret.conjugated = conjugated;
110  // logical variable indicating whether the matrix needs to be transposed in CBLAS operations
111  ret.transposed = transposed;
112  // logical value indicating whether the class instance is the owner of the stored data or not. (If true, the data array is released in the destructor)
113  ret.owner = true;
114 
115  memcpy( ret.data, data, rows*stride*sizeof(double));
116 
117  return ret;
118 
119 }
120 
121 
126 bool
128 
129  for (int idx=0; idx < rows*cols; idx++) {
130  if ( std::isnan(data[idx]) ) {
131  return true;
132  }
133  }
134 
135  return false;
136 
137 
138 }
139 
140 
141 
142 
bool owner
logical value indicating whether the class instance is the owner of the stored data or not...
Definition: matrix_base.hpp:57
Matrix_real copy() const
Call to create a copy of the matrix.
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
Base Class to store data of arrays and its properties.
Definition: matrix_base.hpp:38
int rows
The number of rows.
Definition: matrix_base.hpp:42
int cols
The number of columns.
Definition: matrix_base.hpp:44
bool isnan()
Call to check the array for NaN entries.
Matrix_real()
Default constructor of the class.
Definition: matrix_real.cpp:35
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:39