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