/** * @file SparseMatrixHelper.hpp * @author Giulio Romualdi * @copyright Released under the terms of the BSD 3-Clause License * @date 2018 */ #ifndef SPARSE_MATRIX_HPP #define SPARSE_MATRIX_HPP // std #include // eigen #include #include /** * OsqpEigen namespace. */ namespace OsqpEigen { /** * SparseMatrixHelper namespace is a namespace that contains helper function to handle osqp matrix. * Use it to create to update or manage an osqp sparse matrix. * osqp sparse matrix in [compressed-column](https://people.sc.fsu.edu/~jburkardt/data/cc/cc.html) * or triplet form. */ namespace SparseMatrixHelper { /** * Allocate an osqpSparseMatrix struct. * NOTE: c_malloc function is used to allocate memory please call * c_free to deallcate memory. * @return a const point to the csc struct. */ template bool createOsqpSparseMatrix(const Eigen::SparseCompressedBase& eigenSparseMatrix, csc*& osqpSparseMatrix); /** * Convert an osqp sparse matrix into an eigen sparse matrix. * @param osqpSparseMatrix is a constant pointer to a constant csc struct; * @param eigenSparseMatrix is the eigen sparse matrix object. * @return a const point to the csc struct. */ template bool osqpSparseMatrixToEigenSparseMatrix(const csc* const& osqpSparseMatrix, Eigen::SparseMatrix& eigenSparseMatrix); /** * Convert an osqp sparse matrix into a eigen triplet list. * @param osqpSparseMatrix is reference to a constant pointer to a constant csc struct; * @param tripletList is a std::vector containing the triplet. * @return a const point to the csc struct. */ template bool osqpSparseMatrixToTriplets(const csc* const& osqpSparseMatrix, std::vector>& tripletList); /** * Convert an eigen sparse matrix into a eigen triplet list. * @param eigenSparseMatrix is the eigen sparse matrix object; * @param tripletList is a std::vector containing the triplet. * @return a const point to the csc struct. */ template bool eigenSparseMatrixToTriplets(const Eigen::SparseCompressedBase& eigenSparseMatrix, std::vector>& tripletList); }; // namespace SparseMatrixHelper } // namespace OsqpEigen #include #endif