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 {
26 #ifdef __cpp_concepts
27  template<indexible Arg>
28  constexpr diagonal_matrix decltype(auto)
29 #else
30  template<typename Arg, std::enable_if_t<indexible<Arg>, int> = 0>
31  constexpr decltype(auto)
32 #endif
33  to_diagonal(Arg&& arg)
34  {
35  if constexpr (one_dimensional<Arg>)
36  {
37  return std::forward<Arg>(arg);
38  }
39  else if constexpr (interface::to_diagonal_defined_for<Arg, Arg&&>)
40  {
42  }
43  else
44  {
45  return diagonal_adapter {std::forward<Arg>(arg)};
46  }
47  }
48 
49 
50 }
51 
52 #endif
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:33
The root namespace for OpenKalman.
Definition: basics.hpp:34
An adapter for creating a diagonal matrix or tensor.
Definition: diagonal_adapter.hpp:27
An interface to various routines from the linear algebra library associated with indexible object T...
Definition: library_interface.hpp:42