PageRenderTime 24ms CodeModel.GetById 10ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/farmR/src/glpspm.h

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