alpar@9: /* glpbfx.c */ alpar@9: alpar@9: /*********************************************************************** alpar@9: * This code is part of GLPK (GNU Linear Programming Kit). alpar@9: * alpar@9: * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, alpar@9: * 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics, alpar@9: * Moscow Aviation Institute, Moscow, Russia. All rights reserved. alpar@9: * E-mail: . alpar@9: * alpar@9: * GLPK is free software: you can redistribute it and/or modify it alpar@9: * under the terms of the GNU General Public License as published by alpar@9: * the Free Software Foundation, either version 3 of the License, or alpar@9: * (at your option) any later version. alpar@9: * alpar@9: * GLPK is distributed in the hope that it will be useful, but WITHOUT alpar@9: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY alpar@9: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public alpar@9: * License for more details. alpar@9: * alpar@9: * You should have received a copy of the GNU General Public License alpar@9: * along with GLPK. If not, see . alpar@9: ***********************************************************************/ alpar@9: alpar@9: typedef struct BFX BFX; alpar@9: #define GLPBFX_DEFINED alpar@9: #include "glpbfx.h" alpar@9: #include "glpenv.h" alpar@9: #include "glplux.h" alpar@9: alpar@9: struct BFX alpar@9: { int valid; alpar@9: LUX *lux; alpar@9: }; alpar@9: alpar@9: BFX *bfx_create_binv(void) alpar@9: { /* create factorization of the basis matrix */ alpar@9: BFX *bfx; alpar@9: bfx = xmalloc(sizeof(BFX)); alpar@9: bfx->valid = 0; alpar@9: bfx->lux = NULL; alpar@9: return bfx; alpar@9: } alpar@9: alpar@9: int bfx_factorize(BFX *binv, int m, int (*col)(void *info, int j, alpar@9: int ind[], mpq_t val[]), void *info) alpar@9: { /* compute factorization of the basis matrix */ alpar@9: int ret; alpar@9: xassert(m > 0); alpar@9: if (binv->lux != NULL && binv->lux->n != m) alpar@9: { lux_delete(binv->lux); alpar@9: binv->lux = NULL; alpar@9: } alpar@9: if (binv->lux == NULL) alpar@9: binv->lux = lux_create(m); alpar@9: ret = lux_decomp(binv->lux, col, info); alpar@9: binv->valid = (ret == 0); alpar@9: return ret; alpar@9: } alpar@9: alpar@9: void bfx_ftran(BFX *binv, mpq_t x[], int save) alpar@9: { /* perform forward transformation (FTRAN) */ alpar@9: xassert(binv->valid); alpar@9: lux_solve(binv->lux, 0, x); alpar@9: xassert(save == save); alpar@9: return; alpar@9: } alpar@9: alpar@9: void bfx_btran(BFX *binv, mpq_t x[]) alpar@9: { /* perform backward transformation (BTRAN) */ alpar@9: xassert(binv->valid); alpar@9: lux_solve(binv->lux, 1, x); alpar@9: return; alpar@9: } alpar@9: alpar@9: int bfx_update(BFX *binv, int j) alpar@9: { /* update factorization of the basis matrix */ alpar@9: xassert(binv->valid); alpar@9: xassert(1 <= j && j <= binv->lux->n); alpar@9: return 1; alpar@9: } alpar@9: alpar@9: void bfx_delete_binv(BFX *binv) alpar@9: { /* delete factorization of the basis matrix */ alpar@9: if (binv->lux != NULL) alpar@9: lux_delete(binv->lux); alpar@9: xfree(binv); alpar@9: return; alpar@9: } alpar@9: alpar@9: /* eof */