OpenKalman
conjugate.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-2026 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_CONJUGATE_HPP
17 #define OPENKALMAN_CONJUGATE_HPP
18 
19 #include "values/values.hpp"
29 #include "linear-algebra/functions/internal/make_wrapped_mdspan.hpp"
31 
32 namespace OpenKalman
33 {
38 #ifdef __cpp_concepts
39  template<indexible Arg>
40 #else
41  template<typename Arg, std::enable_if_t<indexible<Arg>, int> = 0>
42 #endif
43  constexpr decltype(auto)
44  conjugate(Arg&& arg)
45  {
47  {
48  return std::forward<Arg>(arg);
49  }
50  else if constexpr (interface::conjugate_defined_for<Arg&&>)
51  {
53  }
54  else if constexpr (constant_object<Arg>)
55  {
56  return make_constant(values::conj(constant_value(arg)), get_pattern_collection(std::forward<Arg>(arg)));
57  }
58  else if constexpr (constant_diagonal_object<Arg>)
59  {
60  return make_constant_diagonal(values::conj(constant_value(arg)), get_pattern_collection(std::forward<Arg>(arg)));
61  }
62  else if constexpr (diagonal_matrix<Arg>)
63  {
64  return to_diagonal(conjugate(diagonal_of(std::forward<Arg>(arg))));
65  }
66  else
67  {
68  auto n = get_mdspan(arg);
69  using nested_accessor = typename std::decay_t<decltype(n)>::accessor_type;
70  using accessor_type = stdex::linalg::conjugated_accessor<nested_accessor>;
71  return internal::make_wrapped_mdspan(
72  std::forward<Arg>(arg),
74  n.mapping(),
75  accessor_type(n.accessor()),
77  }
78  }
79 
80 
81 }
82 
83 #endif
Definition: language-features.hpp:228
Definition for constant_object.
Header file for code relating to values (e.g., scalars and indices)
decltype(auto) constexpr conjugate(Arg &&arg)
Take the complex conjugate of an indexible object.
Definition: conjugate.hpp:44
Definition for constant_diagonal_object.
constexpr bool complex
T is a value that reduces to std::complex or a custom complex type.
Definition: complex.hpp:47
decltype(auto) constexpr get_pattern_collection(T &&t)
Get the patterns::pattern_collection associated with indexible object T.
Definition: get_pattern_collection.hpp:36
constexpr bool not_complex
T is a value in which either its type is not complex or its imaginary component is 0...
Definition: not_complex.hpp:48
Definition for diagonal_matrix.
constexpr auto make_constant_diagonal(C c, P &&p)
Make an indexible object in which every diagonal element is a constant value.
Definition: make_constant_diagonal.hpp:40
Definition for element_type_of.
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:42
decltype(auto) constexpr diagonal_of(Arg &&arg)
Extract a column vector (or column slice for rank>2 tensors) comprising the diagonal elements...
Definition: diagonal_of.hpp:44
constexpr auto conj(const Arg &arg)
A constexpr function for the complex conjugate of a (complex) number.
Definition: conj.hpp:39
Definition of get_mdspan function.
constexpr auto make_constant(C c, P &&p)
Make an indexible object in which every element is a constant value.
Definition: make_constant.hpp:41
constexpr auto constant_value(T &&t)
The constant value associated with a constant_object or constant_diagonal_object. ...
Definition: constant_value.hpp:37
Definition of get_pattern_collection function.
Definition for indexible.
The static constant value of an indexible object, if it exists.
Definition: constant_value_of.hpp:31
Definition for constant_value_of.
decltype(auto) constexpr to_diagonal(Arg &&arg, P &&p)
Convert a column vector (or any other array with a 1D second index) into a diagonal_matrix.
Definition: to_diagonal.hpp:46
typename element_type_of< T >::type element_type_of_t
helper template for element_type_of.
Definition: element_type_of.hpp:54
Definitions for make_constant.
Definition for to_diagonal function.
decltype(auto) constexpr get_mdspan(T &&t)
Get the mdspan associated with indexible object T.
Definition: get_mdspan.hpp:35