lemon-project-template-glpk

annotate deps/glpk/src/glpspm.h @ 11:4fc6ad2fb8a6

Test GLPK in src/main.cc
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 21:43:29 +0100
parents
children
rev   line source
alpar@9 1 /* glpspm.h (general sparse matrix) */
alpar@9 2
alpar@9 3 /***********************************************************************
alpar@9 4 * This code is part of GLPK (GNU Linear Programming Kit).
alpar@9 5 *
alpar@9 6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
alpar@9 7 * 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
alpar@9 8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
alpar@9 9 * E-mail: <mao@gnu.org>.
alpar@9 10 *
alpar@9 11 * GLPK is free software: you can redistribute it and/or modify it
alpar@9 12 * under the terms of the GNU General Public License as published by
alpar@9 13 * the Free Software Foundation, either version 3 of the License, or
alpar@9 14 * (at your option) any later version.
alpar@9 15 *
alpar@9 16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
alpar@9 17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
alpar@9 18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
alpar@9 19 * License for more details.
alpar@9 20 *
alpar@9 21 * You should have received a copy of the GNU General Public License
alpar@9 22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
alpar@9 23 ***********************************************************************/
alpar@9 24
alpar@9 25 #ifndef GLPSPM_H
alpar@9 26 #define GLPSPM_H
alpar@9 27
alpar@9 28 #include "glpdmp.h"
alpar@9 29
alpar@9 30 typedef struct SPM SPM;
alpar@9 31 typedef struct SPME SPME;
alpar@9 32
alpar@9 33 struct SPM
alpar@9 34 { /* general sparse matrix */
alpar@9 35 int m;
alpar@9 36 /* number of rows, m >= 0 */
alpar@9 37 int n;
alpar@9 38 /* number of columns, n >= 0 */
alpar@9 39 DMP *pool;
alpar@9 40 /* memory pool to store matrix elements */
alpar@9 41 SPME **row; /* SPME *row[1+m]; */
alpar@9 42 /* row[i], 1 <= i <= m, is a pointer to i-th row list */
alpar@9 43 SPME **col; /* SPME *col[1+n]; */
alpar@9 44 /* col[j], 1 <= j <= n, is a pointer to j-th column list */
alpar@9 45 };
alpar@9 46
alpar@9 47 struct SPME
alpar@9 48 { /* sparse matrix element */
alpar@9 49 int i;
alpar@9 50 /* row number */
alpar@9 51 int j;
alpar@9 52 /* column number */
alpar@9 53 double val;
alpar@9 54 /* element value */
alpar@9 55 SPME *r_prev;
alpar@9 56 /* pointer to previous element in the same row */
alpar@9 57 SPME *r_next;
alpar@9 58 /* pointer to next element in the same row */
alpar@9 59 SPME *c_prev;
alpar@9 60 /* pointer to previous element in the same column */
alpar@9 61 SPME *c_next;
alpar@9 62 /* pointer to next element in the same column */
alpar@9 63 };
alpar@9 64
alpar@9 65 typedef struct PER PER;
alpar@9 66
alpar@9 67 struct PER
alpar@9 68 { /* permutation matrix */
alpar@9 69 int n;
alpar@9 70 /* matrix order, n >= 0 */
alpar@9 71 int *row; /* int row[1+n]; */
alpar@9 72 /* row[i] = j means p[i,j] = 1 */
alpar@9 73 int *col; /* int col[1+n]; */
alpar@9 74 /* col[j] = i means p[i,j] = 1 */
alpar@9 75 };
alpar@9 76
alpar@9 77 #define spm_create_mat _glp_spm_create_mat
alpar@9 78 SPM *spm_create_mat(int m, int n);
alpar@9 79 /* create general sparse matrix */
alpar@9 80
alpar@9 81 #define spm_new_elem _glp_spm_new_elem
alpar@9 82 SPME *spm_new_elem(SPM *A, int i, int j, double val);
alpar@9 83 /* add new element to sparse matrix */
alpar@9 84
alpar@9 85 #define spm_delete_mat _glp_spm_delete_mat
alpar@9 86 void spm_delete_mat(SPM *A);
alpar@9 87 /* delete general sparse matrix */
alpar@9 88
alpar@9 89 #define spm_test_mat_e _glp_spm_test_mat_e
alpar@9 90 SPM *spm_test_mat_e(int n, int c);
alpar@9 91 /* create test sparse matrix of E(n,c) class */
alpar@9 92
alpar@9 93 #define spm_test_mat_d _glp_spm_test_mat_d
alpar@9 94 SPM *spm_test_mat_d(int n, int c);
alpar@9 95 /* create test sparse matrix of D(n,c) class */
alpar@9 96
alpar@9 97 #define spm_show_mat _glp_spm_show_mat
alpar@9 98 int spm_show_mat(const SPM *A, const char *fname);
alpar@9 99 /* write sparse matrix pattern in BMP file format */
alpar@9 100
alpar@9 101 #define spm_read_hbm _glp_spm_read_hbm
alpar@9 102 SPM *spm_read_hbm(const char *fname);
alpar@9 103 /* read sparse matrix in Harwell-Boeing format */
alpar@9 104
alpar@9 105 #define spm_count_nnz _glp_spm_count_nnz
alpar@9 106 int spm_count_nnz(const SPM *A);
alpar@9 107 /* determine number of non-zeros in sparse matrix */
alpar@9 108
alpar@9 109 #define spm_drop_zeros _glp_spm_drop_zeros
alpar@9 110 int spm_drop_zeros(SPM *A, double eps);
alpar@9 111 /* remove zero elements from sparse matrix */
alpar@9 112
alpar@9 113 #define spm_read_mat _glp_spm_read_mat
alpar@9 114 SPM *spm_read_mat(const char *fname);
alpar@9 115 /* read sparse matrix from text file */
alpar@9 116
alpar@9 117 #define spm_write_mat _glp_spm_write_mat
alpar@9 118 int spm_write_mat(const SPM *A, const char *fname);
alpar@9 119 /* write sparse matrix to text file */
alpar@9 120
alpar@9 121 #define spm_transpose _glp_spm_transpose
alpar@9 122 SPM *spm_transpose(const SPM *A);
alpar@9 123 /* transpose sparse matrix */
alpar@9 124
alpar@9 125 #define spm_add_sym _glp_spm_add_sym
alpar@9 126 SPM *spm_add_sym(const SPM *A, const SPM *B);
alpar@9 127 /* add two sparse matrices (symbolic phase) */
alpar@9 128
alpar@9 129 #define spm_add_num _glp_spm_add_num
alpar@9 130 void spm_add_num(SPM *C, double alfa, const SPM *A, double beta,
alpar@9 131 const SPM *B);
alpar@9 132 /* add two sparse matrices (numeric phase) */
alpar@9 133
alpar@9 134 #define spm_add_mat _glp_spm_add_mat
alpar@9 135 SPM *spm_add_mat(double alfa, const SPM *A, double beta,
alpar@9 136 const SPM *B);
alpar@9 137 /* add two sparse matrices (driver routine) */
alpar@9 138
alpar@9 139 #define spm_mul_sym _glp_spm_mul_sym
alpar@9 140 SPM *spm_mul_sym(const SPM *A, const SPM *B);
alpar@9 141 /* multiply two sparse matrices (symbolic phase) */
alpar@9 142
alpar@9 143 #define spm_mul_num _glp_spm_mul_num
alpar@9 144 void spm_mul_num(SPM *C, const SPM *A, const SPM *B);
alpar@9 145 /* multiply two sparse matrices (numeric phase) */
alpar@9 146
alpar@9 147 #define spm_mul_mat _glp_spm_mul_mat
alpar@9 148 SPM *spm_mul_mat(const SPM *A, const SPM *B);
alpar@9 149 /* multiply two sparse matrices (driver routine) */
alpar@9 150
alpar@9 151 #define spm_create_per _glp_spm_create_per
alpar@9 152 PER *spm_create_per(int n);
alpar@9 153 /* create permutation matrix */
alpar@9 154
alpar@9 155 #define spm_check_per _glp_spm_check_per
alpar@9 156 void spm_check_per(PER *P);
alpar@9 157 /* check permutation matrix for correctness */
alpar@9 158
alpar@9 159 #define spm_delete_per _glp_spm_delete_per
alpar@9 160 void spm_delete_per(PER *P);
alpar@9 161 /* delete permutation matrix */
alpar@9 162
alpar@9 163 #endif
alpar@9 164
alpar@9 165 /* eof */