blob: fe617d30f472057852404e2bdf250158c6f1ad26 [file] [log] [blame]
Austin Schuh9049e202022-02-20 17:34:16 -08001#include "lin_sys.h"
2
3#include "qdldl_interface.h" // Include only this solver in the same directory
4
5const char *LINSYS_SOLVER_NAME[] = {
6 "qdldl", "mkl pardiso"
7};
8
9#ifdef ENABLE_MKL_PARDISO
10# include "pardiso_interface.h"
11# include "pardiso_loader.h"
12#endif /* ifdef ENABLE_MKL_PARDISO */
13
14// Load linear system solver shared library
15c_int load_linsys_solver(enum linsys_solver_type linsys_solver) {
16 switch (linsys_solver) {
17 case QDLDL_SOLVER:
18
19 // We do not load QDLDL solver. We have the source.
20 return 0;
21
22# ifdef ENABLE_MKL_PARDISO
23 case MKL_PARDISO_SOLVER:
24
25 // Load Pardiso library
26 return lh_load_pardiso(OSQP_NULL);
27
28# endif /* ifdef ENABLE_MKL_PARDISO */
29 default: // QDLDL
30 return 0;
31 }
32}
33
34// Unload linear system solver shared library
35c_int unload_linsys_solver(enum linsys_solver_type linsys_solver) {
36 switch (linsys_solver) {
37 case QDLDL_SOLVER:
38
39 // We do not load QDLDL solver. We have the source.
40 return 0;
41
42# ifdef ENABLE_MKL_PARDISO
43 case MKL_PARDISO_SOLVER:
44
45 // Unload Pardiso library
46 return lh_unload_pardiso();
47
48# endif /* ifdef ENABLE_MKL_PARDISO */
49 default: // QDLDL
50 return 0;
51 }
52}
53
54// Initialize linear system solver structure
55// NB: Only the upper triangular part of P is stuffed!
56c_int init_linsys_solver(LinSysSolver **s,
57 const csc *P,
58 const csc *A,
59 c_float sigma,
60 const c_float *rho_vec,
61 enum linsys_solver_type linsys_solver,
62 c_int polish) {
63 switch (linsys_solver) {
64 case QDLDL_SOLVER:
65 return init_linsys_solver_qdldl((qdldl_solver **)s, P, A, sigma, rho_vec, polish);
66
67# ifdef ENABLE_MKL_PARDISO
68 case MKL_PARDISO_SOLVER:
69 return init_linsys_solver_pardiso((pardiso_solver **)s, P, A, sigma, rho_vec, polish);
70
71# endif /* ifdef ENABLE_MKL_PARDISO */
72 default: // QDLDL
73 return init_linsys_solver_qdldl((qdldl_solver **)s, P, A, sigma, rho_vec, polish);
74 }
75}