MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / insert_from_triplets

Function insert_from_triplets

include/Eigen/Eigen/src/SparseCore/SparseMatrix.h:1291–1303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1289// Creates a compressed sparse matrix from its existing entries and those from an unsorted range of triplets
1290template <typename InputIterator, typename SparseMatrixType, typename DupFunctor>
1291void insert_from_triplets(const InputIterator& begin, const InputIterator& end, SparseMatrixType& mat,
1292 DupFunctor dup_func) {
1293 using Scalar = typename SparseMatrixType::Scalar;
1294 using SrcXprType = CwiseBinaryOp<scalar_disjunction_op<DupFunctor, Scalar>, const SparseMatrixType, const SparseMatrixType>;
1295
1296 // set_from_triplets is necessary to sort the inner indices and remove the duplicate entries
1297 SparseMatrixType trips(mat.rows(), mat.cols());
1298 set_from_triplets(begin, end, trips, dup_func);
1299
1300 SrcXprType src = mat.binaryExpr(trips, scalar_disjunction_op<DupFunctor, Scalar>(dup_func));
1301 // the sparse assignment procedure creates a temporary matrix and swaps the final result
1302 assign_sparse_to_sparse<SparseMatrixType, SrcXprType>(mat, src);
1303}
1304
1305// Creates a compressed sparse matrix from its existing entries and those from an sorted range of triplets
1306template <typename InputIterator, typename SparseMatrixType, typename DupFunctor>

Callers

nothing calls this directly

Calls 3

set_from_tripletsFunction · 0.85
rowsMethod · 0.45
colsMethod · 0.45

Tested by

no test coverage detected