Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose C distance backend in libmdanalysis.pxd #4342

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The rules for this file:

-------------------------------------------------------------------------------
??/??/?? IAlibay, ianmkenney, PicoCentauri, pgbarletta, p-j-smith,
richardjgowers, lilyminium, ALescoulie
richardjgowers, lilyminium, ALescoulie, hmacdope

* 2.7.0

Expand All @@ -30,6 +30,8 @@ Fixes
* Fix atom charge reading in PDBQT parser (Issue #4282, PR #4283)

Enhancements
* Refactor c_distances backend to have a cython .pxd header and expose in
libmdanalysis (Issue #4315, PR #4324)
* Add faster nucleic acid Major and Minor pair distance calculators using
AnalysisBase for updated nucleicacids module (Issue #3720, PR #3735)
* Adds external sidebar links (Issue #4296)
Expand Down
29 changes: 29 additions & 0 deletions package/MDAnalysis/lib/c_distances.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from libc.stdint cimport uint64_t, UINT64_MAX


cdef extern from "string.h":
void* memcpy(void* dst, void* src, int len)

cdef extern from "calc_distances.h":
ctypedef float coordinate[3]
cdef bint USED_OPENMP
void _calc_distance_array(coordinate* ref, uint64_t numref, coordinate* conf, uint64_t numconf, double* distances)
void _calc_distance_array_ortho(coordinate* ref, uint64_t numref, coordinate* conf, uint64_t numconf, float* box, double* distances)
void _calc_distance_array_triclinic(coordinate* ref, uint64_t numref, coordinate* conf, uint64_t numconf, float* box, double* distances)
void _calc_self_distance_array(coordinate* ref, uint64_t numref, double* distances)
void _calc_self_distance_array_ortho(coordinate* ref, uint64_t numref, float* box, double* distances)
void _calc_self_distance_array_triclinic(coordinate* ref, uint64_t numref, float* box, double* distances)
void _coord_transform(coordinate* coords, uint64_t numCoords, double* box)
void _calc_bond_distance(coordinate* atom1, coordinate* atom2, uint64_t numatom, double* distances)
void _calc_bond_distance_ortho(coordinate* atom1, coordinate* atom2, uint64_t numatom, float* box, double* distances)
void _calc_bond_distance_triclinic(coordinate* atom1, coordinate* atom2, uint64_t numatom, float* box, double* distances)
void _calc_angle(coordinate* atom1, coordinate* atom2, coordinate* atom3, uint64_t numatom, double* angles)
void _calc_angle_ortho(coordinate* atom1, coordinate* atom2, coordinate* atom3, uint64_t numatom, float* box, double* angles)
void _calc_angle_triclinic(coordinate* atom1, coordinate* atom2, coordinate* atom3, uint64_t numatom, float* box, double* angles)
void _calc_dihedral(coordinate* atom1, coordinate* atom2, coordinate* atom3, coordinate* atom4, uint64_t numatom, double* angles)
void _calc_dihedral_ortho(coordinate* atom1, coordinate* atom2, coordinate* atom3, coordinate* atom4, uint64_t numatom, float* box, double* angles)
void _calc_dihedral_triclinic(coordinate* atom1, coordinate* atom2, coordinate* atom3, coordinate* atom4, uint64_t numatom, float* box, double* angles)
void _ortho_pbc(coordinate* coords, uint64_t numcoords, float* box)
void _triclinic_pbc(coordinate* coords, uint64_t numcoords, float* box)
void minimum_image(double* x, float* box, float* inverse_box)
void minimum_image_triclinic(float* x, float* box, float* inverse_box)
26 changes: 0 additions & 26 deletions package/MDAnalysis/lib/c_distances.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,6 @@ from libc.float cimport FLT_MAX, DBL_MAX
# make UINT64_MAX visible at the python layer
_UINT64_MAX = UINT64_MAX

cdef extern from "string.h":
void* memcpy(void* dst, void* src, int len)

cdef extern from "calc_distances.h":
ctypedef float coordinate[3]
cdef bint USED_OPENMP
void _calc_distance_array(coordinate* ref, uint64_t numref, coordinate* conf, uint64_t numconf, double* distances)
void _calc_distance_array_ortho(coordinate* ref, uint64_t numref, coordinate* conf, uint64_t numconf, float* box, double* distances)
void _calc_distance_array_triclinic(coordinate* ref, uint64_t numref, coordinate* conf, uint64_t numconf, float* box, double* distances)
void _calc_self_distance_array(coordinate* ref, uint64_t numref, double* distances)
void _calc_self_distance_array_ortho(coordinate* ref, uint64_t numref, float* box, double* distances)
void _calc_self_distance_array_triclinic(coordinate* ref, uint64_t numref, float* box, double* distances)
void _coord_transform(coordinate* coords, uint64_t numCoords, double* box)
void _calc_bond_distance(coordinate* atom1, coordinate* atom2, uint64_t numatom, double* distances)
void _calc_bond_distance_ortho(coordinate* atom1, coordinate* atom2, uint64_t numatom, float* box, double* distances)
void _calc_bond_distance_triclinic(coordinate* atom1, coordinate* atom2, uint64_t numatom, float* box, double* distances)
void _calc_angle(coordinate* atom1, coordinate* atom2, coordinate* atom3, uint64_t numatom, double* angles)
void _calc_angle_ortho(coordinate* atom1, coordinate* atom2, coordinate* atom3, uint64_t numatom, float* box, double* angles)
void _calc_angle_triclinic(coordinate* atom1, coordinate* atom2, coordinate* atom3, uint64_t numatom, float* box, double* angles)
void _calc_dihedral(coordinate* atom1, coordinate* atom2, coordinate* atom3, coordinate* atom4, uint64_t numatom, double* angles)
void _calc_dihedral_ortho(coordinate* atom1, coordinate* atom2, coordinate* atom3, coordinate* atom4, uint64_t numatom, float* box, double* angles)
void _calc_dihedral_triclinic(coordinate* atom1, coordinate* atom2, coordinate* atom3, coordinate* atom4, uint64_t numatom, float* box, double* angles)
void _ortho_pbc(coordinate* coords, uint64_t numcoords, float* box)
void _triclinic_pbc(coordinate* coords, uint64_t numcoords, float* box)
void minimum_image(double* x, float* box, float* inverse_box)
void minimum_image_triclinic(float* x, float* box, float* inverse_box)

OPENMP_ENABLED = True if USED_OPENMP else False

Expand Down
1 change: 1 addition & 0 deletions package/MDAnalysis/lib/libmdanalysis/__init__.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from ..coordinates cimport timestep
from .formats cimport libmdaxdr
from .formats cimport libdcd
from . cimport c_distances
Loading