For the API
but not for the speed
auto arc_distance(xtensor<double, 1>& theta_1, xtensor<double, 1>& phi_1,
xtensor<double, 1>& theta_2, xtensor<double, 1>& phi_2)
{
xtensor<double, 1> temp = pow(sin((theta_2 - theta_1) / 2), 2) + cos(theta_1) *
cos(theta_2) * pow(sin((phi_2 - phi_1) / 2), 2);
xtensor<double, 1> distance_matrix = 2 * (atan2(sqrt(temp), sqrt(1 - temp)));
return distance_matrix;
}
def arc_distance(theta_1, phi_1, theta_2, phi_2):
temp = np.sin((theta_2 - theta_1) / 2) ** 2 + np.cos(theta_1) * \
np.cos(theta_2) * np.sin((phi_2 - phi_1) / 2) ** 2
distance_matrix = 2 * (np.arctan2(np.sqrt(temp), np.sqrt(1 - temp)))
return distance_matrix
We benchmark a lot
A SCIENTIFIC COMPUTING ECOSYSTEM
What's in a xtensor?
xarray<T, layout_type::row_major>
xtensor<T, 4>
xtensor_fixed<T, xshape<2, 3, 2>>
Flexible data structures: