HSLLoader.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /* Copyright (C) 2008, 2011 GAMS Development and others
  2. All Rights Reserved.
  3. This code is published under the Eclipse Public License.
  4. $Id: HSLLoader.h 2332 2013-06-14 14:05:12Z stefan $
  5. Author: Stefan Vigerske
  6. */
  7. #ifndef HSLLOADER_H_
  8. #define HSLLOADER_H_
  9. #include "IpoptConfig.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #ifndef ma77_default_control
  14. #define ma77_control ma77_control_d
  15. #define ma77_info ma77_info_d
  16. #define ma77_default_control ma77_default_control_d
  17. #define ma77_open_nelt ma77_open_nelt_d
  18. #define ma77_open ma77_open_d
  19. #define ma77_input_vars ma77_input_vars_d
  20. #define ma77_input_reals ma77_input_reals_d
  21. #define ma77_analyse ma77_analyse_d
  22. #define ma77_factor ma77_factor_d
  23. #define ma77_factor_solve ma77_factor_solve_d
  24. #define ma77_solve ma77_solve_d
  25. #define ma77_resid ma77_resid_d
  26. #define ma77_scale ma77_scale_d
  27. #define ma77_enquire_posdef ma77_enquire_posdef_d
  28. #define ma77_enquire_indef ma77_enquire_indef_d
  29. #define ma77_alter ma77_alter_d
  30. #define ma77_restart ma77_restart_d
  31. #define ma77_finalise ma77_finalise_d
  32. #endif
  33. struct ma77_control;
  34. struct ma77_info;
  35. typedef double ma77pkgtype_d_;
  36. #ifndef ma86_default_control
  37. #define ma86_control ma86_control_d
  38. #define ma86_info ma86_info_d
  39. #define ma86_default_control ma86_default_control_d
  40. #define ma86_analyse ma86_analyse_d
  41. #define ma86_factor ma86_factor_d
  42. #define ma86_factor_solve ma86_factor_solve_d
  43. #define ma86_solve ma86_solve_d
  44. #define ma86_finalise ma86_finalise_d
  45. #endif
  46. struct ma86_control;
  47. struct ma86_info;
  48. typedef double ma86pkgtype_d_;
  49. typedef double ma86realtype_d_;
  50. #ifndef ma97_default_control
  51. #define ma97_control ma97_control_d
  52. #define ma97_info ma97_info_d
  53. #define ma97_default_control ma97_default_control_d
  54. #define ma97_analyse ma97_analyse_d
  55. #define ma97_factor ma97_factor_d
  56. #define ma97_factor_solve ma97_factor_solve_d
  57. #define ma97_solve ma97_solve_d
  58. #define ma97_finalise ma97_finalise_d
  59. #define ma97_free_akeep ma97_free_akeep_d
  60. #endif
  61. struct ma97_control;
  62. struct ma97_info;
  63. typedef double ma97pkgtype_d_;
  64. typedef double ma97realtype_d_;
  65. struct mc68_control_i;
  66. struct mc68_info_i;
  67. #ifndef __IPTYPES_HPP__
  68. /* Type of Fortran integer translated into C */
  69. typedef FORTRAN_INTEGER_TYPE ipfint;
  70. #endif
  71. typedef void (*ma27ad_t)(ipfint *N, ipfint *NZ, const ipfint *IRN, const ipfint* ICN,
  72. ipfint *IW, ipfint* LIW, ipfint* IKEEP, ipfint *IW1,
  73. ipfint* NSTEPS, ipfint* IFLAG, ipfint* ICNTL,
  74. double* CNTL, ipfint *INFO, double* OPS);
  75. typedef void (*ma27bd_t)(ipfint *N, ipfint *NZ, const ipfint *IRN, const ipfint* ICN,
  76. double* A, ipfint* LA, ipfint* IW, ipfint* LIW,
  77. ipfint* IKEEP, ipfint* NSTEPS, ipfint* MAXFRT,
  78. ipfint* IW1, ipfint* ICNTL, double* CNTL,
  79. ipfint* INFO);
  80. typedef void (*ma27cd_t)(ipfint *N, double* A, ipfint* LA, ipfint* IW,
  81. ipfint* LIW, double* W, ipfint* MAXFRT,
  82. double* RHS, ipfint* IW1, ipfint* NSTEPS,
  83. ipfint* ICNTL, double* CNTL);
  84. typedef void (*ma27id_t)(ipfint* ICNTL, double* CNTL);
  85. typedef void (*ma28ad_t)(void* nsize, void* nz, void* rw, void* licn, void* iw,
  86. void* lirn, void* iw2, void* pivtol, void* iw3, void* iw4, void* rw2, void* iflag);
  87. typedef void (*ma57ad_t) (
  88. ipfint *n, /* Order of matrix. */
  89. ipfint *ne, /* Number of entries. */
  90. const ipfint *irn, /* Matrix nonzero row structure */
  91. const ipfint *jcn, /* Matrix nonzero column structure */
  92. ipfint *lkeep, /* Workspace for the pivot order of lenght 3*n */
  93. ipfint *keep, /* Workspace for the pivot order of lenght 3*n */
  94. /* Automatically iflag = 0; ikeep pivot order iflag = 1 */
  95. ipfint *iwork, /* Integer work space. */
  96. ipfint *icntl, /* Integer Control parameter of length 30*/
  97. ipfint *info, /* Statistical Information; Integer array of length 20 */
  98. double *rinfo); /* Double Control parameter of length 5 */
  99. typedef void (*ma57bd_t) (
  100. ipfint *n, /* Order of matrix. */
  101. ipfint *ne, /* Number of entries. */
  102. double *a, /* Numerical values. */
  103. double *fact, /* Entries of factors. */
  104. ipfint *lfact, /* Length of array `fact'. */
  105. ipfint *ifact, /* Indexing info for factors. */
  106. ipfint *lifact, /* Length of array `ifact'. */
  107. ipfint *lkeep, /* Length of array `keep'. */
  108. ipfint *keep, /* Integer array. */
  109. ipfint *iwork, /* Workspace of length `n'. */
  110. ipfint *icntl, /* Integer Control parameter of length 20. */
  111. double *cntl, /* Double Control parameter of length 5. */
  112. ipfint *info, /* Statistical Information; Integer array of length 40. */
  113. double *rinfo); /* Statistical Information; Real array of length 20. */
  114. typedef void (*ma57cd_t) (
  115. ipfint *job, /* Solution job. Solve for... */
  116. ipfint *n, /* Order of matrix. */
  117. double *fact, /* Entries of factors. */
  118. ipfint *lfact, /* Length of array `fact'. */
  119. ipfint *ifact, /* Indexing info for factors. */
  120. ipfint *lifact, /* Length of array `ifact'. */
  121. ipfint *nrhs, /* Number of right hand sides. */
  122. double *rhs, /* Numerical Values. */
  123. ipfint *lrhs, /* Leading dimensions of `rhs'. */
  124. double *work, /* Real workspace. */
  125. ipfint *lwork, /* Length of `work', >= N*NRHS. */
  126. ipfint *iwork, /* Integer array of length `n'. */
  127. ipfint *icntl, /* Integer Control parameter array of length 20. */
  128. ipfint *info); /* Statistical Information; Integer array of length 40. */
  129. typedef void (*ma57ed_t) (
  130. ipfint *n,
  131. ipfint *ic, /* 0: copy real array. >=1: copy integer array. */
  132. ipfint *keep,
  133. double *fact,
  134. ipfint *lfact,
  135. double *newfac,
  136. ipfint *lnew,
  137. ipfint *ifact,
  138. ipfint *lifact,
  139. ipfint *newifc,
  140. ipfint *linew,
  141. ipfint *info);
  142. typedef void (*ma57id_t) (double *cntl, ipfint *icntl);
  143. typedef void (*ma77_default_control_t)(struct ma77_control_d *control);
  144. typedef void (*ma77_open_nelt_t)(const int n, const char* fname1, const char* fname2,
  145. const char *fname3, const char *fname4, void **keep,
  146. const struct ma77_control_d *control, struct ma77_info_d *info,
  147. const int nelt);
  148. typedef void (*ma77_open_t)(const int n, const char* fname1, const char* fname2,
  149. const char *fname3, const char *fname4, void **keep,
  150. const struct ma77_control_d *control, struct ma77_info_d *info);
  151. typedef void (*ma77_input_vars_t)(const int idx, const int nvar, const int list[],
  152. void **keep, const struct ma77_control_d *control, struct ma77_info_d *info);
  153. typedef void (*ma77_input_reals_t)(const int idx, const int length,
  154. const double reals[], void **keep, const struct ma77_control_d *control,
  155. struct ma77_info_d *info);
  156. typedef void (*ma77_analyse_t)(const int order[], void **keep,
  157. const struct ma77_control_d *control, struct ma77_info_d *info);
  158. typedef void (*ma77_factor_t)(const int posdef, void **keep,
  159. const struct ma77_control_d *control, struct ma77_info_d *info,
  160. const double *scale);
  161. typedef void (*ma77_factor_solve_t)(const int posdef, void **keep,
  162. const struct ma77_control_d *control, struct ma77_info_d *info,
  163. const double *scale, const int nrhs, const int lx,
  164. double rhs[]);
  165. typedef void (*ma77_solve_t)(const int job, const int nrhs, const int lx, double x[],
  166. void **keep, const struct ma77_control_d *control, struct ma77_info_d *info,
  167. const double *scale);
  168. typedef void (*ma77_resid_t)(const int nrhs, const int lx, const double x[],
  169. const int lresid, double resid[], void **keep,
  170. const struct ma77_control_d *control, struct ma77_info_d *info,
  171. double *anorm_bnd);
  172. typedef void (*ma77_scale_t)(double scale[], void **keep,
  173. const struct ma77_control_d *control, struct ma77_info_d *info,
  174. double *anorm);
  175. typedef void (*ma77_enquire_posdef_t)(double d[], void **keep,
  176. const struct ma77_control_d *control, struct ma77_info_d *info);
  177. typedef void (*ma77_enquire_indef_t)(int piv_order[], double d[], void **keep,
  178. const struct ma77_control_d *control, struct ma77_info_d *info);
  179. typedef void (*ma77_alter_t)(const double d[], void **keep,
  180. const struct ma77_control_d *control, struct ma77_info_d *info);
  181. typedef void (*ma77_restart_t)(const char *restart_file, const char *fname1,
  182. const char *fname2, const char *fname3, const char *fname4, void **keep,
  183. const struct ma77_control_d *control, struct ma77_info_d *info);
  184. typedef void (*ma77_finalise_t)(void **keep, const struct ma77_control_d *control,
  185. struct ma77_info_d *info);
  186. typedef void (*ma86_default_control_t)(struct ma86_control *control);
  187. typedef void (*ma86_analyse_t)(const int n, const int ptr[], const int row[],
  188. int order[], void **keep, const struct ma86_control *control,
  189. struct ma86_info *info);
  190. typedef void (*ma86_factor_t)(const int n, const int ptr[], const int row[],
  191. const ma86pkgtype_d_ val[], const int order[], void **keep,
  192. const struct ma86_control *control, struct ma86_info *info,
  193. const ma86pkgtype_d_ scale[]);
  194. typedef void (*ma86_factor_solve_t)(const int n, const int ptr[],
  195. const int row[], const ma86pkgtype_d_ val[], const int order[], void **keep,
  196. const struct ma86_control *control, struct ma86_info *info, const int nrhs,
  197. const int ldx, ma86pkgtype_d_ x[], const ma86pkgtype_d_ scale[]);
  198. typedef void (*ma86_solve_t)(const int job, const int nrhs, const int ldx,
  199. ma86pkgtype_d_ *x, const int order[], void **keep,
  200. const struct ma86_control *control, struct ma86_info *info,
  201. const ma86pkgtype_d_ scale[]);
  202. typedef void (*ma86_finalise_t)(void **keep,
  203. const struct ma86_control *control);
  204. typedef void (*ma97_default_control_t)(struct ma97_control *control);
  205. typedef void (*ma97_analyse_t)(const int check, const int n, const int ptr[],
  206. const int row[], ma97pkgtype_d_ val[], void **akeep,
  207. const struct ma97_control *control, struct ma97_info *info, int order[]);
  208. typedef void (*ma97_factor_t)(const int matrix_type, const int ptr[],
  209. const int row[], const ma97pkgtype_d_ val[], void **akeep, void **fkeep,
  210. const struct ma97_control *control, struct ma97_info *info,
  211. const ma97pkgtype_d_ scale[]);
  212. typedef void (*ma97_factor_solve_t)(const int matrix_type, const int ptr[],
  213. const int row[], const ma97pkgtype_d_ val[], const int nrhs,
  214. ma97pkgtype_d_ x[], const int ldx, void **akeep, void **fkeep,
  215. const struct ma97_control *control, struct ma97_info *info,
  216. const ma97pkgtype_d_ scale[]);
  217. typedef void (*ma97_solve_t)(const int job, const int nrhs, ma97pkgtype_d_ *x,
  218. const int ldx, void **akeep, void **fkeep,
  219. const struct ma97_control *control, struct ma97_info *info);
  220. typedef void (*ma97_finalise_t)(void **akeep, void **fkeep);
  221. typedef void (*ma97_free_akeep_t)(void **akeep);
  222. typedef void (*mc19ad_t)(ipfint *N, ipfint *NZ, double* A, ipfint *IRN, ipfint* ICN, float* R, float* C, float* W);
  223. typedef void (*mc68_default_control_t)(struct mc68_control_i *control);
  224. typedef void (*mc68_order_t)(int ord, int n, const int ptr[],
  225. const int row[], int perm[], const struct mc68_control_i *control,
  226. struct mc68_info_i *info);
  227. /** Tries to load a dynamically linked library with HSL routines.
  228. * Also tries to load symbols for those HSL routines that are not linked into Ipopt, i.e., HAVE_... is not defined.
  229. * Return a failure if the library cannot be loaded, but not if a symbol is not found.
  230. * @see LSL_isMA27available
  231. * @see LSL_isMA28available
  232. * @see LSL_isMA57available
  233. * @see LSL_isMA77available
  234. * @see LSL_isMA86available
  235. * @see LSL_isMA97available
  236. * @see LSL_isMC19available
  237. * @param libname The name under which the HSL lib can be found, or NULL to use a default name (libhsl.SHAREDLIBEXT).
  238. * @param msgbuf A buffer where we can store a failure message. Assumed to be NOT NULL!
  239. * @param msglen Length of the message buffer.
  240. * @return Zero on success, nonzero on failure.
  241. */
  242. int LSL_loadHSL(const char* libname, char* msgbuf, int msglen);
  243. /** Unloads a loaded HSL library.
  244. * @return Zero on success, nonzero on failure.
  245. */
  246. int LSL_unloadHSL();
  247. /** Indicates whether a HSL library has been loaded.
  248. * @return Zero if not loaded, nonzero if handle is loaded
  249. */
  250. int LSL_isHSLLoaded();
  251. /** Indicates whether a HSL library is loaded and all symbols necessary to use MA27 have been found.
  252. * @return Zero if not available, nonzero if MA27 is available in the loaded library.
  253. */
  254. int LSL_isMA27available();
  255. /** Indicates whether a HSL library is loaded and all symbols necessary to use MA28 have been found.
  256. * @return Zero if not available, nonzero if MA28 is available in the loaded library.
  257. */
  258. int LSL_isMA28available();
  259. /** Indicates whether a HSL library is loaded and all symbols necessary to use MA57 have been found.
  260. * @return Zero if not available, nonzero if MA57 is available in the loaded library.
  261. */
  262. int LSL_isMA57available();
  263. /** Indicates whether a HSL library is loaded and all symbols necessary to use MA77 have been found.
  264. * @return Zero if not available, nonzero if HSL_MA77 is available in the loaded library.
  265. */
  266. int LSL_isMA77available();
  267. /** Indicates whether a HSL library is loaded and all symbols necessary to use HSL_MA86 have been found.
  268. * @return Zero if not available, nonzero if HSL_MA86 is available in the loaded library.
  269. */
  270. int LSL_isMA86available();
  271. /** Indicates whether a HSL library is loaded and all symbols necessary to use HSL_MA97 have been found.
  272. * @return Zero if not available, nonzero if HSL_MA97 is available in the loaded library.
  273. */
  274. int LSL_isMA97available();
  275. /** Indicates whether a HSL library is loaded and all symbols necessary to use MA57 have been found.
  276. * @return Zero if not available, nonzero if MC19 is available in the loaded library.
  277. */
  278. int LSL_isMC19available();
  279. /** Indicates whether a HSL library is loaded and all symbols necessary to use HSL_MC68 have been found.
  280. * @return Zero if not available, nonzero if MC68 is available in the loaded library.
  281. */
  282. int LSL_isMC68available();
  283. /** Returns name of the shared library that should contain HSL */
  284. char* LSL_HSLLibraryName();
  285. /** sets pointers to MA27 functions */
  286. void LSL_setMA27(ma27ad_t ma27ad, ma27bd_t ma27bd, ma27cd_t ma27cd, ma27id_t ma27id);
  287. /** sets pointers to MA28 functions */
  288. void LSL_setMA28(ma28ad_t ma28ad);
  289. /** sets pointers to MA57 functions */
  290. void LSL_setMA57(ma57ad_t ma57ad, ma57bd_t ma57bd, ma57cd_t ma57cd, ma57ed_t ma57ed, ma57id_t ma57id);
  291. /** sets pointers to MA77 functions */
  292. void LSL_setMA77(ma77_default_control_t ma77_default_control,
  293. ma77_open_nelt_t ma77_open_nelt,
  294. ma77_open_t ma77_open,
  295. ma77_input_vars_t ma77_input_vars,
  296. ma77_input_reals_t ma77_input_reals,
  297. ma77_analyse_t ma77_analyse,
  298. ma77_factor_t ma77_factor,
  299. ma77_factor_solve_t ma77_factor_solve,
  300. ma77_solve_t ma77_solve,
  301. ma77_resid_t ma77_resid,
  302. ma77_scale_t ma77_scale,
  303. ma77_enquire_posdef_t ma77_enquire_posdef,
  304. ma77_enquire_indef_t ma77_enquire_indef,
  305. ma77_alter_t ma77_alter,
  306. ma77_restart_t ma77_restart,
  307. ma77_finalise_t ma77_finalise);
  308. /** sets pointers to MA86 functions */
  309. void LSL_setMA86(ma86_default_control_t ma86_default_control,
  310. ma86_analyse_t ma86_analyse,
  311. ma86_factor_t ma86_factor,
  312. ma86_factor_solve_t ma86_factor_solve,
  313. ma86_solve_t ma86_solve,
  314. ma86_finalise_t ma86_finalise);
  315. /** sets pointers to MA97 functions */
  316. void LSL_setMA97(ma97_default_control_t ma97_default_control,
  317. ma97_analyse_t ma97_analyse,
  318. ma97_factor_t ma97_factor,
  319. ma97_factor_solve_t ma97_factor_solve,
  320. ma97_solve_t ma97_solve,
  321. ma97_finalise_t ma97_finalise,
  322. ma97_free_akeep_t ma97_free_akeep);
  323. /** sets pointer to MC19 function */
  324. void LSL_setMC19(mc19ad_t mc19ad);
  325. /** sets pointers to MC68 functions */
  326. void LSL_setMC68(mc68_default_control_t mc68_default_control, mc68_order_t mc68_order);
  327. #ifdef __cplusplus
  328. }
  329. #endif
  330. #endif /*HSLLOADER_H_*/