Bayes Filters Library
src
BayesFilters
src
directional_statistics.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2016-2019 Istituto Italiano di Tecnologia (IIT)
3
*
4
* This software may be modified and distributed under the terms of the
5
* BSD 3-Clause license. See the accompanying LICENSE file for details.
6
*/
7
8
#include <
BayesFilters/directional_statistics.h
>
9
10
#include <cmath>
11
12
using namespace
bfl
;
13
using namespace
bfl::directional_statistics
;
14
using namespace
Eigen;
15
16
17
MatrixXd
bfl::directional_statistics::directional_add
(
const
Ref<const MatrixXd>& a,
const
Ref<const VectorXd>& b)
18
{
19
/* Let M = a.colwise() + b.
20
Then Mij = arg(exp(j * Mij)) where j is the imaginary unit
21
and arg(x) is the phase angle of the complex number x. */
22
return
(std::complex<double>(0.0, 1.0) * (a.colwise() + b)).array().exp().arg();
23
}
24
25
26
MatrixXd
bfl::directional_statistics::directional_sub
(
const
Ref<const MatrixXd>& a,
const
Ref<const VectorXd>& b)
27
{
28
return
directional_add
(a, -b);
29
}
30
31
32
VectorXd
bfl::directional_statistics::directional_mean
(
const
Ref<const MatrixXd>& a,
const
Ref<const VectorXd>& w)
33
{
34
/* If one column only is provided, it is returned as is. */
35
if
(a.cols() == 1)
36
return
a.col(0);
37
38
/* For each row i of the matrix a,
39
the method computes the sum of exponentials sum(w_{k} * e^(j*a_{ik})) where j is the imaginary unit
40
and then extract the phase angle using the method arg(x). */
41
return
((std::complex<double>(0.0, 1.0) * a).array().exp().matrix() * w).array().arg();
42
}
bfl::directional_statistics::directional_mean
Eigen::VectorXd directional_mean(const Eigen::Ref< const Eigen::MatrixXd > &a, const Eigen::Ref< const Eigen::VectorXd > &w)
bfl::directional_statistics::directional_add
Eigen::MatrixXd directional_add(const Eigen::Ref< const Eigen::MatrixXd > &a, const Eigen::Ref< const Eigen::VectorXd > &b)
bfl::directional_statistics::directional_sub
Eigen::MatrixXd directional_sub(const Eigen::Ref< const Eigen::MatrixXd > &a, const Eigen::Ref< const Eigen::VectorXd > &b)
bfl
Port of boost::any for C++11 compilers.
Definition:
AdditiveMeasurementModel.h:13
bfl::directional_statistics
Definition:
directional_statistics.h:16
directional_statistics.h
Generated by
1.8.17