23 #ifndef MATRIX_OPERATION_H
24 #define MATRIX_OPERATION_H
26 #include <boost/numeric/ublas/matrix.hpp>
27 #include <boost/numeric/ublas/matrix_proxy.hpp>
28 #include <boost/numeric/ublas/matrix_sparse.hpp>
30 #include <boost/numeric/ublas/vector.hpp>
40 namespace ublas = boost::numeric::ublas;
47 if (
e.size1() ==
e.size2()) {
48 ublas::matrix_vector_range<ublas::matrix<V> > diag(
e,ublas::range(0,
e.size1()),ublas::range(0,
e.size2()));
52 throw std::length_error(
"Error in function trace() of matrix_vector_operation.h: Wrong matrix dimensions.");
58 template<
class V,
class A>
60 ublas::vector<V, A>
cross_prod(ublas::vector<V, A>& v1, ublas::vector<V, A>& v2) {
61 ublas::vector<V, A> v(v1.size());
62 if (v1.size() == v2.size() && v1.size() == 3) {
63 v(0) = v1(1) * v2(2) - v1(2) * v2(1);
64 v(1) = v1(2) * v2(0) - v1(0) * v2(2);
65 v(2) = v1(0) * v2(1) - v1(1) * v2(0);
68 throw std::length_error(
"Error in function cross_prod() of matrix_vector_operation.h: Wrong vector dimensions.");
76 ublas::matrix<V>
taylor_exp(
const ublas::matrix<V>& F,
const V ds,
const unsigned int order) {
78 ublas::matrix<V> Fn = ublas::identity_matrix<V>(6);
79 ublas::matrix<V> M = Fn;
81 for (
unsigned int k = 1; k < order; ++k) {
90 template<
class M,
class E1,
class E2,
class E3>
92 M
gemmm(
const ublas::matrix_expression<E1>& e1,
const ublas::matrix_expression<E2>& e2,
const ublas::matrix_expression<E3>& e3) {
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
T::PETE_Expr_t::PETE_Return_t prod(const PETE_Expr< T > &expr)
constexpr double e
The value of.
BOOST_UBLAS_INLINE ublas::vector< V, A > cross_prod(ublas::vector< V, A > &v1, ublas::vector< V, A > &v2)
Computes the cross product of two vectors in .
BOOST_UBLAS_INLINE ublas::matrix< V > taylor_exp(const ublas::matrix< V > &F, const V ds, const unsigned int order)
Computes Taylor-Series of M(s) = exp(F*s)
BOOST_UBLAS_INLINE V trace(ublas::matrix< V > &e)
Computes the trace of a square matrix.
BOOST_UBLAS_INLINE M gemmm(const ublas::matrix_expression< E1 > &e1, const ublas::matrix_expression< E2 > &e2, const ublas::matrix_expression< E3 > &e3)
Generalized matrix-matrix-matrix multiplication .