Tatooine
cross.h
Go to the documentation of this file.
1#ifndef TATOOINE_TENSOR_OPERATIONS_CROSS_H
2#define TATOOINE_TENSOR_OPERATIONS_CROSS_H
3//==============================================================================
4#include <tatooine/vec.h>
5//==============================================================================
6namespace tatooine {
7//==============================================================================
8template <typename Tensor0, typename T0, typename Tensor1, typename T1>
9constexpr auto cross(base_tensor<Tensor0, T0, 3> const& lhs,
10 base_tensor<Tensor1, T1, 3> const& rhs) {
11 return vec<common_type<T0, T1>, 3>{lhs(1) * rhs(2) - lhs(2) * rhs(1),
12 lhs(2) * rhs(0) - lhs(0) * rhs(2),
13 lhs(0) * rhs(1) - lhs(1) * rhs(0)};
14}
15//==============================================================================
16template <typename T0, typename T1>
17constexpr auto cross(tensor<T0> const& lhs,
18 tensor<T1> const& rhs) {
19 return tensor<common_type<T0, T1>>{lhs(1) * rhs(2) - lhs(2) * rhs(1),
20 lhs(2) * rhs(0) - lhs(0) * rhs(2),
21 lhs(0) * rhs(1) - lhs(1) * rhs(0)};
22}
23//==============================================================================
24} // namespace tatooine
25//==============================================================================
26#endif
Definition: algorithm.h:6
constexpr auto cross(base_tensor< Tensor0, T0, 3 > const &lhs, base_tensor< Tensor1, T1, 3 > const &rhs)
Definition: cross.h:9
Definition: base_tensor.h:23
Definition: tensor.h:17
Definition: vec.h:12