Revision d59320310b92ca41bd8c4d711c6c2361ae4f0d43 authored by Arthur Tolley on 13 January 2021, 09:55:09 UTC, committed by GitHub on 13 January 2021, 09:55:09 UTC
* Included an option to choose the scipy optimizer, also including the relevant arguments that are needed to customise the optimizers. Changed the default differential_evolution parameters from (100,200) to (50,100).

* Fixing an error

* PR changes, argument choices, making defaults integers, changing some of the help descriptions and the name of the shgo-n argument to shgo-samples.

* Changing from capitals to lower-case for clarity

* Importing the shgo function
1 parent 5349712
Raw File
npfft.py
# Copyright (C) 2012  Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#
# =============================================================================
#
#                                   Preamble
#
# =============================================================================
#
"""
This module provides the numpy backend of the fast Fourier transform
for the PyCBC package.
"""

import numpy.fft

def fft(invec,outvec,prec,itype,otype):
    if invec.ptr == outvec.ptr:
        raise NotImplementedError("numpy backend of pycbc.fft does not support in-place transforms")
    if itype == 'complex' and otype == 'complex':
        outvec.data = numpy.asarray(numpy.fft.fft(invec.data),dtype=outvec.dtype)
    elif itype == 'real' and otype == 'complex':
        outvec.data = numpy.asarray(numpy.fft.rfft(invec.data),dtype=outvec.dtype)

def ifft(invec,outvec,prec,itype,otype):
    if invec.ptr == outvec.ptr:
        raise NotImplementedError("numpy backend of pycbc.fft does not support in-place transforms")
    if itype == 'complex' and otype == 'complex':
        outvec.data = numpy.asarray(numpy.fft.ifft(invec.data),dtype=outvec.dtype)
        outvec *= len(outvec)
    elif itype == 'complex' and otype == 'real':
        outvec.data = numpy.asarray(numpy.fft.irfft(invec.data,len(outvec)),
                                    dtype=outvec.dtype)
        outvec *= len(outvec)

back to top