1#ifndef TATOOINE_TENSOR_OPERATIONS_H
2#define TATOOINE_TENSOR_OPERATIONS_H
4#if TATOOINE_BLAS_AND_LAPACK_AVAILABLE
30template <
typename Tensor0,
typename Tensor1,
typename T0,
typename T1,
37template <
typename Tensor,
typename TensorT, std::size_t... Dims>
40 [](
auto const& component) {
return gcem::abs(component); }, t);
44template <
typename Tensor0,
typename Tensor1,
typename T0,
typename T1,
52template <
typename Tensor0,
typename Tensor1,
typename T0,
typename T1,
56 return gcem::min(
angle(v0, v1),
angle(v0, -v1));
60template <
typename Tensor0,
typename Tensor1,
typename T0,
typename T1,
64 return gcem::max(
angle(v0, v1),
angle(v0, -v1));
68template <
typename Tensor0,
typename Tensor1,
typename Tensor2,
typename T0,
69 typename T1,
typename T2, std::size_t N>
77template <
typename Tensor0,
typename Tensor1,
typename Tensor2,
typename T0,
78 typename T1,
typename T2, std::size_t N>
85template <
typename Tensor,
typename T, std::size_t... Dims>
87 auto m = std::numeric_limits<T>::max();
88 t.
for_indices([&](
auto const... is) { m = gcem::min(m, t(is...)); });
92template <
typename Tensor,
typename T, std::size_t... Dims>
94 auto m = -std::numeric_limits<T>::max();
95 t.
for_indices([&](
auto const... is) { m = gcem::max(m, t(is...)); });
99template <
typename Tensor,
typename T, std::
size_t N>
102 if (gcem::abs(l) < 1e-13) {
109template <
typename Tensor,
typename T, std::
size_t VecDim>
112 for (std::size_t i = 0; i < VecDim; ++i) {
118template <
typename Tensor0,
typename T0,
typename Tensor1,
typename T1,
123 for (std::size_t i = 0; i < N; ++i) {
124 d += lhs(i) * rhs(i);
129template <
typename T0,
typename T1>
135template <
typename Tensor,
typename TensorT, std::size_t... Dims>
138 [](
auto const& component) {
return gcem::sqrt(component); }, t);
143 [](
auto const& c) {
return gcem::sqrt(c); },
144 std::forward<decltype(t)>(t));
Definition: tensor_concepts.h:17
Definition: algorithm.h:6
typename common_type_impl< Ts... >::type common_type
Definition: common_type.h:23
void normal(base_tensor< Tensor, GiNaC::ex, Dims... > &m)
Definition: tensor_symbolic.h:75
constexpr auto min_angle(base_tensor< Tensor0, T0, N > const &v0, base_tensor< Tensor1, T1, N > const &v1)
Returns the angle of two normalized vectors.
Definition: tensor_operations.h:54
constexpr auto abs(arithmetic auto const x)
Definition: math.h:26
constexpr auto cos_angle(base_tensor< Tensor0, T0, N > const &v0, base_tensor< Tensor1, T1, N > const &v1)
Returns the cosine of the angle of two normalized vectors.
Definition: tensor_operations.h:32
tensor< real_number, Dimensions... > Tensor
Definition: tensor.h:184
constexpr auto euclidean_length(base_tensor< Tensor, T, N > const &t_in) -> T
Definition: length.h:12
constexpr auto normalize(base_tensor< Tensor, T, N > const &t_in) -> vec< T, N >
Definition: tensor_operations.h:100
constexpr auto max(A &&a, B &&b)
Definition: math.h:20
constexpr auto unary_operation(invocable< tatooine::value_type< Tensor > > auto &&op, Tensor const &t)
Definition: unary_operation.h:9
constexpr auto dot(base_tensor< Tensor0, T0, N > const &lhs, base_tensor< Tensor1, T1, N > const &rhs)
Definition: tensor_operations.h:120
constexpr auto min(A &&a, B &&b)
Definition: math.h:15
constexpr auto sum(base_tensor< Tensor, T, VecDim > const &v)
sum of all components of a vector
Definition: tensor_operations.h:110
constexpr auto sqrt(arithmetic auto const x)
Definition: math.h:29
constexpr auto angle(base_tensor< Tensor0, T0, N > const &v0, base_tensor< Tensor1, T1, N > const &v1)
Returns the angle of two normalized vectors.
Definition: tensor_operations.h:46
constexpr auto max_angle(base_tensor< Tensor0, T0, N > const &v0, base_tensor< Tensor1, T1, N > const &v1)
Returns the angle of two normalized vectors.
Definition: tensor_operations.h:62
constexpr auto reflect(vec< T0, 3 > const &incidentVec, vec< T1, 3 > const &normal)
Definition: tensor_operations.h:130
Definition: base_tensor.h:23
static auto constexpr for_indices(invocable< decltype(Dims)... > auto &&f)
Definition: base_tensor.h:58
static auto constexpr zeros()
Definition: vec.h:26