C2DLL
Easily build C code into dll and call it from python script
Here is the example of usage:
from c2dll import dllfunc, as_ptr
import numpy as np
def fwd(eps, n, x=[0.1711, 0.1117]):
d = dllfunc('''
#define PI2 6.283185307179586
#include <math.h>
double mod1(double x) {double x_mod_1 = fmod(x, 1); x_mod_1 = (x_mod_1 < 0) ? x_mod_1 + 1 : x_mod_1; return x_mod_1;}
DLL_API void fwd(double* params, double* x, int n, double* out) {
double eps_square = params[0]*params[0];
for (int i=0; i<n; i++) {
double x_ = atan2((1 - eps_square) * sin(PI2 * x[0]), (1 + eps_square) * cos(PI2 * x[0]) + 2*params[0]) / PI2;
x[0] = 2 * x_ + x[1];
x[1] = x_ + x[1];
x[0] = atan2((1 - eps_square) * sin(PI2 * x[0]), (1 + eps_square) * cos(PI2 * x[0]) + 2*params[0]) / PI2;
x[0] = mod1(x[0]);
x[1] = mod1(x[1]);
out[2*i] = x[0];
out[2*i+1] = x[1];
}
}''')
n = int(n)
points = np.zeros(shape=(2*n))
d.fwd(as_ptr([eps,]), as_ptr(x), n, as_ptr(points))
return points.reshape((n, 2))
GitHub: https://github.com/chiga17/c2dll
Metadata
Release files for c2dll 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| c2dll-0.1.0.tar.gz | 3.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| c2dll-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.7 kB
Release files / c2dll-0.1.0.tar.gz
| Download URL | c2dll-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c31f487e47a975afc70c2b09858113543ababe1f6f3568d1847e41025e5f086
|
|
BLAKE2b-256 checksum How to use checksums |
e7dccf7c6f7eb8fa6fe42b12f9796445bedf4c87c65ea0e2c539834bf2e66668
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.0
|
Release files / c2dll-0.1.0-py3-none-any.whl
| Download URL | c2dll-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a76dbbe9de46eb98cee6d98bd9fd3a6437c44a6fc79b2355d662ac018e08fc7b
|
|
BLAKE2b-256 checksum How to use checksums |
04a01db1bc7f1b7b2fd1c201c9c5fdc415f946154422dc876204e6ef2b9c2570
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.0
|
Security for c2dll 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.