Tatooine
determinant.h
Go to the documentation of this file.
1#ifndef TATOOINE_TENSOR_OPERATIONS_DETERMINANT_H
2#define TATOOINE_TENSOR_OPERATIONS_DETERMINANT_H
3//==============================================================================
4namespace tatooine {
5//==============================================================================
6template <typename Tensor, typename T>
7constexpr auto det(base_tensor<Tensor, T, 2, 2> const& A) -> T {
8 return A(0, 0) * A(1, 1) - A(0, 1) * A(1, 0);
9}
10//------------------------------------------------------------------------------
11template <typename Tensor, typename T>
12constexpr auto detAtA(base_tensor<Tensor, T, 2, 2> const& A) -> T {
13 return A(0, 0) * A(0, 0) * A(1, 1) * A(1, 1) -
14 2 * A(0, 0) * A(0, 1) * A(1, 0) * A(1, 1) +
15 A(0, 1) * A(0, 1) * A(1, 0) * A(1, 0);
16}
17// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
18template <typename Tensor, typename T>
19constexpr auto det(base_tensor<Tensor, T, 3, 3> const& A) -> T {
20 return (A(0, 0) * A(1, 1) - A(0, 1) * A(1, 0)) * A(2, 2) +
21 (A(0, 2) * A(1, 0) - A(0, 0) * A(1, 2)) * A(2, 1) +
22 (A(0, 1) * A(1, 2) - A(0, 2) * A(1, 1)) * A(2, 0);
23}
24//==============================================================================
25} // namespace tatooine
26//==============================================================================
27#endif
Definition: algorithm.h:6
constexpr auto detAtA(base_tensor< Tensor, T, 2, 2 > const &A) -> T
Definition: determinant.h:12
constexpr auto det(base_tensor< Tensor, T, 2, 2 > const &A) -> T
Definition: determinant.h:7
Definition: base_tensor.h:23