微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

特征稀疏矩阵innerIndexPtr() 和outerIndexPtr() 返回类型转换错误?

如何解决特征稀疏矩阵innerIndexPtr() 和outerIndexPtr() 返回类型转换错误?

我想使用OSQP的C API来解决一些优化问题。我使用 Eigen::Sparse 矩阵定义了这个问题。但是我无法按照 OSQP 的要求转换那些稀疏矩阵。以下代码尝试将稀疏矩阵转换为 OSQP 理解的格式。但是在尝试分配 P 时,我遇到了一些错误,但仍然不知道如何解决

    int updateMatrices(Eigen::SparseMatrix<double> & P_,Eigen::SparseMatrix<double> & q_,Eigen::SparseMatrix<double> & A_,Eigen::SparseMatrix<double> & l_,Eigen::SparseMatrix<double> & u_,int warmStart,int max_iterations){

          P_ = P_.triangularView<Upper>();

          data->n = P_.rows();
          data->m = A_.rows();
          // use the eigen sparse ptrs make it faster
          data->P = csc_matrix(data->n,data->n,P_.nonZeros(),P_.valuePtr(),P_.innerIndexPtr(),P_.outerIndexPtr());

    .
    .
    .
    .

如给定的 here,它期望 c_int*,但它具有 Eigen::SparseMatrix<double>::StorageIndex* 的格式。这就是我收到以下错误的原因,知道如何解决这个问题吗?

error: cannot convert ‘Eigen::SparseMatrix<double>::StorageIndex* {aka int*}’ to ‘c_int* {aka long long int*}’ for argument ‘5’ to ‘csc* csc_matrix(c_int,c_int,c_float*,c_int*,c_int*)’
 data->P = csc_matrix(data->n,P_.outerIndexPtr());

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。