Skip to content

Instantly share code, notes, and snippets.

@nathanshammah
Created June 4, 2019 15:04
Show Gist options
  • Save nathanshammah/7054fd9954d0e5abe17db1d1981903d4 to your computer and use it in GitHub Desktop.
Save nathanshammah/7054fd9954d0e5abe17db1d1981903d4 to your computer and use it in GitHub Desktop.
qutip cython compiled file
#!python
#cython: language_level=3
# This file is generated automatically by QuTiP.
# (C) 2011 and later, QuSTaR
import numpy as np
cimport numpy as np
cimport cython
np.import_array()
cdef extern from "numpy/arrayobject.h" nogil:
void PyDataMem_NEW_ZEROED(size_t size, size_t elsize)
void PyArray_ENABLEFLAGS(np.ndarray arr, int flags)
from qutip.cy.spmatfuncs cimport spmvpy
from qutip.cy.interpolate cimport interp, zinterp
from qutip.cy.math cimport erf, zerf
cdef double pi = 3.14159265358979323
include '/Users/nathanshammah/miniconda3/envs/qutip44/lib/python3.7/site-packages/qutip-4.4.0.dev0+1aa3cf9f-py3.7-macosx-10.7-x86_64.egg/qutip/cy/complex_math.pxi'
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
def cy_td_ode_rhs(
double t,
complex[::1] vec,
complex[::1] data0,int[::1] idx0,int[::1] ptr0,
complex[::1] data1,int[::1] idx1,int[::1] ptr1,
np.ndarray[np.float64_t, ndim=1] _td_array_0):
cdef size_t row
cdef unsigned int num_rows = vec.shape[0]
cdef double complex * out = <complex *>PyDataMem_NEW_ZEROED(num_rows,sizeof(complex))
spmvpy(&data0[0], &idx0[0], &ptr0[0], &vec[0], 1.0, out, num_rows)
spmvpy(&data1[0], &idx1[0], &ptr1[0], &vec[0], ((0 if (t > 10.000000) else _td_array_0[int(round(999 * (t/10.000000)))]))**2, out, num_rows)
cdef np.npy_intp dims = num_rows
cdef np.ndarray[complex, ndim=1, mode='c'] arr_out = np.PyArray_SimpleNewFromData(1, &dims, np.NPY_COMPLEX128, out)
PyArray_ENABLEFLAGS(arr_out, np.NPY_OWNDATA)
return arr_out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment