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
49enum class Statistics{
50 Mean
51};
52
53template<class T>
63constexpr T incremental_mean(const T &current_mean, const int &current_number_of_samples, const T &new_sample)
64{
65 if(current_number_of_samples<0)
66 throw std::range_error("incremental_mean::current_number_of_samples should be larger than 0");
67 return (current_mean * current_number_of_samples + new_sample)/(current_number_of_samples+1);
68}
69
76VectorXd concatenate(const VectorXd& a, const VectorXd& b);
77
83VectorXd concatenate(const std::vector<VectorXd>& as);
84
92MatrixXd vstack(const MatrixXd& A, const MatrixXd& B);
93
99MatrixXd block_diag(const std::vector<MatrixXd>& As);
100
107std::vector<VectorXd> split(const VectorXd& a, const std::vector<int>& ns);
108
109}
Statistics
Statistical measures supported by sas_core utilities.
Definition sas_core.hpp:49
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:63