Identity.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
10 
11 /// \ingroup TensorGroup
12 /// \brief returns the Identity matrix
13 template <size_t Dim, typename DataType>
14 tnsr::Ij<DataType, Dim, Frame::NoFrame> identity(
15  const DataType& used_for_type) noexcept {
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 }
Defines classes for Tensor.
tnsr::Ij< DataType, Dim, Frame::NoFrame > identity(const DataType &used_for_type) noexcept
returns the Identity matrix
Definition: Identity.hpp:14
Defines make_with_value.