Tatooine
tensor
include
tatooine
tensor_operations
trace.h
Go to the documentation of this file.
1
#ifndef TATOOINE_TENSOR_OPERATIONS_TRACE_H
2
#define TATOOINE_TENSOR_OPERATIONS_TRACE_H
3
//==============================================================================
4
#include <
tatooine/base_tensor.h
>
5
//==============================================================================
6
namespace
tatooine
{
7
//==============================================================================
8
template
<
typename
Tensor,
typename
T, std::
size_t
N>
9
constexpr
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
base_tensor.h
tatooine
Definition:
algorithm.h:6
tatooine::trace
constexpr auto trace(base_tensor< Tensor, T, N, N > const &A)
Definition:
trace.h:9
tatooine::base_tensor
Definition:
base_tensor.h:23
Generated by
1.9.5