alpar@1: /* glpbfx.c */ 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: typedef struct BFX BFX; alpar@1: #define GLPBFX_DEFINED alpar@1: #include "glpbfx.h" alpar@1: #include "glpenv.h" alpar@1: #include "glplux.h" alpar@1: alpar@1: struct BFX alpar@1: { int valid; alpar@1: LUX *lux; alpar@1: }; alpar@1: alpar@1: BFX *bfx_create_binv(void) alpar@1: { /* create factorization of the basis matrix */ alpar@1: BFX *bfx; alpar@1: bfx = xmalloc(sizeof(BFX)); alpar@1: bfx->valid = 0; alpar@1: bfx->lux = NULL; alpar@1: return bfx; alpar@1: } alpar@1: alpar@1: int bfx_factorize(BFX *binv, int m, int (*col)(void *info, int j, alpar@1: int ind[], mpq_t val[]), void *info) alpar@1: { /* compute factorization of the basis matrix */ alpar@1: int ret; alpar@1: xassert(m > 0); alpar@1: if (binv->lux != NULL && binv->lux->n != m) alpar@1: { lux_delete(binv->lux); alpar@1: binv->lux = NULL; alpar@1: } alpar@1: if (binv->lux == NULL) alpar@1: binv->lux = lux_create(m); alpar@1: ret = lux_decomp(binv->lux, col, info); alpar@1: binv->valid = (ret == 0); alpar@1: return ret; alpar@1: } alpar@1: alpar@1: void bfx_ftran(BFX *binv, mpq_t x[], int save) alpar@1: { /* perform forward transformation (FTRAN) */ alpar@1: xassert(binv->valid); alpar@1: lux_solve(binv->lux, 0, x); alpar@1: xassert(save == save); alpar@1: return; alpar@1: } alpar@1: alpar@1: void bfx_btran(BFX *binv, mpq_t x[]) alpar@1: { /* perform backward transformation (BTRAN) */ alpar@1: xassert(binv->valid); alpar@1: lux_solve(binv->lux, 1, x); alpar@1: return; alpar@1: } alpar@1: alpar@1: int bfx_update(BFX *binv, int j) alpar@1: { /* update factorization of the basis matrix */ alpar@1: xassert(binv->valid); alpar@1: xassert(1 <= j && j <= binv->lux->n); alpar@1: return 1; alpar@1: } alpar@1: alpar@1: void bfx_delete_binv(BFX *binv) alpar@1: { /* delete factorization of the basis matrix */ alpar@1: if (binv->lux != NULL) alpar@1: lux_delete(binv->lux); alpar@1: xfree(binv); alpar@1: return; alpar@1: } alpar@1: alpar@1: /* eof */