alpar@1: /* glpscf.h (Schur complement factorization) */ alpar@1: alpar@1: /*********************************************************************** alpar@1: * This code is part of GLPK (GNU Linear Programming Kit). alpar@1: * alpar@1: * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, alpar@1: * 2009, 2010 Andrew Makhorin, Department for Applied Informatics, alpar@1: * Moscow Aviation Institute, Moscow, Russia. All rights reserved. alpar@1: * E-mail: . alpar@1: * alpar@1: * GLPK is free software: you can redistribute it and/or modify it alpar@1: * under the terms of the GNU General Public License as published by alpar@1: * the Free Software Foundation, either version 3 of the License, or alpar@1: * (at your option) any later version. alpar@1: * alpar@1: * GLPK is distributed in the hope that it will be useful, but WITHOUT alpar@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY alpar@1: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public alpar@1: * License for more details. alpar@1: * alpar@1: * You should have received a copy of the GNU General Public License alpar@1: * along with GLPK. If not, see . alpar@1: ***********************************************************************/ alpar@1: alpar@1: #ifndef GLPSCF_H alpar@1: #define GLPSCF_H alpar@1: alpar@1: /*********************************************************************** alpar@1: * The structure SCF defines the following factorization of a square alpar@1: * nxn matrix C (which is the Schur complement): alpar@1: * alpar@1: * F * C = U * P, alpar@1: * alpar@1: * where F is a square transforming matrix, U is an upper triangular alpar@1: * matrix, P is a permutation matrix. alpar@1: * alpar@1: * It is assumed that matrix C is small and dense, so matrices F and U alpar@1: * are stored in the dense format by rows as follows: alpar@1: * alpar@1: * 1 n n_max 1 n n_max alpar@1: * 1 * * * * * * x x x x 1 * * * * * * x x x x alpar@1: * * * * * * * x x x x . * * * * * x x x x alpar@1: * * * * * * * x x x x . . * * * * x x x x alpar@1: * * * * * * * x x x x . . . * * * x x x x alpar@1: * * * * * * * x x x x . . . . * * x x x x alpar@1: * n * * * * * * x x x x n . . . . . * x x x x alpar@1: * x x x x x x x x x x . . . . . . x x x x alpar@1: * x x x x x x x x x x . . . . . . . x x x alpar@1: * x x x x x x x x x x . . . . . . . . x x alpar@1: * n_max x x x x x x x x x x n_max . . . . . . . . . x alpar@1: * alpar@1: * matrix F matrix U alpar@1: * alpar@1: * where '*' are matrix elements, 'x' are reserved locations. alpar@1: * alpar@1: * Permutation matrix P is stored in row-like format. alpar@1: * alpar@1: * Matrix C normally is not stored. alpar@1: * alpar@1: * REFERENCES alpar@1: * alpar@1: * 1. M.A.Saunders, "LUSOL: A basis package for constrained optimiza- alpar@1: * tion," SCCM, Stanford University, 2006. alpar@1: * alpar@1: * 2. M.A.Saunders, "Notes 5: Basis Updates," CME 318, Stanford Univer- alpar@1: * sity, Spring 2006. alpar@1: * alpar@1: * 3. M.A.Saunders, "Notes 6: LUSOL---a Basis Factorization Package," alpar@1: * ibid. */ alpar@1: alpar@1: typedef struct SCF SCF; alpar@1: alpar@1: struct SCF alpar@1: { /* Schur complement factorization */ alpar@1: int n_max; alpar@1: /* maximal order of matrices C, F, U, P; n_max >= 1 */ alpar@1: int n; alpar@1: /* current order of matrices C, F, U, P; n >= 0 */ alpar@1: double *f; /* double f[1+n_max*n_max]; */ alpar@1: /* matrix F stored by rows */ alpar@1: double *u; /* double u[1+n_max*(n_max+1)/2]; */ alpar@1: /* upper triangle of matrix U stored by rows */ alpar@1: int *p; /* int p[1+n_max]; */ alpar@1: /* matrix P; p[i] = j means that P[i,j] = 1 */ alpar@1: int t_opt; alpar@1: /* type of transformation used to restore triangular structure of alpar@1: matrix U: */ alpar@1: #define SCF_TBG 1 /* Bartels-Golub elimination */ alpar@1: #define SCF_TGR 2 /* Givens plane rotation */ alpar@1: int rank; alpar@1: /* estimated rank of matrices C and U */ alpar@1: double *c; /* double c[1+n_max*n_max]; */ alpar@1: /* matrix C stored in the same format as matrix F and used only alpar@1: for debugging; normally this array is not allocated */ alpar@1: double *w; /* double w[1+n_max]; */ alpar@1: /* working array */ alpar@1: }; alpar@1: alpar@1: /* return codes: */ alpar@1: #define SCF_ESING 1 /* singular matrix */ alpar@1: #define SCF_ELIMIT 2 /* update limit reached */ alpar@1: alpar@1: #define scf_create_it _glp_scf_create_it alpar@1: SCF *scf_create_it(int n_max); alpar@1: /* create Schur complement factorization */ alpar@1: alpar@1: #define scf_update_exp _glp_scf_update_exp alpar@1: int scf_update_exp(SCF *scf, const double x[], const double y[], alpar@1: double z); alpar@1: /* update factorization on expanding C */ alpar@1: alpar@1: #define scf_solve_it _glp_scf_solve_it alpar@1: void scf_solve_it(SCF *scf, int tr, double x[]); alpar@1: /* solve either system C * x = b or C' * x = b */ alpar@1: alpar@1: #define scf_reset_it _glp_scf_reset_it alpar@1: void scf_reset_it(SCF *scf); alpar@1: /* reset factorization for empty matrix C */ alpar@1: alpar@1: #define scf_delete_it _glp_scf_delete_it alpar@1: void scf_delete_it(SCF *scf); alpar@1: /* delete Schur complement factorization */ alpar@1: alpar@1: #endif alpar@1: alpar@1: /* eof */