MCPcopy Create free account
hub / github.com/SINGROUP/dscribe / distancesNumpy

Function distancesNumpy

dscribe/ext/geometry.cpp:143–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143py::array_t<double> distancesNumpy(py::detail::unchecked_reference<double, 2> &positions_u)
144{
145 int n_atoms = positions_u.shape(0);
146 py::array_t<double> distances({n_atoms, n_atoms});
147 auto distances_mu = distances.mutable_unchecked<2>();
148 for (int i = 0; i < n_atoms; ++i) {
149 for (int j = i; j < n_atoms; ++j) {
150 double dx = positions_u(i, 0) - positions_u(j, 0);
151 double dy = positions_u(i, 1) - positions_u(j, 1);
152 double dz = positions_u(i, 2) - positions_u(j, 2);
153 double distance = sqrt(dx*dx + dy*dy + dz*dz);
154 distances_mu(i, j) = distance;
155 distances_mu(j, i) = distance;
156 }
157 }
158 return distances;
159}
160
161MatrixXd distancesEigen(py::detail::unchecked_reference<double, 2> &positions_u)
162{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected