smooth
A C++ library for Lie theory
Loading...
Searching...
No Matches
Classes | Functions | Variables
lie_sparse.hpp File Reference

Sparse versions of certain Lie group methods. More...

#include <Eigen/Sparse>
#include "detail/utils.hpp"
#include "lie_groups.hpp"
#include "detail/lie_group_sparse_impl.hpp"
Include dependency graph for lie_sparse.hpp:

Go to the source code of this file.

Classes

struct  traits::lie_sparse< G >
 Traits that defines sparsity patterns for various groups. More...
 

Functions

template<LieGroup G>
void ad_sparse (Eigen::SparseMatrix< Scalar< G > > &sp, const Tangent< G > &a)
 Sparse ad.
 
template<LieGroup G, bool Inv = false>
void dr_exp_sparse (Eigen::SparseMatrix< Scalar< G > > &sp, const Tangent< G > &a, Eigen::Index i0=0)
 Sparse dr_exp.
 
template<LieGroup G>
void dr_expinv_sparse (Eigen::SparseMatrix< Scalar< G > > &sp, const Tangent< G > &a, Eigen::Index i0=0)
 Sparse dr_expinv.
 
template<LieGroup G, bool Inv = false>
void d2r_exp_sparse (Eigen::SparseMatrix< Scalar< G > > &sp, const Tangent< G > &a, Eigen::Index i0=0)
 Sparse d2r_exp.
 
template<LieGroup G>
void d2r_expinv_sparse (Eigen::SparseMatrix< Scalar< G > > &sp, const Tangent< G > &a, Eigen::Index i0=0)
 Sparse d2r_expinv.
 

Variables

template<LieGroup G>
std::array< Eigen::SparseMatrix< Scalar< G > >, Dof< G > > generators_sparse
 Generators of lie algebra (inline variable).
 
template<LieGroup G>
Eigen::SparseMatrix< Scalar< G > > ad_sparse_pattern
 Sparsity pattern of ad_sparse (inline variable).
 
template<LieGroup G>
Eigen::SparseMatrix< Scalar< G > > d_exp_sparse_pattern
 Sparsity pattern of dr_exp_sparse, dr_expinv_sparse (inline variable).
 
template<LieGroup G>
Eigen::SparseMatrix< Scalar< G > > d2_exp_sparse_pattern
 Sparsity pattern of d2r_exp_sparse(), d2r_expinv_sparse() (inline variable).
 

Detailed Description

Sparse versions of certain Lie group methods.

Implemented methods contain two parts: a pattern and the function itself. The pattern is in the form of an inline sparse matrix variable that is pre-allocated with the appropriate nonzeros.

The intended usage is to copy a pattern and use the resulting variable in calls to these methods. That way no additional allocation is needed.

Example:

auto my_var = ad_sparse_pattern; // copy pattern
ad_sparse(my_var, a); // update my_var in-place without allocation
void ad_sparse(Eigen::SparseMatrix< Scalar< G > > &sp, const Tangent< G > &a)
Sparse ad.
Eigen::SparseMatrix< Scalar< G > > ad_sparse_pattern
Sparsity pattern of ad_sparse (inline variable).

Definition in file lie_sparse.hpp.

Function Documentation

◆ ad_sparse()

template<LieGroup G>
void ad_sparse ( Eigen::SparseMatrix< Scalar< G > > &  sp,
const Tangent< G > &  a 
)

Sparse ad.

Parameters
[in,out]spallocated and compressed sparse matrix
[in]aLie algebra element
Warning
sp must be pre-allocated with the appropriate nonzeros and compressed
See also
ad_sparse_pattern() for a pre-allocated pattern.

◆ d2r_exp_sparse()

template<LieGroup G, bool Inv = false>
void d2r_exp_sparse ( Eigen::SparseMatrix< Scalar< G > > &  sp,
const Tangent< G > &  a,
Eigen::Index  i0 = 0 
)

Sparse d2r_exp.

Template Parameters
GLie group
Invcompute d2r_expinv
Parameters
[in,out]spallocated and compressed sparse matrix
[in]aLie algebra element
[in]i0block index (row and column) in sp where result is inserted
Warning
sp must be pre-allocated with the appropriate nonzeros and compressed
See also
d2_exp_sparse_pattern() for a pre-allocated pattern.

◆ d2r_expinv_sparse()

template<LieGroup G>
void d2r_expinv_sparse ( Eigen::SparseMatrix< Scalar< G > > &  sp,
const Tangent< G > &  a,
Eigen::Index  i0 = 0 
)
inline

Sparse d2r_expinv.

Template Parameters
GLie group
Parameters
[in,out]spallocated and compressed sparse matrix
[in]aLie algebra element
[in]i0block index (row and column) in sp where result is inserted
Warning
sp must be pre-allocated with the appropriate nonzeros and compressed
See also
d2_exp_sparse_pattern() for a pre-allocated pattern.

