* @brief Computes the dot product as defined by a metric between two 4-vector * velocities * * @param pos * @param lhs * @param rhs * @return af::array */
| 544 | * @return af::array |
| 545 | */ |
| 546 | af::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 | |
| 561 | af::array norm4(const af::array& pos, const af::array& vel) { |
| 562 | return dot_product(pos, vel, vel); |