lemon-project-template-glpk
view 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 source
1 /* glpspm.h (general sparse matrix) */
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 #ifndef GLPSPM_H
26 #define GLPSPM_H
28 #include "glpdmp.h"
30 typedef struct SPM SPM;
31 typedef struct SPME SPME;
33 struct SPM
34 { /* general sparse matrix */
35 int m;
36 /* number of rows, m >= 0 */
37 int n;
38 /* number of columns, n >= 0 */
39 DMP *pool;
40 /* memory pool to store matrix elements */
41 SPME **row; /* SPME *row[1+m]; */
42 /* row[i], 1 <= i <= m, is a pointer to i-th row list */
43 SPME **col; /* SPME *col[1+n]; */
44 /* col[j], 1 <= j <= n, is a pointer to j-th column list */
45 };
47 struct SPME
48 { /* sparse matrix element */
49 int i;
50 /* row number */
51 int j;
52 /* column number */
53 double val;
54 /* element value */
55 SPME *r_prev;
56 /* pointer to previous element in the same row */
57 SPME *r_next;
58 /* pointer to next element in the same row */
59 SPME *c_prev;
60 /* pointer to previous element in the same column */
61 SPME *c_next;
62 /* pointer to next element in the same column */
63 };
65 typedef struct PER PER;
67 struct PER
68 { /* permutation matrix */
69 int n;
70 /* matrix order, n >= 0 */
71 int *row; /* int row[1+n]; */
72 /* row[i] = j means p[i,j] = 1 */
73 int *col; /* int col[1+n]; */
74 /* col[j] = i means p[i,j] = 1 */
75 };
77 #define spm_create_mat _glp_spm_create_mat
78 SPM *spm_create_mat(int m, int n);
79 /* create general sparse matrix */
81 #define spm_new_elem _glp_spm_new_elem
82 SPME *spm_new_elem(SPM *A, int i, int j, double val);
83 /* add new element to sparse matrix */
85 #define spm_delete_mat _glp_spm_delete_mat
86 void spm_delete_mat(SPM *A);
87 /* delete general sparse matrix */
89 #define spm_test_mat_e _glp_spm_test_mat_e
90 SPM *spm_test_mat_e(int n, int c);
91 /* create test sparse matrix of E(n,c) class */
93 #define spm_test_mat_d _glp_spm_test_mat_d
94 SPM *spm_test_mat_d(int n, int c);
95 /* create test sparse matrix of D(n,c) class */
97 #define spm_show_mat _glp_spm_show_mat
98 int spm_show_mat(const SPM *A, const char *fname);
99 /* write sparse matrix pattern in BMP file format */
101 #define spm_read_hbm _glp_spm_read_hbm
102 SPM *spm_read_hbm(const char *fname);
103 /* read sparse matrix in Harwell-Boeing format */
105 #define spm_count_nnz _glp_spm_count_nnz
106 int spm_count_nnz(const SPM *A);
107 /* determine number of non-zeros in sparse matrix */
109 #define spm_drop_zeros _glp_spm_drop_zeros
110 int spm_drop_zeros(SPM *A, double eps);
111 /* remove zero elements from sparse matrix */
113 #define spm_read_mat _glp_spm_read_mat
114 SPM *spm_read_mat(const char *fname);
115 /* read sparse matrix from text file */
117 #define spm_write_mat _glp_spm_write_mat
118 int spm_write_mat(const SPM *A, const char *fname);
119 /* write sparse matrix to text file */
121 #define spm_transpose _glp_spm_transpose
122 SPM *spm_transpose(const SPM *A);
123 /* transpose sparse matrix */
125 #define spm_add_sym _glp_spm_add_sym
126 SPM *spm_add_sym(const SPM *A, const SPM *B);
127 /* add two sparse matrices (symbolic phase) */
129 #define spm_add_num _glp_spm_add_num
130 void spm_add_num(SPM *C, double alfa, const SPM *A, double beta,
131 const SPM *B);
132 /* add two sparse matrices (numeric phase) */
134 #define spm_add_mat _glp_spm_add_mat
135 SPM *spm_add_mat(double alfa, const SPM *A, double beta,
136 const SPM *B);
137 /* add two sparse matrices (driver routine) */
139 #define spm_mul_sym _glp_spm_mul_sym
140 SPM *spm_mul_sym(const SPM *A, const SPM *B);
141 /* multiply two sparse matrices (symbolic phase) */
143 #define spm_mul_num _glp_spm_mul_num
144 void spm_mul_num(SPM *C, const SPM *A, const SPM *B);
145 /* multiply two sparse matrices (numeric phase) */
147 #define spm_mul_mat _glp_spm_mul_mat
148 SPM *spm_mul_mat(const SPM *A, const SPM *B);
149 /* multiply two sparse matrices (driver routine) */
151 #define spm_create_per _glp_spm_create_per
152 PER *spm_create_per(int n);
153 /* create permutation matrix */
155 #define spm_check_per _glp_spm_check_per
156 void spm_check_per(PER *P);
157 /* check permutation matrix for correctness */
159 #define spm_delete_per _glp_spm_delete_per
160 void spm_delete_per(PER *P);
161 /* delete permutation matrix */
163 #endif
165 /* eof */