lemon-project-template-glpk
diff deps/glpk/src/glpspm.h @ 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/glpspm.h Sun Nov 06 20:59:10 2011 +0100 1.3 @@ -0,0 +1,165 @@ 1.4 +/* glpspm.h (general sparse matrix) */ 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 +#ifndef GLPSPM_H 1.29 +#define GLPSPM_H 1.30 + 1.31 +#include "glpdmp.h" 1.32 + 1.33 +typedef struct SPM SPM; 1.34 +typedef struct SPME SPME; 1.35 + 1.36 +struct SPM 1.37 +{ /* general sparse matrix */ 1.38 + int m; 1.39 + /* number of rows, m >= 0 */ 1.40 + int n; 1.41 + /* number of columns, n >= 0 */ 1.42 + DMP *pool; 1.43 + /* memory pool to store matrix elements */ 1.44 + SPME **row; /* SPME *row[1+m]; */ 1.45 + /* row[i], 1 <= i <= m, is a pointer to i-th row list */ 1.46 + SPME **col; /* SPME *col[1+n]; */ 1.47 + /* col[j], 1 <= j <= n, is a pointer to j-th column list */ 1.48 +}; 1.49 + 1.50 +struct SPME 1.51 +{ /* sparse matrix element */ 1.52 + int i; 1.53 + /* row number */ 1.54 + int j; 1.55 + /* column number */ 1.56 + double val; 1.57 + /* element value */ 1.58 + SPME *r_prev; 1.59 + /* pointer to previous element in the same row */ 1.60 + SPME *r_next; 1.61 + /* pointer to next element in the same row */ 1.62 + SPME *c_prev; 1.63 + /* pointer to previous element in the same column */ 1.64 + SPME *c_next; 1.65 + /* pointer to next element in the same column */ 1.66 +}; 1.67 + 1.68 +typedef struct PER PER; 1.69 + 1.70 +struct PER 1.71 +{ /* permutation matrix */ 1.72 + int n; 1.73 + /* matrix order, n >= 0 */ 1.74 + int *row; /* int row[1+n]; */ 1.75 + /* row[i] = j means p[i,j] = 1 */ 1.76 + int *col; /* int col[1+n]; */ 1.77 + /* col[j] = i means p[i,j] = 1 */ 1.78 +}; 1.79 + 1.80 +#define spm_create_mat _glp_spm_create_mat 1.81 +SPM *spm_create_mat(int m, int n); 1.82 +/* create general sparse matrix */ 1.83 + 1.84 +#define spm_new_elem _glp_spm_new_elem 1.85 +SPME *spm_new_elem(SPM *A, int i, int j, double val); 1.86 +/* add new element to sparse matrix */ 1.87 + 1.88 +#define spm_delete_mat _glp_spm_delete_mat 1.89 +void spm_delete_mat(SPM *A); 1.90 +/* delete general sparse matrix */ 1.91 + 1.92 +#define spm_test_mat_e _glp_spm_test_mat_e 1.93 +SPM *spm_test_mat_e(int n, int c); 1.94 +/* create test sparse matrix of E(n,c) class */ 1.95 + 1.96 +#define spm_test_mat_d _glp_spm_test_mat_d 1.97 +SPM *spm_test_mat_d(int n, int c); 1.98 +/* create test sparse matrix of D(n,c) class */ 1.99 + 1.100 +#define spm_show_mat _glp_spm_show_mat 1.101 +int spm_show_mat(const SPM *A, const char *fname); 1.102 +/* write sparse matrix pattern in BMP file format */ 1.103 + 1.104 +#define spm_read_hbm _glp_spm_read_hbm 1.105 +SPM *spm_read_hbm(const char *fname); 1.106 +/* read sparse matrix in Harwell-Boeing format */ 1.107 + 1.108 +#define spm_count_nnz _glp_spm_count_nnz 1.109 +int spm_count_nnz(const SPM *A); 1.110 +/* determine number of non-zeros in sparse matrix */ 1.111 + 1.112 +#define spm_drop_zeros _glp_spm_drop_zeros 1.113 +int spm_drop_zeros(SPM *A, double eps); 1.114 +/* remove zero elements from sparse matrix */ 1.115 + 1.116 +#define spm_read_mat _glp_spm_read_mat 1.117 +SPM *spm_read_mat(const char *fname); 1.118 +/* read sparse matrix from text file */ 1.119 + 1.120 +#define spm_write_mat _glp_spm_write_mat 1.121 +int spm_write_mat(const SPM *A, const char *fname); 1.122 +/* write sparse matrix to text file */ 1.123 + 1.124 +#define spm_transpose _glp_spm_transpose 1.125 +SPM *spm_transpose(const SPM *A); 1.126 +/* transpose sparse matrix */ 1.127 + 1.128 +#define spm_add_sym _glp_spm_add_sym 1.129 +SPM *spm_add_sym(const SPM *A, const SPM *B); 1.130 +/* add two sparse matrices (symbolic phase) */ 1.131 + 1.132 +#define spm_add_num _glp_spm_add_num 1.133 +void spm_add_num(SPM *C, double alfa, const SPM *A, double beta, 1.134 + const SPM *B); 1.135 +/* add two sparse matrices (numeric phase) */ 1.136 + 1.137 +#define spm_add_mat _glp_spm_add_mat 1.138 +SPM *spm_add_mat(double alfa, const SPM *A, double beta, 1.139 + const SPM *B); 1.140 +/* add two sparse matrices (driver routine) */ 1.141 + 1.142 +#define spm_mul_sym _glp_spm_mul_sym 1.143 +SPM *spm_mul_sym(const SPM *A, const SPM *B); 1.144 +/* multiply two sparse matrices (symbolic phase) */ 1.145 + 1.146 +#define spm_mul_num _glp_spm_mul_num 1.147 +void spm_mul_num(SPM *C, const SPM *A, const SPM *B); 1.148 +/* multiply two sparse matrices (numeric phase) */ 1.149 + 1.150 +#define spm_mul_mat _glp_spm_mul_mat 1.151 +SPM *spm_mul_mat(const SPM *A, const SPM *B); 1.152 +/* multiply two sparse matrices (driver routine) */ 1.153 + 1.154 +#define spm_create_per _glp_spm_create_per 1.155 +PER *spm_create_per(int n); 1.156 +/* create permutation matrix */ 1.157 + 1.158 +#define spm_check_per _glp_spm_check_per 1.159 +void spm_check_per(PER *P); 1.160 +/* check permutation matrix for correctness */ 1.161 + 1.162 +#define spm_delete_per _glp_spm_delete_per 1.163 +void spm_delete_per(PER *P); 1.164 +/* delete permutation matrix */ 1.165 + 1.166 +#endif 1.167 + 1.168 +/* eof */