OpenKalman
to_diagonal.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2022-2023 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
16 #ifndef OPENKALMAN_TO_DIAGONAL_HPP
17 #define OPENKALMAN_TO_DIAGONAL_HPP
18 
19 namespace OpenKalman
20 {
25 #ifdef __cpp_concepts
26  template<indexible Arg>
27  constexpr diagonal_matrix decltype(auto)
28 #else
29  template<typename Arg, std::enable_if_t<indexible<Arg>, int> = 0>
30  constexpr decltype(auto)
31 #endif
32  to_diagonal(Arg&& arg)
33  {
34  if constexpr (one_dimensional<Arg>)
35  {
36  return std::forward<Arg>(arg);
37  }
38  else if constexpr (interface::to_diagonal_defined_for<Arg, Arg&&>)
39  {
41  }
42  else
43  {
44  return DiagonalAdapter {std::forward<Arg>(arg)};
45  }
46  }
47 
48 
49 } // namespace OpenKalman
50 
51 #endif //OPENKALMAN_TO_DIAGONAL_HPP
constexpr bool diagonal_matrix
Specifies that a type is a diagonal matrix or tensor.
Definition: diagonal_matrix.hpp:32
decltype(auto) constexpr to_diagonal(Arg &&arg)
Convert an indexible object into a diagonal matrix.
Definition: to_diagonal.hpp:32
The root namespace for OpenKalman.
Definition: basics.hpp:34
An interface to various routines from the linear algebra library associated with indexible object T...
Definition: library_interface.hpp:37
An adapter for creating a diagonal matrix or tensor.
Definition: DiagonalAdapter.hpp:27