Commit 67f6c2a8 authored by Ashwin Vishnu's avatar Ashwin Vishnu
Browse files
parent ad4f3d9abc1a
Pipeline #15107 passed with stage
in 5 minutes and 1 second
......@@ -32,7 +32,7 @@ def get_doc(lines, indent=' '):
strings_to_be_deleted = [
' int ', ' view3df_t ', ' view3dc_t ',
' view2df_t ', ' view2dc_t ']
' view2df_t ', ' view2dc_t ', 'const ']
def get_function_code(lines):
......
......@@ -91,7 +91,7 @@ cdef class ${class_name}:
@cython.boundscheck(False)
@cython.wraparound(False)
# @cython.initializedcheck(False)
cpdef fft_as_arg(self, view2df_t fieldX,
cpdef fft_as_arg(self, const view2df_t fieldX,
view2dc_t fieldK):
"""Perform the fft and copy the result in the second argument."""
self.thisptr.fft(&fieldX[0, 0], <mycomplex*> &fieldK[0, 0])
......@@ -99,7 +99,7 @@ cdef class ${class_name}:
@cython.boundscheck(False)
@cython.wraparound(False)
# @cython.initializedcheck(False)
cpdef ifft_as_arg(self, view2dc_t fieldK,
cpdef ifft_as_arg(self, const view2dc_t fieldK,
view2df_t fieldX):
"""Perform the ifft and copy the result in the second argument."""
self.thisptr.ifft(<mycomplex*> &fieldK[0, 0], &fieldX[0, 0])
......@@ -107,7 +107,7 @@ cdef class ${class_name}:
@cython.boundscheck(False)
@cython.wraparound(False)
# @cython.initializedcheck(False)
cpdef fft(self, view2df_t fieldX):
cpdef fft(self, const view2df_t fieldX):
"""Perform the fft and returns the result."""
cdef np.ndarray[DTYPEc_t, ndim=2] fieldK
fieldK = np.empty(self._shapeK_loc, dtype=DTYPEc, order='C')
......@@ -117,7 +117,7 @@ cdef class ${class_name}:
@cython.boundscheck(False)
@cython.wraparound(False)
# @cython.initializedcheck(False)
cpdef ifft(self, view2dc_t fieldK):
cpdef ifft(self, const view2dc_t fieldK):
"""Perform the ifft and returns the result."""
cdef np.ndarray[DTYPEf_t, ndim=2] fieldX
fieldX = np.empty(self._shapeX_loc, dtype=DTYPEf, order='C')
......@@ -221,16 +221,16 @@ cdef class ${class_name}:
return x0loc, x1loc
def compute_energy_from_X(self, view2df_t fieldX):
def compute_energy_from_X(self, const view2df_t fieldX):
"""Compute the mean energy from a real space array."""
return <float> self.thisptr.compute_energy_from_X(&fieldX[0, 0])
def compute_energy_from_K(self, view2dc_t fieldK):
def compute_energy_from_K(self, const view2dc_t fieldK):
"""Compute the mean energy from a Fourier space array."""
return <float> self.thisptr.compute_energy_from_K(
<mycomplex*> &fieldK[0, 0])
def sum_wavenumbers(self, view2df_t fieldK):
def sum_wavenumbers(self, const view2df_t fieldK):
"""Compute the sum over all wavenumbers."""
return <float> self.thisptr.sum_wavenumbers(&fieldK[0, 0])
......
......@@ -127,7 +127,7 @@ cdef class ${class_name}:
@cython.boundscheck(False)
@cython.wraparound(False)
# @cython.initializedcheck(False)
cpdef fft_as_arg(self, view3df_t fieldX,
cpdef fft_as_arg(self, const view3df_t fieldX,
view3dc_t fieldK):
"""Perform FFT and put result in second argument."""
......@@ -139,9 +139,15 @@ cdef class ${class_name}:
@cython.boundscheck(False)
@cython.wraparound(False)
# @cython.initializedcheck(False)
cpdef ifft_as_arg(self, view3dc_t fieldK,
cpdef ifft_as_arg(self, const view3dc_t fieldK,
view3df_t fieldX):
"""Perform iFFT and put result in second argument."""
"""Perform iFFT and put result in second argument.
.. note::
The values in the input array would be retained by making a copy to
an intermediate input array. This can have a performance impact.
"""
self.thisptr.ifft(<mycomplex*> &fieldK[0, 0, 0], &fieldX[0, 0, 0])
@cython.boundscheck(False)
......@@ -149,14 +155,20 @@ cdef class ${class_name}:
# @cython.initializedcheck(False)
cpdef ifft_as_arg_destroy(self, view3dc_t fieldK,
view3df_t fieldX):
"""Perform iFFT and put result in second argument."""
"""Perform iFFT and put result in second argument.
.. note::
The values in the input array would be destroyed for the better
performance.
"""
self.thisptr.ifft_destroy(
<mycomplex*> &fieldK[0, 0, 0], &fieldX[0, 0, 0])
@cython.boundscheck(False)
@cython.wraparound(False)
# @cython.initializedcheck(False)
cpdef fft(self, view3df_t fieldX):
cpdef fft(self, const view3df_t fieldX):
"""Perform FFT and return the result."""
cdef np.ndarray[DTYPEc_t, ndim=3] fieldK
fieldK = np.empty(self._shapeK_loc, dtype=DTYPEc, order='C')
......@@ -166,7 +178,7 @@ cdef class ${class_name}:
@cython.boundscheck(False)
@cython.wraparound(False)
# @cython.initializedcheck(False)
cpdef ifft(self, view3dc_t fieldK):
cpdef ifft(self, const view3dc_t fieldK):
"""Perform iFFT and return the result."""
cdef np.ndarray[DTYPEf_t, ndim=3] fieldX
fieldX = np.empty(self.get_shapeX_loc(), dtype=DTYPEf, order='C')
......@@ -452,11 +464,11 @@ cdef class ${class_name}:
return arr3d
def compute_energy_from_X(self, view3df_t fieldX):
def compute_energy_from_X(self, const view3df_t fieldX):
"""Compute the mean energy from a real space array."""
return <float> self.thisptr.compute_energy_from_X(&fieldX[0, 0, 0])
def compute_energy_from_K(self, view3dc_t fieldK):
def compute_energy_from_K(self, const view3dc_t fieldK):
"""Compute the mean energy from a Fourier space array."""
return <float> self.thisptr.compute_energy_from_K(
<mycomplex*> &fieldK[0, 0, 0])
......
  • @all Oh no! Accidental push. This was supposed to be a WIP MR to address #30. I wanted to do it at Cython level first and then consider adding const to the C++ files after discussion. What should I do? Keep it / revert it?

  • mentioned in issue #30

    Toggle commit list
  • It seems perfectly reasonable so I don't think it should be reverted! Thanks. It's better like that.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment