Giter Site home page Giter Site logo

fdint's People

Contributors

scott-maddox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fdint's Issues

Compatible with python 3.10 but not 3.11

clang throws the following error during compilation:

fdint/_fdint.c:106304:15: error: too few arguments to function call, expected 17, have 15
    py_code = __Pyx_PyCode_New(
              ^~~~~~~~~~~~~~~~~
fdint/_fdint.c:78:83: note: expanded from macro '__Pyx_PyCode_New'
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
          ~~~~~~~~~~                                                              ^
/Users/j.fischbach/Documents/pd-tcad/env/include/python3.11/cpython/code.h:148:28: note: 'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
                           ^
fdint/_fdint.c:106347:13: error: incomplete definition of type 'struct _frame'
    py_frame->f_lineno = py_line;
    ~~~~~~~~^
/Users/j.fischbach/Documents/pd-tcad/env/include/python3.11/pytypedefs.h:22:16: note: forward declaration of 'struct _frame'
typedef struct _frame PyFrameObject;

Support Cython-free installation

By providing the generated C code in the source distribution and altering setup.py, it should be possible for people to build and install without Cython. Numpy will still be required, though, since the build process links to Numpy's header files.

Cython directive 'language_level' not set

Compile procedure returns the warning:
/usr/lib/python3/dist-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /<<PKGBUILDDIR>>/fdint/_fdint.pxd

To avoid it:
--- a/setup.py
+++ b/setup.py
@@ -84,7 +85,8 @@ metadata = dict(
)
.
if USE_CYTHON:
- metadata['ext_modules'] = cythonize(extensions)
+ metadata['ext_modules'] = cythonize(extensions,
+ compiler_directives={'language_level' : "3"})
else:
metadata['ext_modules'] = no_cythonize(extensions)

Repo state?

Is this project looking for maintainers? It seems unmaintained so would be great to assign a new maintainer or mark it as public archive.

for full numpy compatibility: vectorized functions

Thanks for a great plugin! This is very useful.

For ultimate smoothness with the numpy philosphy, it would be great if the fd* functions would operate elementwise over the input arrays including broadcasting, much in the way of functions in the scipy.special module.

For example, this passes a column 2-vector and row 2-vector to the order-n Bessel function, resulting in a matrix of J_5(1), J_5(2), J_6(1), J_6(2)::

>>> from scipy.special import jn
>>> jn(array([[5],[6]]),array([1,2]))
array([[  2.49757730e-04,   7.03962976e-03],
       [  2.09383380e-05,   1.20242897e-03]])

Currently, this is not directly implemented for the fdint functions, however it can be done by wrapping them with numpy's "vectorize" class.

>>> fdk_vec = numpy.vectorize(fdint.fdk)
>>> fdk_vec(array([[5],[6]]),array([1,2]))
array([[  314.66805418,   817.16312139],
       [ 1920.6214911 ,  5088.14241086]])

This is unfortunately a bit inefficient in that it essentially performs a for loop in python, rather than a for loop in C.

100% test coverage

  • fdk, dfdk, gfdk, dgfdk
  • ifd1h
  • parabolic, dparabolic, iparabolic, dnonparabolic
  • vparabolic, vdparabolic, viparabolic, vdnonparabolic

Further optimize `nonparabolic` and `dnonparabolic`

Most of the functions are currently called twice, so a ~2x speedup should be possible.

An additional ~2x speedup of newton iteration should be possible by calculating nonparabolic and dnonparabolic at the same time, since most of the function calls are the same between the two.

Switch to Cython?

On my system it appears to be ~3x faster. This might be due to using gfortran, which is apparently not as good as the intel fortran compiler. However, Cython might be preferable overall.

Windows 10 install?

I love this package and use it on Linux workstations at work, but would really like to get it working on my Windows laptop. Has anyone successfully installed this on Windows 10? If so, what Python, Numpy, and Scipy did you use?

I've tried it on Anaconda and with just Python 2.7.x with Numpy and Scipy packages from http://www.lfd.uci.edu/~gohlke/pythonlibs/, and both times it fails when calling Microsoft compilers. I have the Microsoft compiler for pythong installed.

*.pxd files are installed in unusual dir

The install procedure gives the warnings:
script did not provide a directory for 'fdint/__init__.pxd' -- installing right in '/<<PKGBUILDDIR>>/debian/python3-fdint/usr'
script did not provide a directory for 'fdint/_fdint.pxd' -- installing right in '/<<PKGBUILDDIR>>/debian/python3-fdint/usr'
script did not provide a directory for 'fdint/scfd.pxd' -- installing right in '/<<PKGBUILDDIR>>/debian/python3-fdint/usr'

As results, lintian gives warns as follows:
W: python3-fdint: file-in-unusual-dir [usr/fdint/__init__.pxd]
W: python3-fdint: file-in-unusual-dir [usr/fdint/_fdint.pxd]
W: python3-fdint: file-in-unusual-dir [usr/fdint/scfd.pxd]

Make access to individual functions easier

They are much faster, as shown by this benchmark:
$ python -m timeit -s "from fdint import _fd; import numpy; x=numpy.linspace(-100,100,1000)" "_fd.fd1h(x)"
1000000 loops, best of 3: 0.29 usec per loop
$ python -m timeit -s "from fdint import fdk; import numpy; x=numpy.linspace(-100,100,1000)" "fdk(0.5, x)"
100000 loops, best of 3: 15.2 usec per loop

extended precision/calling from C/C++

Hi,

Is it possible to get these routines in 128 floating point precision?

I am new to cython, is there a good tutorial on how to compile your work (or cython in general) so it is callable from C/C++?

Regards,

Juan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.