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

Function dot_product

examples/pde/bhrt.cpp:546–559  ·  view source on GitHub ↗

* @brief Computes the dot product as defined by a metric between two 4-vector * velocities * * @param pos * @param lhs * @param rhs * @return af::array */

Source from the content-addressed store, hash-verified

544 * @return af::array
545 */
546af::array dot_product(const af::array& pos, const af::array& lhs,
547 const af::array& rhs) {
548 if (pos.dims() != lhs.dims())
549 throw make_error(
550 "Position and lhs velocity must have the same dimensions");
551 else if (lhs.dims() != rhs.dims())
552 throw make_error(
553 "Position and rhs velocity must have the same dimensions");
554 else if (rhs.dims()[0] != 4)
555 throw make_error("Arrays must have 4 principal coordinates");
556
557 return af::matmul(af::moddims(lhs, 1, 4, lhs.dims()[1]), metric4(pos),
558 af::moddims(rhs, 4, 1, rhs.dims()[1]));
559}
560
561af::array norm4(const af::array& pos, const af::array& vel) {
562 return dot_product(pos, vel, vel);

Callers 1

norm4Function · 0.85

Calls 5

make_errorFunction · 0.85
moddimsFunction · 0.85
metric4Function · 0.85
matmulFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected