1 /* glpspm.h (general sparse matrix) */
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <mao@gnu.org>.
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.
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.
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 ***********************************************************************/
30 typedef struct SPM SPM;
31 typedef struct SPME SPME;
34 { /* general sparse matrix */
36 /* number of rows, m >= 0 */
38 /* number of columns, n >= 0 */
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 */
48 { /* sparse matrix element */
56 /* pointer to previous element in the same row */
58 /* pointer to next element in the same row */
60 /* pointer to previous element in the same column */
62 /* pointer to next element in the same column */
65 typedef struct PER PER;
68 { /* permutation matrix */
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 */
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,
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,
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 */