Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 :
8 : #include "DataStructures/Tensor/Tensor.hpp"
9 : #include "Utilities/MakeWithValue.hpp"
10 :
11 : /// \ingroup TensorGroup
12 : /// \brief returns the Identity matrix
13 : template <size_t Dim, typename DataType>
14 1 : tnsr::Ij<DataType, Dim, Frame::NoFrame> identity(
15 : const DataType& used_for_type) {
16 : auto identity_matrix{make_with_value<tnsr::Ij<DataType, Dim, Frame::NoFrame>>(
17 : used_for_type, 0.0)};
18 :
19 : for (size_t i = 0; i < Dim; ++i) {
20 : identity_matrix.get(i, i) = 1.0;
21 : }
22 : return identity_matrix;
23 : }
|