From abc6849f21a3c68b4438e3958f3221f184ede643 Mon Sep 17 00:00:00 2001 From: kleeman Date: Tue, 13 Oct 2020 14:22:22 -0700 Subject: [PATCH] Add the ability to extract a child covariance function from a composed function --- .../covariance_function.hpp | 8 ++ .../albatross/src/utils/covariance_utils.hpp | 73 +++++++++++++++++++ tests/test_covariance_functions.cc | 70 ++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 include/albatross/src/utils/covariance_utils.hpp diff --git a/include/albatross/src/covariance_functions/covariance_function.hpp b/include/albatross/src/covariance_functions/covariance_function.hpp index dc181ab6..770478f7 100644 --- a/include/albatross/src/covariance_functions/covariance_function.hpp +++ b/include/albatross/src/covariance_functions/covariance_function.hpp @@ -305,6 +305,10 @@ class SumOfCovarianceFunctions return this->rhs_.state_space_representation(xs); } + LHS get_lhs() const { return lhs_; } + + RHS get_rhs() const { return rhs_; } + protected: LHS lhs_; RHS rhs_; @@ -403,6 +407,10 @@ class ProductOfCovarianceFunctions return this->rhs_.state_space_representation(xs); } + LHS get_lhs() const { return lhs_; } + + RHS get_rhs() const { return rhs_; } + protected: LHS lhs_; RHS rhs_; diff --git a/include/albatross/src/utils/covariance_utils.hpp b/include/albatross/src/utils/covariance_utils.hpp new file mode 100644 index 00000000..6c2c69d0 --- /dev/null +++ b/include/albatross/src/utils/covariance_utils.hpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2020 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef INCLUDE_ALBATROSS_SRC_UTILS_COVARIANCE_UTILS_HPP_ +#define INCLUDE_ALBATROSS_SRC_UTILS_COVARIANCE_UTILS_HPP_ + +namespace albatross { + +namespace details { + +template struct cov_func_contains { + const static bool value = false; +}; + +template struct cov_func_contains { + const static bool value = true; +}; + +template class Composite, typename LHS, + typename RHS> +struct cov_func_contains> { + const static bool value = cov_func_contains::value || + cov_func_contains::value; +}; + +template struct GetChildImpl { + template ::value, int> = 0> + static Child get_child(const Parent &parent) { + return parent; + } +}; + +template struct GetChildIdentity { typedef T type; }; + +template