lemon-project-template-glpk

annotate 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
rev   line source
alpar@9 1 /* glpbfx.c */
alpar@9 2
alpar@9 3 /***********************************************************************
alpar@9 4 * This code is part of GLPK (GNU Linear Programming Kit).
alpar@9 5 *
alpar@9 6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
alpar@9 7 * 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
alpar@9 8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
alpar@9 9 * E-mail: <mao@gnu.org>.
alpar@9 10 *
alpar@9 11 * GLPK is free software: you can redistribute it and/or modify it
alpar@9 12 * under the terms of the GNU General Public License as published by
alpar@9 13 * the Free Software Foundation, either version 3 of the License, or
alpar@9 14 * (at your option) any later version.
alpar@9 15 *
alpar@9 16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
alpar@9 17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
alpar@9 18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
alpar@9 19 * License for more details.
alpar@9 20 *
alpar@9 21 * You should have received a copy of the GNU General Public License
alpar@9 22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
alpar@9 23 ***********************************************************************/
alpar@9 24
alpar@9 25 typedef struct BFX BFX;
alpar@9 26 #define GLPBFX_DEFINED
alpar@9 27 #include "glpbfx.h"
alpar@9 28 #include "glpenv.h"
alpar@9 29 #include "glplux.h"
alpar@9 30
alpar@9 31 struct BFX
alpar@9 32 { int valid;
alpar@9 33 LUX *lux;
alpar@9 34 };
alpar@9 35
alpar@9 36 BFX *bfx_create_binv(void)
alpar@9 37 { /* create factorization of the basis matrix */
alpar@9 38 BFX *bfx;
alpar@9 39 bfx = xmalloc(sizeof(BFX));
alpar@9 40 bfx->valid = 0;
alpar@9 41 bfx->lux = NULL;
alpar@9 42 return bfx;
alpar@9 43 }
alpar@9 44
alpar@9 45 int bfx_factorize(BFX *binv, int m, int (*col)(void *info, int j,
alpar@9 46 int ind[], mpq_t val[]), void *info)
alpar@9 47 { /* compute factorization of the basis matrix */
alpar@9 48 int ret;
alpar@9 49 xassert(m > 0);
alpar@9 50 if (binv->lux != NULL && binv->lux->n != m)
alpar@9 51 { lux_delete(binv->lux);
alpar@9 52 binv->lux = NULL;
alpar@9 53 }
alpar@9 54 if (binv->lux == NULL)
alpar@9 55 binv->lux = lux_create(m);
alpar@9 56 ret = lux_decomp(binv->lux, col, info);
alpar@9 57 binv->valid = (ret == 0);
alpar@9 58 return ret;
alpar@9 59 }
alpar@9 60
alpar@9 61 void bfx_ftran(BFX *binv, mpq_t x[], int save)
alpar@9 62 { /* perform forward transformation (FTRAN) */
alpar@9 63 xassert(binv->valid);
alpar@9 64 lux_solve(binv->lux, 0, x);
alpar@9 65 xassert(save == save);
alpar@9 66 return;
alpar@9 67 }
alpar@9 68
alpar@9 69 void bfx_btran(BFX *binv, mpq_t x[])
alpar@9 70 { /* perform backward transformation (BTRAN) */
alpar@9 71 xassert(binv->valid);
alpar@9 72 lux_solve(binv->lux, 1, x);
alpar@9 73 return;
alpar@9 74 }
alpar@9 75
alpar@9 76 int bfx_update(BFX *binv, int j)
alpar@9 77 { /* update factorization of the basis matrix */
alpar@9 78 xassert(binv->valid);
alpar@9 79 xassert(1 <= j && j <= binv->lux->n);
alpar@9 80 return 1;
alpar@9 81 }
alpar@9 82
alpar@9 83 void bfx_delete_binv(BFX *binv)
alpar@9 84 { /* delete factorization of the basis matrix */
alpar@9 85 if (binv->lux != NULL)
alpar@9 86 lux_delete(binv->lux);
alpar@9 87 xfree(binv);
alpar@9 88 return;
alpar@9 89 }
alpar@9 90
alpar@9 91 /* eof */