Sequential Quantum Gate Decomposer  v1.9.3
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 #include <Python.h>
22 #include <numpy/arrayobject.h>
23 #include "matrix.h"
24 #include "matrix_real.h"
25 
26 
31 void capsule_cleanup(PyObject* capsule);
32 
33 
34 
42 PyObject* array_from_ptr(void * ptr, int dim, npy_intp* shape, int np_type);
43 
44 
45 
50 PyObject* matrix_to_numpy( Matrix &mtx );
51 
52 
57 PyObject* matrix_real_to_numpy( Matrix_real &mtx );
58 
59 
65 
69 Matrix numpy2matrix(PyArrayObject *arr);
70 
71 
75 Matrix_real numpy2matrix_real(PyArrayObject *arr);
76 
77 
78 
79 
80 
81 #endif
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.
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.
Base Class to store data of arrays and its properties.
Definition: matrix_base.hpp:38
Header file of complex array storage array with automatic and thread safe reference counting...
Class to store data of complex arrays and its properties.
Definition: matrix.h:38
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:39