lemon-project-template-glpk

diff deps/glpk/src/glpbfx.c @ 9:33de93886c88

Import GLPK 4.47
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 20:59:10 +0100
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/deps/glpk/src/glpbfx.c	Sun Nov 06 20:59:10 2011 +0100
     1.3 @@ -0,0 +1,91 @@
     1.4 +/* glpbfx.c */
     1.5 +
     1.6 +/***********************************************************************
     1.7 +*  This code is part of GLPK (GNU Linear Programming Kit).
     1.8 +*
     1.9 +*  Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
    1.10 +*  2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
    1.11 +*  Moscow Aviation Institute, Moscow, Russia. All rights reserved.
    1.12 +*  E-mail: <mao@gnu.org>.
    1.13 +*
    1.14 +*  GLPK is free software: you can redistribute it and/or modify it
    1.15 +*  under the terms of the GNU General Public License as published by
    1.16 +*  the Free Software Foundation, either version 3 of the License, or
    1.17 +*  (at your option) any later version.
    1.18 +*
    1.19 +*  GLPK is distributed in the hope that it will be useful, but WITHOUT
    1.20 +*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    1.21 +*  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
    1.22 +*  License for more details.
    1.23 +*
    1.24 +*  You should have received a copy of the GNU General Public License
    1.25 +*  along with GLPK. If not, see <http://www.gnu.org/licenses/>.
    1.26 +***********************************************************************/
    1.27 +
    1.28 +typedef struct BFX BFX;
    1.29 +#define GLPBFX_DEFINED
    1.30 +#include "glpbfx.h"
    1.31 +#include "glpenv.h"
    1.32 +#include "glplux.h"
    1.33 +
    1.34 +struct BFX
    1.35 +{     int valid;
    1.36 +      LUX *lux;
    1.37 +};
    1.38 +
    1.39 +BFX *bfx_create_binv(void)
    1.40 +{     /* create factorization of the basis matrix */
    1.41 +      BFX *bfx;
    1.42 +      bfx = xmalloc(sizeof(BFX));
    1.43 +      bfx->valid = 0;
    1.44 +      bfx->lux = NULL;
    1.45 +      return bfx;
    1.46 +}
    1.47 +
    1.48 +int bfx_factorize(BFX *binv, int m, int (*col)(void *info, int j,
    1.49 +      int ind[], mpq_t val[]), void *info)
    1.50 +{     /* compute factorization of the basis matrix */
    1.51 +      int ret;
    1.52 +      xassert(m > 0);
    1.53 +      if (binv->lux != NULL && binv->lux->n != m)
    1.54 +      {  lux_delete(binv->lux);
    1.55 +         binv->lux = NULL;
    1.56 +      }
    1.57 +      if (binv->lux == NULL)
    1.58 +         binv->lux = lux_create(m);
    1.59 +      ret = lux_decomp(binv->lux, col, info);
    1.60 +      binv->valid = (ret == 0);
    1.61 +      return ret;
    1.62 +}
    1.63 +
    1.64 +void bfx_ftran(BFX *binv, mpq_t x[], int save)
    1.65 +{     /* perform forward transformation (FTRAN) */
    1.66 +      xassert(binv->valid);
    1.67 +      lux_solve(binv->lux, 0, x);
    1.68 +      xassert(save == save);
    1.69 +      return;
    1.70 +}
    1.71 +
    1.72 +void bfx_btran(BFX *binv, mpq_t x[])
    1.73 +{     /* perform backward transformation (BTRAN) */
    1.74 +      xassert(binv->valid);
    1.75 +      lux_solve(binv->lux, 1, x);
    1.76 +      return;
    1.77 +}
    1.78 +
    1.79 +int bfx_update(BFX *binv, int j)
    1.80 +{     /* update factorization of the basis matrix */
    1.81 +      xassert(binv->valid);
    1.82 +      xassert(1 <= j && j <= binv->lux->n);
    1.83 +      return 1;
    1.84 +}
    1.85 +
    1.86 +void bfx_delete_binv(BFX *binv)
    1.87 +{     /* delete factorization of the basis matrix */
    1.88 +      if (binv->lux != NULL)
    1.89 +         lux_delete(binv->lux);
    1.90 +      xfree(binv);
    1.91 +      return;
    1.92 +}
    1.93 +
    1.94 +/* eof */