Skipping over empty columns in sparse matrix
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 5.1k
- Forks
- 1.2k
- Avg merge
- 7h 33m
- Merged PRs (30d)
- 8
Description
Hello, iglers,
The code for the mosek quadprog wrapper crashes if there are empty columns at the end of the constraint matrix.
For example, let's say that the constraint matrix is
A = [1 0]
Then,
Av = [1]
Ari = [0]
Acp = [0 1 1]
When j=1, the code tries to dereference Av[1] and Ari[1], which causes a crash on our platform (Windows 10 & Visual Studio 2017). A simple fix is to check if the nnz in the jth column is 0.
According to the Mosek API page, MSK_putacol() resets all the elements in column j to zero and then..." So, it might still be a good idea to call this function with a zero column to make sure that the column is actually zeroed out.
int nnz = Acp[j+1] - Acp[j]; // number of nonzeros in jth col
if(nnz > 0)
{
mosek_guarded(
MSK_putacol(
task,
j,
nnz,
&Ari[Acp[j]],
&Av[Acp[j]])
);
}else
{
mosek_guarded(
MSK_putacol(
task,
j,
0,
0,
0)
);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in include/igl/mosek/mosek_quadprog.cpp around lines 175-180 and inspect how sparse column ranges are passed to MSK_putacol(). Reproduce the failure with a constraint matrix containing an empty trailing column, then verify that the wrapper handles the zero-length column without dereferencing invalid entries and preserves the intended zero-column state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100