5#include <initializer_list>
7#include <Eigen/SparseCore>
21template <
typename Scalar>
24 int col_offset, std::initializer_list<Eigen::SparseMatrix<Scalar>> mats) {
27 int mat_row_offset = 0;
28 for (
const auto& mat : mats) {
29 mat_row_offsets.emplace_back(mat_row_offset);
30 mat_row_offset += mat.rows();
34 for (
int col = 0; col < mats.begin()[0].cols(); ++col) {
35 for (
size_t i = 0; i < mats.size(); ++i) {
36 for (
typename Eigen::SparseMatrix<Scalar>::InnerIterator it{
37 mats.begin()[i], col};
39 triplets.emplace_back(row_offset + mat_row_offsets[i] + it.row(),
40 col_offset + it.col(), it.value());
53template <
typename Scalar>
56 int col_offset,
const Eigen::Vector<Scalar, Eigen::Dynamic>& diag) {
57 for (
int row = 0; row < diag.rows(); ++row) {
58 triplets.emplace_back(row_offset + row, col_offset + row, diag[row]);
void append_as_triplets(gch::small_vector< Eigen::Triplet< Scalar > > &triplets, int row_offset, int col_offset, std::initializer_list< Eigen::SparseMatrix< Scalar > > mats)
Appends sparse matrices to list of triplets at the given offset.
Definition append_as_triplets.hpp:22
void append_diagonal_as_triplets(gch::small_vector< Eigen::Triplet< Scalar > > &triplets, int row_offset, int col_offset, const Eigen::Vector< Scalar, Eigen::Dynamic > &diag)
Append diagonal matrix to list of triplets at the given offset.
Definition append_as_triplets.hpp:54
wpi::util::SmallVector< T > small_vector
Definition small_vector.hpp:10