scott-maddox / fdint Goto Github PK
View Code? Open in Web Editor NEWPrecise and fast Fermi-Dirac integrals of integer and half integer order.
License: BSD 3-Clause "New" or "Revised" License
Precise and fast Fermi-Dirac integrals of integer and half integer order.
License: BSD 3-Clause "New" or "Revised" License
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;
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.
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)
Is this project looking for maintainers? It seems unmaintained so would be great to assign a new maintainer or mark it as public archive.
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.
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.
fdint.get_include()
Also incorporate them into gfdm1h
, gfd1h
, gfd3h
, gfd5h
, nonparabolic
, and the corresponding deriviatives.
i.e. F(phi, alpha), where alpha is the nonparabolicity parameter of a compound III-V zinc blende semiconductor
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.
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.
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]
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.