Tatooine
trace.h
Go to the documentation of this file.
1#ifndef TATOOINE_TENSOR_OPERATIONS_TRACE_H
2#define TATOOINE_TENSOR_OPERATIONS_TRACE_H
3//==============================================================================
5//==============================================================================
6namespace tatooine {
7//==============================================================================
8template <typename Tensor, typename T, std::size_t N>
9constexpr auto trace(base_tensor<Tensor, T, N, N> const& A) {
10 auto tr = T{};
11 for (std::size_t i = 0; i < N; ++i) {
12 tr += A(i, i);
13 }
14 return tr;
15}
16//==============================================================================
17} // namespace tatooine
18//==============================================================================
19#endif
Definition: algorithm.h:6
constexpr auto trace(base_tensor< Tensor, T, N, N > const &A)
Definition: trace.h:9
Definition: base_tensor.h:23