/farmR/src/glpscf.h

https://code.google.com/p/javawfm/ · C Header · 125 lines · 31 code · 13 blank · 81 comment · 0 complexity · 281e99cf8b480bf714dc256e1dc160b6 MD5 · raw file

  1. /* glpscf.h (Schur complement factorization) */
  2. /***********************************************************************
  3. * This code is part of GLPK (GNU Linear Programming Kit).
  4. *
  5. * Copyright (C) 2000,01,02,03,04,05,06,07,08,2009 Andrew Makhorin,
  6. * Department for Applied Informatics, Moscow Aviation Institute,
  7. * Moscow, Russia. All rights reserved. E-mail: <mao@mai2.rcnet.ru>.
  8. *
  9. * GLPK is free software: you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * GLPK is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  17. * License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  21. ***********************************************************************/
  22. #ifndef _GLPSCF_H
  23. #define _GLPSCF_H
  24. /***********************************************************************
  25. * The structure SCF defines the following factorization of a square
  26. * nxn matrix C (which is the Schur complement):
  27. *
  28. * F * C = U * P,
  29. *
  30. * where F is a square transforming matrix, U is an upper triangular
  31. * matrix, P is a permutation matrix.
  32. *
  33. * It is assumed that matrix C is small and dense, so matrices F and U
  34. * are stored in the dense format by rows as follows:
  35. *
  36. * 1 n n_max 1 n n_max
  37. * 1 * * * * * * x x x x 1 * * * * * * x x x x
  38. * * * * * * * x x x x . * * * * * x x x x
  39. * * * * * * * x x x x . . * * * * x x x x
  40. * * * * * * * x x x x . . . * * * x x x x
  41. * * * * * * * x x x x . . . . * * x x x x
  42. * n * * * * * * x x x x n . . . . . * x x x x
  43. * x x x x x x x x x x . . . . . . x x x x
  44. * x x x x x x x x x x . . . . . . . x x x
  45. * x x x x x x x x x x . . . . . . . . x x
  46. * n_max x x x x x x x x x x n_max . . . . . . . . . x
  47. *
  48. * matrix F matrix U
  49. *
  50. * where '*' are matrix elements, 'x' are reserved locations.
  51. *
  52. * Permutation matrix P is stored in row-like format.
  53. *
  54. * Matrix C normally is not stored.
  55. *
  56. * REFERENCES
  57. *
  58. * 1. M.A.Saunders, "LUSOL: A basis package for constrained optimiza-
  59. * tion," SCCM, Stanford University, 2006.
  60. *
  61. * 2. M.A.Saunders, "Notes 5: Basis Updates," CME 318, Stanford Univer-
  62. * sity, Spring 2006.
  63. *
  64. * 3. M.A.Saunders, "Notes 6: LUSOL---a Basis Factorization Package,"
  65. * ibid. */
  66. typedef struct SCF SCF;
  67. struct SCF
  68. { /* Schur complement factorization */
  69. int n_max;
  70. /* maximal order of matrices C, F, U, P; n_max >= 1 */
  71. int n;
  72. /* current order of matrices C, F, U, P; n >= 0 */
  73. double *f; /* double f[1+n_max*n_max]; */
  74. /* matrix F stored by rows */
  75. double *u; /* double u[1+n_max*(n_max+1)/2]; */
  76. /* upper triangle of matrix U stored by rows */
  77. int *p; /* int p[1+n_max]; */
  78. /* matrix P; p[i] = j means that P[i,j] = 1 */
  79. int t_opt;
  80. /* type of transformation used to restore triangular structure of
  81. matrix U: */
  82. #define SCF_TBG 1 /* Bartels-Golub elimination */
  83. #define SCF_TGR 2 /* Givens plane rotation */
  84. int rank;
  85. /* estimated rank of matrices C and U */
  86. double *c; /* double c[1+n_max*n_max]; */
  87. /* matrix C stored in the same format as matrix F and used only
  88. for debugging; normally this array is not allocated */
  89. double *w; /* double w[1+n_max]; */
  90. /* working array */
  91. };
  92. /* return codes: */
  93. #define SCF_ESING 1 /* singular matrix */
  94. #define SCF_ELIMIT 2 /* update limit reached */
  95. #define scf_create_it _glp_scf_create_it
  96. SCF *scf_create_it(int n_max);
  97. /* create Schur complement factorization */
  98. #define scf_update_exp _glp_scf_update_exp
  99. int scf_update_exp(SCF *scf, const double x[], const double y[],
  100. double z);
  101. /* update factorization on expanding C */
  102. #define scf_solve_it _glp_scf_solve_it
  103. void scf_solve_it(SCF *scf, int tr, double x[]);
  104. /* solve either system C * x = b or C' * x = b */
  105. #define scf_reset_it _glp_scf_reset_it
  106. void scf_reset_it(SCF *scf);
  107. /* reset factorization for empty matrix C */
  108. #define scf_delete_it _glp_scf_delete_it
  109. void scf_delete_it(SCF *scf);
  110. /* delete Schur complement factorization */
  111. #endif
  112. /* eof */