q = 2000;
n = 10000;
F = sprandn(q,n,10/n);
while not(isempty(find(sum(F,2) == 0)))
F = sprandn(q,n,10/n);
end
QP.H = F'*F;
QP.G = F';
QP.C = speye(n);
QP.h.fcn = '1norm';
QP.h.gamma = 10;
QP.gt = 1;
QP.bt = 0;
[QP_reform,alg_data] = run_code_gen(QP);
Checking data....done!
Checking algorithm options....done!
Selecting remaining algorithm options....done!
Reformulating problem....done!
Computing preconditioner....done!
Generating algorithm data....done!
Generating C code...done!
-----------------------------------------------------------
C code generated with options (in opts struct):
sparsity_threshold: 0.6500
alpha_relax: 1.8500
max_iter: 2000
rel_tol: 1.0000e-03
check_opt_interval: 10
restart: 1
precision: 'double'
precond_Hess: 'K11'
rho: 1
t: 1
no_math_lib: 0
min_cond_rel_tol: 2.0000e-05
alg: 'FGMprimal'
reform: 'original'
dense: 1
precond: 'jacobi'
Change any of these option using the function change_opts()
-----------------------------------------------------------
Generated files: QPgen.h (header file)
QPgen.c (main C file with solver qp())
qp_mex.c (mex gateway-file)
qp_mex.mex* (compiled mex-file)
-----------------------------------------------------------
Usage MATLAB: [sol,iter] = qp_mex(gt);
-----------------------------------------------------------
Usage C:
- compile QPgen.c
- solve using function qp(gt) with declaration:
void qp(double *sol, int *iter, double *gt);
-----------------------------------------------------------
Input dimensions: size(gt) = 2000x1
-----------------------------------------------------------
Output dimensions: size(sol) = 10000x1, size(iter) = 1x1
-----------------------------------------------------------