Type of linsys_solver_bwork in generated code

24 views
Skip to first unread message

michael.he...@gmail.com

unread,
Feb 5, 2019, 2:39:22 PM2/5/19
to OSQP
Hi,

I am generating code from Matlab with osqp-0.5.0.

In workspace.h, the linsys_solver_bwork is of type c_int. According to qldl_interface.h, the qdldl_solver struct expects a pointer of type QDLDL_bool. As QDLDL_bool (or QDLDL_BOOL_TYPE respectively) is not set anywhere, QDLDL_bool defaults to int. Is there a reason that QDLDL_BOOL_TYPE is not set anywhere?

Also, from the name, I would expect QDLDL_bool to be a boolean type. However, the values in linsys_solver_bwork contain integers unequal to 0 or 1. Is this just a confusing naming?

Thanks and best regards
Michael

Goran Banjac

unread,
Feb 6, 2019, 4:53:05 AM2/6/19
to OSQP
Hi Michael,

Thanks for reporting this issue. We have now defined QDLDL_BOOL_TYPE in this commit and changed types of internal qdldl variables in this commit.

You can see in this function that bwork can only take values 0 and 1. We do not define QDLDL_BOOL_TYPE as the boolean type because this type does not exist in C89.

Please let us know if you have any further questions.

Best,
Goran

Paul Goulart

unread,
Feb 6, 2019, 4:55:54 AM2/6/19
to OSQP
I think there are a few separate problems here:


On Tuesday, February 5, 2019 at 7:39:22 PM UTC, michael.he...@gmail.com wrote:
Hi,

I am generating code from Matlab with osqp-0.5.0.

In workspace.h, the linsys_solver_bwork is of type c_int. 


This part I do not understand, because when I run the codegen_test.m example in the ./examples directory of the osqp-matlab repo, it defines linsys_solver_bwork to be of type QDLDL_bool for me.   Could you verify that you have the latest version and, if so, provide an example to generates code as described above?

According to qldl_interface.h, the qdldl_solver struct expects a pointer of type QDLDL_bool. As QDLDL_bool (or QDLDL_BOOL_TYPE respectively) is not set anywhere, QDLDL_bool defaults to int. Is there a reason that QDLDL_BOOL_TYPE is not set anywhere?

The qdldl_interface.h header includes qdldl_types.h, which says 
> typedef unsigned char   QDLDL_bool;

Also, from the name, I would expect QDLDL_bool to be a boolean type. However, the values in linsys_solver_bwork contain integers unequal to 0 or 1. Is this just a confusing naming?


I believe that this is a problem with the way we generate the workspace header.  The bwork, fwork and iwork arrays don't actually require values to be set since they are just scratch space for the qdldl factorization code.   We should probably just make them arrays and not specify the values.

The reason the values are non-boolean and because the bool type is actually a char according to the typedef above, but I agree that it is confusing.    Could you raise this as a bug report on github?

PG

Goran Banjac

unread,
Feb 12, 2019, 3:41:46 PM2/12/19
to OSQP
This should now be fixed in this commit.

Goran
Reply all
Reply to author
Forward
0 new messages