如何通过q​​pOASES的SymSparseMat类创建对称的稀疏矩阵?

问题描述

我已经看到了hpp文件,以了解如何通过q​​pOASES的SymSparseMat类创建创建对称稀疏矩阵,并且需要输入五个参数:

                  int_t nr,/**< Number of rows. */
                  int_t nc,/**< Number of columns. */
                  sparse_int_t* r,/**< Row indices (length). */
                  sparse_int_t* c,/**< Indices to first entry of columns (nCols+1). */
                  real_t* v           /**< Vector of entries (length). */

我不知道第3至第5 自变量的含义。谁能给我一个简单的例子(例如3 * 3矩阵)来解释这3个参数代表什么? 预先感谢!

解决方法

qpOASES manual PDF说:“存储稀疏矩阵 列CCS或CSC格式。请参见explanation on Wikipedia

examples/qrecipe.cpp中有一个示例用法:

/* create sparse matrices */
SymSparseMat *H = new SymSparseMat(180,180,H_ir,H_jc,H_val);
SparseMatrix *A = new SparseMatrix(91,A_ir,A_jc,A_val);

其中{_3}中大约定义了H_ir,H_jc等。