10 #ifndef MATRIX_OPERATION_H
11 #define MATRIX_OPERATION_H
13 #include <boost/numeric/ublas/matrix.hpp>
14 #include <boost/numeric/ublas/matrix_proxy.hpp>
15 #include <boost/numeric/ublas/matrix_sparse.hpp>
17 #include <boost/numeric/ublas/vector.hpp>
26 namespace matt_boost {
28 namespace ublas = boost::numeric::ublas;
35 if (e.size1() == e.size2()) {
36 ublas::matrix_vector_range<ublas::matrix<V> > diag(e,ublas::range(0,e.size1()),ublas::range(0,e.size2()));
40 throw std::length_error(
"Error in function trace() of matrix_vector_operation.h: Wrong matrix dimensions.");
48 ublas::vector<V>
cross_prod(ublas::vector<V>& v1, ublas::vector<V>& v2) {
49 ublas::vector<V> v(v1.size());
50 if (v1.size() == v2.size() && v1.size() == 3) {
51 v(0) = v1(1) * v2(2) - v1(2) * v2(1);
52 v(1) = v1(2) * v2(0) - v1(0) * v2(2);
53 v(2) = v1(0) * v2(1) - v1(1) * v2(0);
56 throw std::length_error(
"Error in function cross_prod() of matrix_vector_operation.h: Wrong vector dimensions.");
64 ublas::matrix<V>
taylor_exp(
const ublas::matrix<V>& F,
const V ds,
const unsigned int order) {
66 ublas::matrix<V> Fn = ublas::identity_matrix<V>(6);
67 ublas::matrix<V> M = Fn;
69 for (
unsigned int k = 1; k < order; ++k) {
78 template<
class M,
class E1,
class E2,
class E3>
80 M
gemmm(
const ublas::matrix_expression<E1>& e1,
const ublas::matrix_expression<E2>& e2,
const ublas::matrix_expression<E3>& e3) {
constexpr double e
The value of .
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
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.
T::PETE_Expr_t::PETE_Return_t prod(const PETE_Expr< T > &expr)
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 .
BOOST_UBLAS_INLINE ublas::vector< V > cross_prod(ublas::vector< V > &v1, ublas::vector< V > &v2)
Computes the cross product of two vectors in .