Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
numpy_interface.h
Go to the documentation of this file.
1 /*
2 Copyright 2020 Peter Rakyta, Ph.D.
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 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 
16 */
17 
18 #ifndef NUMPY_INTERFACE_H
19 #define NUMPY_INTERFACE_H
20 
21 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
22 #include <Python.h>
23 #include <numpy/arrayobject.h>
24 #include "matrix.h"
25 #include "matrix_float.h"
26 #include "matrix_real.h"
27 #include "matrix_real_float.h"
28 
29 
34 void capsule_cleanup(PyObject* capsule);
35 
36 
37 
45 PyObject* array_from_ptr(void * ptr, int dim, npy_intp* shape, int np_type);
46 
47 
48 
53 PyObject* matrix_to_numpy( Matrix &mtx );
54 
59 PyObject* matrix_float_to_numpy( Matrix_float &mtx );
60 
61 
66 PyObject* matrix_real_to_numpy( Matrix_real &mtx );
67 
73 
74 
80 
84 Matrix numpy2matrix(PyArrayObject *arr);
85 
89 Matrix_float numpy2matrix_float(PyArrayObject *arr);
90 
91 
95 Matrix_real numpy2matrix_real(PyArrayObject *arr);
96 
100 Matrix_real_float numpy2matrix_real_float(PyArrayObject *arr);
101 
102 
103 
104 
105 
106 #endif
Header file of single-precision complex array storage with automatic and thread safe reference counti...
Class to store single-precision real arrays and properties.
Matrix_real numpy2matrix_real(PyArrayObject *arr)
Call to create a PIC matrix_real representation of a numpy array.
PyObject * matrix_real_to_numpy(Matrix_real &mtx)
Call to make a numpy array from an instance of matrix class.
Matrix_real_float numpy2matrix_real_float(PyArrayObject *arr)
Call to create a PIC matrix_real_float representation of a numpy array.
PyObject * array_from_ptr(void *ptr, int dim, npy_intp *shape, int np_type)
Call to make a numpy array from data stored via void pointer.
PyObject * matrix_real_float_to_numpy(Matrix_real_float &mtx)
Call to make a numpy array from an instance of matrix_real_float class.
Header file of complex array storage array with automatic and thread safe reference counting...
Double-precision complex matrix (float64).
Definition: matrix.h:38
Matrix_float numpy2matrix_float(PyArrayObject *arr)
Call to create a PIC matrix_float representation of a numpy array.
Single-precision complex matrix (float32).
Definition: matrix_float.h:41
PyObject * matrix_float_to_numpy(Matrix_float &mtx)
Call to make a numpy array from an instance of matrix_float class.
Matrix numpy2matrix(PyArrayObject *arr)
Call to create a PIC matrix representation of a numpy array.
PyObject * matrix_int8_to_numpy(matrix_base< int8_t > &mtx)
Call to make a numpy array from an instance of matrix_base<int8_t> class.
void capsule_cleanup(PyObject *capsule)
Method to cleanup the memory when the python object becomes released.
PyObject * matrix_to_numpy(Matrix &mtx)
Call to make a numpy array from an instance of matrix class.
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:41