Understand HPIPM Matrix Formats and Memory Layout
masterHPIPM uses internal matrix and vector formats based on BLASFEO structs for high performance. The exact memory layout is architecture-dependent and cannot be inspected directly.
Using C Interface
- Column-major (Default): Use standard setter/getter routines. These expect matrices in column-major order (standard for Matlab, BLAS, and LAPACK).
- Row-major: Use routines suffixed with
_rowmaj. These expect input matrices in row-major order.
Language-specific Layout Pitfalls
When passing data to HPIPM, be aware of how your language stores matrices in memory:
- Matlab: Dense matrices are column-major.
- C: Arrays of arrays are row-major.
- Python (NumPy): Arrays of arrays are row-major.
If you use row-major routines, the input matrix is transposed while being packed/unpacked into the internal format.