# Copyright (c) 2015, <NAME>. All rights reserved.
# Use of this source code is governed by the BSD-3-Clause
# license that can be found in the LICENSE file.
'''
Combine everything into `_fdint.pyx` and `_fdint.pxd`, in order to take advantage
of inlining.
'''

import os
import sys
fdint_dir = os.path.join(os.path.dirname(__file__), '../fdint/')
templates_dir = os.path.join(os.path.dirname(__file__), 'templates')
fdint_pyx_path = os.path.join(fdint_dir, '_fdint.pyx')
fdint_pxd_path = os.path.join(fdint_dir, '_fdint.pxd')
bases = [
    '_fd',
    '_fd_whole',
    '_vfd',

    '_dfd',
    '_vdfd',

    '_ifd',
    '_vifd',

    '_gfd',
    '_vgfd',

    '_dgfd',
    '_vdgfd',

    '_nonparabolic',
    '_vnonparabolic',

    '_dnonparabolic',
    '_vdnonparabolic',
    ]


with open(fdint_pyx_path, 'w') as f:
    f.write("""# Copyright (c) 2015, <NAME>. All rights reserved.
# Use of this source code is governed by the BSD-3-Clause
# license that can be found in the LICENSE file.

# This file was generated by `scripts/gen__fdint.py`.
# Do not edit this file directly, or your changes will be lost.
'''
Precise and fast Fermi-Dirac integrals of integer and half integer order.
    
[1] <NAME>, "Precise and fast computation of Fermi-Dirac integral of
    integer and half integer order by piecewise minimax rational approximation,"
    Applied Mathematics and Computation, vol. 259, pp. 708-729, May 2015.
    DOI: 10.1016/j.amc.2015.03.009

[2] <NAME>, "Precise and fast computation of inverse Fermi-Dirac
    integral of order 1/2 by minimax rational function approximation,"
    Applied Mathematics and Computation, vol. 259, pp. 698-707, May 2015.
    DOI: 10.1016/j.amc.2015.03.015
    
[3] <NAME>, "Precise and fast computation of generalized Fermi-Dirac
    integral by parameter polynomial approximation," 2014.
    DOI: 10.13140/2.1.1094.6566

Almost all of the low-level functions for this package are contained in this
module in order to take advantage of inlining.
'''
""")
    f.write('cimport cython\n')
    f.write('from libc.math cimport exp, log, sqrt\n')
    f.write('cimport numpy as np\n')
    f.write('import numpy\n')
    f.write('import warnings\n')
    f.write('\n')

    for base in bases:
        path = os.path.join(fdint_dir, base+'.pyx')
        with open(path, 'r') as fin:
            for line in fin:
                f.write(line)
        os.remove(path)

with open(fdint_pxd_path, 'w') as f:
    f.write('cimport numpy as np\n')
    
    for base in bases:
        path = os.path.join(fdint_dir, base+'.pxd')
        with open(path, 'r') as fin:
            for line in fin:
                f.write(line)
        os.remove(path)
# Copyright (c) 2015, <NAME>. All rights reserved.
# Use of this source code is governed by the BSD-3-Clause
# license that can be found in the LICENSE file.
'''
Combine everything into `_fdint.pyx` and `_fdint.pxd`, in order to take advantage
of inlining.
'''

import os
import sys
fdint_dir = os.path.join(os.path.dirname(__file__), '../fdint/')
templates_dir = os.path.join(os.path.dirname(__file__), 'templates')
fdint_pyx_path = os.path.join(fdint_dir, '_fdint.pyx')
fdint_pxd_path = os.path.join(fdint_dir, '_fdint.pxd')
bases = [
    '_fd',
    '_fd_whole',
    '_vfd',

    '_dfd',
    '_vdfd',

    '_ifd',
    '_vifd',

    '_gfd',
    '_vgfd',

    '_dgfd',
    '_vdgfd',

    '_nonparabolic',
    '_vnonparabolic',

    '_dnonparabolic',
    '_vdnonparabolic',
    ]


with open(fdint_pyx_path, 'w') as f:
    f.write("""# Copyright (c) 2015, <NAME>. All rights reserved.
# Use of this source code is governed by the BSD-3-Clause
# license that can be found in the LICENSE file.

# This file was generated by `scripts/gen__fdint.py`.
# Do not edit this file directly, or your changes will be lost.
'''
Precise and fast Fermi-Dirac integrals of integer and half integer order.
    
[1] <NAME>, "Precise and fast computation of Fermi-Dirac integral of
    integer and half integer order by piecewise minimax rational approximation,"
    Applied Mathematics and Computation, vol. 259, pp. 708-729, May 2015.
    DOI: 10.1016/j.amc.2015.03.009

[2] <NAME>, "Precise and fast computation of inverse Fermi-Dirac
    integral of order 1/2 by minimax rational function approximation,"
    Applied Mathematics and Computation, vol. 259, pp. 698-707, May 2015.
    DOI: 10.1016/j.amc.2015.03.015
    
[3] <NAME>, "Precise and fast computation of generalized Fermi-Dirac
    integral by parameter polynomial approximation," 2014.
    DOI: 10.13140/2.1.1094.6566

Almost all of the low-level functions for this package are contained in this
module in order to take advantage of inlining.
'''
""")
    f.write('cimport cython\n')
    f.write('from libc.math cimport exp, log, sqrt\n')
    f.write('cimport numpy as np\n')
    f.write('import numpy\n')
    f.write('import warnings\n')
    f.write('\n')

    for base in bases:
        path = os.path.join(fdint_dir, base+'.pyx')
        with open(path, 'r') as fin:
            for line in fin:
                f.write(line)
        os.remove(path)

with open(fdint_pxd_path, 'w') as f:
    f.write('cimport numpy as np\n')
    
    for base in bases:
        path = os.path.join(fdint_dir, base+'.pxd')
        with open(path, 'r') as fin:
            for line in fin:
                f.write(line)
        os.remove(path)
# Copyright (c) 2015, <NAME>. All rights reserved. # Use of this source code is governed by the BSD-3-Clause # license that can be found in the LICENSE file. Combine everything into `_fdint.pyx` and `_fdint.pxd`, in order to take advantage of inlining. # Copyright (c) 2015, <NAME>. All rights reserved. # Use of this source code is governed by the BSD-3-Clause # license that can be found in the LICENSE file.  # This file was generated by `scripts/gen__fdint.py`. # Do not edit this file directly, or your changes will be lost. ''' Precise and fast Fermi-Dirac integrals of integer and half integer order.      [1] <NAME>, "Precise and fast computation of Fermi-Dirac integral of     integer and half integer order by piecewise minimax rational approximation,"     Applied Mathematics and Computation, vol. 259, pp. 708-729, May 2015.     DOI: 10.1016/j.amc.2015.03.009  [2] <NAME>, "Precise and fast computation of inverse Fermi-Dirac     integral of order 1/2 by minimax rational function approximation,"     Applied Mathematics and Computation, vol. 259, pp. 698-707, May 2015.     DOI: 10.1016/j.amc.2015.03.015      [3] <NAME>, "Precise and fast computation of generalized Fermi-Dirac     integral by parameter polynomial approximation," 2014.     DOI: 10.13140/2.1.1094.6566  Almost all of the low-level functions for this package are contained in this module in order to take advantage of inlining. '''