PageRenderTime 45ms CodeModel.GetById 39ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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