◆ dr_exp_sparse()

template<LieGroup G, bool Inv = false>
void dr_exp_sparse ( Eigen::SparseMatrix< Scalar< G > > &  sp,
const Tangent< G > &  a,
Eigen::Index  i0 = 0 
)

Sparse dr_exp.

Template Parameters
GLie group
Invcompute dr_expinv
Parameters
[in,out]spallocated and compressed sparse matrix
[in]aLie algebra element
[in]i0block index (row and column) in sp where result is inserted
Warning
sp must be pre-allocated with the appropriate nonzeros and compressed
See also
d_exp_sparse_pattern() for a pre-allocated pattern.

◆ dr_expinv_sparse()

template<LieGroup G>
void dr_expinv_sparse ( Eigen::SparseMatrix< Scalar< G > > &  sp,
const Tangent< G > &  a,
Eigen::Index  i0 = 0 
)

Sparse dr_expinv.

Template Parameters
GLie group
Parameters
[in,out]spallocated and compressed sparse matrix
[in]aLie algebra element
[in]i0block index (row and column) in sp where result is inserted
Warning
sp must be pre-allocated with the appropriate nonzeros and compressed
See also
d_exp_sparse_pattern() for a pre-allocated pattern.

Variable Documentation

◆ ad_sparse_pattern

template<LieGroup G>
Eigen::SparseMatrix<Scalar<G> > ad_sparse_pattern
inline
Initial value:
= [] {
Eigen::SparseMatrix<Scalar<G>> ret(Dof<G>, Dof<G>);
if constexpr (!IsCommutative<G>) {
for (const auto & gen : generators_sparse<G>) { ret += gen; }
}
ret.makeCompressed();
ret.coeffs().setZero();
return ret;
}()
std::array< Eigen::SparseMatrix< Scalar< G > >, Dof< G > > generators_sparse
Generators of lie algebra (inline variable).

Sparsity pattern of ad_sparse (inline variable).

Definition at line 62 of file lie_sparse.hpp.

◆ d2_exp_sparse_pattern

template<LieGroup G>
Eigen::SparseMatrix<Scalar<G> > d2_exp_sparse_pattern
inline
Initial value:
= [] {
Eigen::SparseMatrix<Scalar<G>> ret(Dof<G>, Dof<G> * Dof<G>);
if constexpr (IsCommutative<G>) {
} else if constexpr (requires { traits::lie_sparse<G>::d2_exp_sparse_pattern; }) {
} else {
ret = Eigen::Matrix<Scalar<G>, Dof<G>, Dof<G> * Dof<G>>::Ones().sparseView();
}
ret.makeCompressed();
return ret;
}()
Traits that defines sparsity patterns for various groups.

Sparsity pattern of d2r_exp_sparse(), d2r_expinv_sparse() (inline variable).

Definition at line 144 of file lie_sparse.hpp.

◆ d_exp_sparse_pattern

template<LieGroup G>
Eigen::SparseMatrix<Scalar<G> > d_exp_sparse_pattern
inline
Initial value:
= [] {
Eigen::SparseMatrix<Scalar<G>> ret(Dof<G>, Dof<G>);
if constexpr (IsCommutative<G>) {
for (auto i = 0u; i < Dof<G>; ++i) { ret.insert(i, i) = Scalar<G>(1); }
} else if constexpr (requires { traits::lie_sparse<G>::d_exp_sparse_pattern; }) {
} else {
for (auto i = 0u; i < Dof<G>; ++i) {
for (auto j = 0u; j < Dof<G>; ++j) { ret.insert(i, j) = (i == j) ? Scalar<G>(1) : Scalar<G>(0); }
}
}
ret.makeCompressed();
return ret;
}()
typename traits::man< M >::Scalar Scalar
Manifold scalar type.
Definition manifold.hpp:88

Sparsity pattern of dr_exp_sparse, dr_expinv_sparse (inline variable).

Definition at line 89 of file lie_sparse.hpp.

◆ generators_sparse

template<LieGroup G>
std::array<Eigen::SparseMatrix<Scalar<G> >, Dof<G> > generators_sparse
inline
Initial value:
=
[]() -> std::array<Eigen::SparseMatrix<Scalar<G>>, Dof<G>> {
std::array<Eigen::SparseMatrix<Scalar<G>>, Dof<G>> ret;
for (auto i = 0u; i < Dof<G>; ++i) {
ret[i] = ad<G>(Tangent<G>::Unit(i)).sparseView();
ret[i].makeCompressed();
}
return ret;
}()
Eigen::Vector< Scalar< M >, Dof< M > > Tangent
Tangent as a Dof-length vector.
Definition manifold.hpp:106

Generators of lie algebra (inline variable).

Definition at line 48 of file lie_sparse.hpp.