sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas_core.hpp
Go to the documentation of this file.
1/*
2# Copyright (c) 2022-2023 Murilo Marques Marinho
3#
4# This file is part of sas_core.
5#
6# sas_core is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Lesser General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# sas_core is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Lesser General Public License for more details.
15#
16# You should have received a copy of the GNU Lesser General Public License
17# along with sas_core. If not, see <https://www.gnu.org/licenses/>.
18#
19# ################################################################
20#
21# Author: Murilo M. Marinho, email: murilomarinho@ieee.org
22#
23# ################################################################*/
33#pragma once
34
35#include <eigen3/Eigen/Dense>
36
37using namespace Eigen;
38
39namespace sas
40{
41
42enum class Statistics{
43 Mean
44};
45
46template<class T>
55constexpr T incremental_mean(const T &current_mean, const int &current_number_of_samples, const T &new_sample)
56{
57 if(current_number_of_samples<0)
58 throw std::range_error("incremental_mean::current_number_of_samples should be larger than 0");
59 return (current_mean * current_number_of_samples + new_sample)/(current_number_of_samples+1);
60}
61
68VectorXd concatenate(const VectorXd& a, const VectorXd& b);
69
75VectorXd concatenate(const std::vector<VectorXd>& as);
76
83MatrixXd vstack(const MatrixXd& A, const MatrixXd& B);
84
90MatrixXd block_diag(const std::vector<MatrixXd>& As);
91
98std::vector<VectorXd> split(const VectorXd& a, const std::vector<int>& ns);
99
100}
constexpr T incremental_mean(const T &current_mean, const int &current_number_of_samples, const T &new_sample)
incremental_mean a simple implementation of incremental mean, for the many cases in which keeping a v...
Definition sas_core.hpp:55