lemon-project-template-glpk

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