4
Copyright (C) 2007 Gabor Csardi <csardi@rmki.kfki.hu>
5
MTA RMKI, Konkoly-Thege Miklos st. 29-33, Budapest 1121, Hungary
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24
typedef struct TYPE(igraph_matrix) {
25
TYPE(igraph_vector) data;
27
} TYPE(igraph_matrix);
33
int FUNCTION(igraph_matrix,init)(TYPE(igraph_matrix) *m,
34
long int nrow, long int ncol);
35
int FUNCTION(igraph_matrix,copy)(TYPE(igraph_matrix) *to,
36
const TYPE(igraph_matrix) *from);
37
void FUNCTION(igraph_matrix,destroy)(TYPE(igraph_matrix) *m);
39
/*--------------------*/
40
/* Accessing elements */
41
/*--------------------*/
44
BASE FUNCTION(igraph_matrix,e)(const TYPE(igraph_matrix) *m,
45
long int row, long int col);
46
BASE* FUNCTION(igraph_matrix,e_ptr)(const TYPE(igraph_matrix) *m,
47
long int row, long int col);
48
void FUNCTION(igraph_matrix,set)(TYPE(igraph_matrix)* m, long int row, long int col,
51
/*------------------------------*/
52
/* Initializing matrix elements */
53
/*------------------------------*/
55
void FUNCTION(igraph_matrix,null)(TYPE(igraph_matrix) *m);
56
void FUNCTION(igraph_matrix,fill)(TYPE(igraph_matrix) *m, BASE e);
58
/*------------------*/
59
/* Copying matrices */
60
/*------------------*/
62
void FUNCTION(igraph_matrix,copy_to)(const TYPE(igraph_matrix) *m, BASE *to);
63
int FUNCTION(igraph_matrix,update)(TYPE(igraph_matrix) *to,
64
const TYPE(igraph_matrix) *from);
65
int FUNCTION(igraph_matrix,rbind)(TYPE(igraph_matrix) *to,
66
const TYPE(igraph_matrix) *from);
67
int FUNCTION(igraph_matrix,cbind)(TYPE(igraph_matrix) *to,
68
const TYPE(igraph_matrix) *from);
69
int FUNCTION(igraph_matrix,swap)(TYPE(igraph_matrix) *m1, TYPE(igraph_matrix) *m2);
71
/*--------------------------*/
72
/* Copying rows and columns */
73
/*--------------------------*/
75
int FUNCTION(igraph_matrix,get_row)(const TYPE(igraph_matrix) *m,
76
TYPE(igraph_vector) *res, long int index);
77
int FUNCTION(igraph_matrix,get_col)(const TYPE(igraph_matrix) *m,
78
TYPE(igraph_vector) *res, long int index);
79
int FUNCTION(igraph_matrix,set_row)(TYPE(igraph_matrix) *m,
80
const TYPE(igraph_vector) *v, long int index);
81
int FUNCTION(igraph_matrix,set_col)(TYPE(igraph_matrix) *m,
82
const TYPE(igraph_vector) *v, long int index);
83
int FUNCTION(igraph_matrix,select_rows)(const TYPE(igraph_matrix) *m,
84
TYPE(igraph_matrix) *res,
85
const igraph_vector_t *rows);
86
int FUNCTION(igraph_matrix,select_cols)(const TYPE(igraph_matrix) *m,
87
TYPE(igraph_matrix) *res,
88
const igraph_vector_t *cols);
90
/*-----------------------------*/
91
/* Exchanging rows and columns */
92
/*-----------------------------*/
94
int FUNCTION(igraph_matrix,swap_rows)(TYPE(igraph_matrix) *m,
95
long int i, long int j);
96
int FUNCTION(igraph_matrix,swap_cols)(TYPE(igraph_matrix) *m,
97
long int i, long int j);
98
int FUNCTION(igraph_matrix,swap_rowcol)(TYPE(igraph_matrix) *m,
99
long int i, long int j);
100
int FUNCTION(igraph_matrix,transpose)(TYPE(igraph_matrix) *m);
102
/*-----------------------------*/
103
/* Matrix operations */
104
/*-----------------------------*/
106
int FUNCTION(igraph_matrix,add)(TYPE(igraph_matrix) *m1,
107
const TYPE(igraph_matrix) *m2);
108
int FUNCTION(igraph_matrix,sub)(TYPE(igraph_matrix) *m1,
109
const TYPE(igraph_matrix) *m2);
110
int FUNCTION(igraph_matrix,mul_elements)(TYPE(igraph_matrix) *m1,
111
const TYPE(igraph_matrix) *m2);
112
int FUNCTION(igraph_matrix,div_elements)(TYPE(igraph_matrix) *m1,
113
const TYPE(igraph_matrix) *m2);
114
void FUNCTION(igraph_matrix,scale)(TYPE(igraph_matrix) *m, BASE by);
115
void FUNCTION(igraph_matrix,add_constant)(TYPE(igraph_matrix) *m, BASE plus);
117
/*-----------------------------*/
118
/* Finding minimum and maximum */
119
/*-----------------------------*/
121
igraph_real_t FUNCTION(igraph_matrix,min)(const TYPE(igraph_matrix) *m);
122
igraph_real_t FUNCTION(igraph_matrix,max)(const TYPE(igraph_matrix) *m);
123
int FUNCTION(igraph_matrix,which_min)(const TYPE(igraph_matrix) *m,
124
long int *i, long int *j);
125
int FUNCTION(igraph_matrix,which_max)(const TYPE(igraph_matrix) *m,
126
long int *i, long int *j);
127
int FUNCTION(igraph_matrix,minmax)(const TYPE(igraph_matrix) *m,
128
BASE *min, BASE *max);
129
int FUNCTION(igraph_matrix,which_minmax)(const TYPE(igraph_matrix) *m,
130
long int *imin, long int *jmin,
131
long int *imax, long int *jmax);
133
/*-------------------*/
134
/* Matrix properties */
135
/*-------------------*/
137
igraph_bool_t FUNCTION(igraph_matrix,isnull)(const TYPE(igraph_matrix) *m);
138
igraph_bool_t FUNCTION(igraph_matrix,empty)(const TYPE(igraph_matrix) *m);
139
long int FUNCTION(igraph_matrix,size)(const TYPE(igraph_matrix) *m);
140
long int FUNCTION(igraph_matrix,nrow)(const TYPE(igraph_matrix) *m);
141
long int FUNCTION(igraph_matrix,ncol)(const TYPE(igraph_matrix) *m);
142
igraph_bool_t FUNCTION(igraph_matrix,is_symmetric)(const TYPE(igraph_matrix) *m);
143
igraph_real_t FUNCTION(igraph_matrix,sum)(const TYPE(igraph_matrix) *m);
144
igraph_real_t FUNCTION(igraph_matrix,prod)(const TYPE(igraph_matrix) *m);
145
int FUNCTION(igraph_matrix,rowsum)(const TYPE(igraph_matrix) *m,
146
igraph_vector_t *res);
147
int FUNCTION(igraph_matrix,colsum)(const TYPE(igraph_matrix) *m,
148
igraph_vector_t *res);
149
igraph_bool_t FUNCTION(igraph_matrix,is_equal)(const TYPE(igraph_matrix) *m1,
150
const TYPE(igraph_matrix) *m2);
151
BASE FUNCTION(igraph_matrix,maxdifference)(const TYPE(igraph_matrix) *m1,
152
const TYPE(igraph_matrix) *m2);
154
/*------------------------*/
155
/* Searching for elements */
156
/*------------------------*/
158
igraph_bool_t FUNCTION(igraph_matrix,contains)(const TYPE(igraph_matrix) *m,
160
igraph_bool_t FUNCTION(igraph_matrix,search)(const TYPE(igraph_matrix) *m,
161
long int from, BASE what,
163
long int *row, long int *col);
165
/*------------------------*/
166
/* Resizing operations */
167
/*------------------------*/
169
int FUNCTION(igraph_matrix,resize)(TYPE(igraph_matrix) *m,
170
long int nrow, long int ncol);
171
int FUNCTION(igraph_matrix,add_cols)(TYPE(igraph_matrix) *m, long int n);
172
int FUNCTION(igraph_matrix,add_rows)(TYPE(igraph_matrix) *m, long int n);
173
int FUNCTION(igraph_matrix,remove_col)(TYPE(igraph_matrix) *m, long int col);
174
int FUNCTION(igraph_matrix,remove_row)(TYPE(igraph_matrix) *m, long int row);
176
/* ----------------------------------------------------------------------------*/
177
/* For internal use only, may be removed, rewritten ... */
178
/* ----------------------------------------------------------------------------*/
180
int FUNCTION(igraph_matrix,permdelete_rows)(TYPE(igraph_matrix) *m,
181
long int *index, long int nremove);
182
int FUNCTION(igraph_matrix,delete_rows_neg)(TYPE(igraph_matrix) *m,
183
const igraph_vector_t *neg,