MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / cross_product

Function cross_product

examples/pde/bhrt.cpp:165–179  ·  view source on GitHub ↗

* @brief Computes the cross_product of two euclidean vectors * * @param lhs * @param rhs * @return af::array */

Source from the content-addressed store, hash-verified

163 * @return af::array
164 */
165af::array cross_product(const af::array& lhs, const af::array& rhs) {
166 if (lhs.dims() != rhs.dims())
167 throw make_error("Arrays must have the same dimensions");
168 else if (lhs.dims()[0] != 3)
169 throw make_error("Arrays must have 3 principal coordintes");
170
171 return af::join(
172 0,
173 lhs(1, af::span, af::span) * rhs(2, af::span, af::span) -
174 lhs(2, af::span, af::span) * rhs(1, af::span, af::span),
175 lhs(2, af::span, af::span) * rhs(0, af::span, af::span) -
176 lhs(0, af::span, af::span) * rhs(2, af::span, af::span),
177 lhs(0, af::span, af::span) * rhs(1, af::span, af::span) -
178 lhs(1, af::span, af::span) * rhs(0, af::span, af::span));
179}
180
181/**
182 * @brief Transform the position vectors from cartesian to spherical coordinates

Callers 1

CameraMethod · 0.85

Calls 3

make_errorFunction · 0.85
joinFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected