You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It was recommended by @goulart-paul that I open an issue in GitHub.
Hello,
I am trying to generate C source code with the Python3 tool m.codegen(dir_name, **opts). I would like the resulting code to use float instead of double and to use int instead of long long. However, I believe I am not achieving these settings. The following is a description of the behavior I am experiencing.
Following the documentation, I tried running the following Python3 script:
import osqp
# Allocate problem data and src variable
...
m = osqp.OSQP();
m.setup(P, q, A, l, u)
m.codegen(src, force_rewrite=True, parameters='matrices', FLOAT=True, LONG=False)
The result is a directory with the correct source code. In fact, I can compile the source code with the rest of my project and correctly solve the QP. However, I believe the type of c_int is long long and the type of c_float is double. I have tested this by printing, for example, as follows printf( "Test c_int workspace->data->A->i[4] = %d, workspace->data->A->i[4]); >> Test c_int workspace->data->A->i[4] = 467912 printf( "Test c_int workspace->data->A->i[4] = %lld, workspace->data->A->i[4]); >> Test c_int workspace->data->A->i[4] = 1
The expected value of workspace->data->A->i[4] is 1. I can cast (int)workspace->data->A->i[4] and then I also get 1 as expected. But I believe this shows me the type of c_int is long long.
Furthermore, here are some lines in the file src/include/osqp_configure.h that seem to have auto-generated with unexpected content. I would expect #define DFLOAT for example.
If I try to manually change this osqp_configure.h file, I get some compilation errors from the qdldl library with type mismatches.
I apologize for the long explanation. Any advice on how to correctly use the m.codegen(dir_name, **opts) Python3 method to generate code with the correct float and int typing would be appreciated.
Thank you for your time,
-Victor
The text was updated successfully, but these errors were encountered:
// qdldl_types.h
...
//typedef long long QDLDL_int; /* for indices */
typedef int QDLDL_int; /* for indices */
//typedef double QDLDL_float; /* for numerical values */
typedef float QDLDL_float; /* for numerical values */
...
Original post: OSQP Forum
It was recommended by @goulart-paul that I open an issue in GitHub.
Hello,
I am trying to generate C source code with the Python3 tool
m.codegen(dir_name, **opts)
. I would like the resulting code to usefloat
instead ofdouble
and to useint
instead oflong long
. However, I believe I am not achieving these settings. The following is a description of the behavior I am experiencing.Following the documentation, I tried running the following Python3 script:
The result is a directory with the correct source code. In fact, I can compile the source code with the rest of my project and correctly solve the QP. However, I believe the type of
c_int
islong long
and the type ofc_float
isdouble
. I have tested this by printing, for example, as followsprintf( "Test c_int workspace->data->A->i[4] = %d, workspace->data->A->i[4]);
>> Test c_int workspace->data->A->i[4] = 467912
printf( "Test c_int workspace->data->A->i[4] = %lld, workspace->data->A->i[4]);
>> Test c_int workspace->data->A->i[4] = 1
The expected value of
workspace->data->A->i[4]
is1
. I can cast(int)workspace->data->A->i[4]
and then I also get1
as expected. But I believe this shows me the type ofc_int
islong long
.Furthermore, here are some lines in the file
src/include/osqp_configure.h
that seem to have auto-generated with unexpected content. I would expect#define DFLOAT
for example.If I try to manually change this
osqp_configure.h
file, I get some compilation errors from theqdldl
library with type mismatches.I apologize for the long explanation. Any advice on how to correctly use the
m.codegen(dir_name, **opts)
Python3 method to generate code with the correctfloat
andint
typing would be appreciated.Thank you for your time,
-Victor
The text was updated successfully, but these errors were encountered: