~ubuntu-branches/ubuntu/lucid/igraph/lucid

« back to all changes in this revision

Viewing changes to include/matrix.h

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Malaterre
  • Date: 2009-11-16 18:12:42 UTC
  • Revision ID: james.westby@ubuntu.com-20091116181242-mzv9p5fz9uj57xd1
Tags: upstream-0.5.3
ImportĀ upstreamĀ versionĀ 0.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C -*-  */
 
2
/* 
 
3
   IGraph library.
 
4
   Copyright (C) 2007  Gabor Csardi <csardi@rmki.kfki.hu>
 
5
   MTA RMKI, Konkoly-Thege Miklos st. 29-33, Budapest 1121, Hungary
 
6
   
 
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.
 
11
   
 
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.
 
16
   
 
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 
 
20
   02110-1301 USA
 
21
 
 
22
*/
 
23
 
 
24
typedef struct TYPE(igraph_matrix) {
 
25
  TYPE(igraph_vector) data;
 
26
  long int nrow, ncol;
 
27
} TYPE(igraph_matrix);
 
28
 
 
29
/*---------------*/
 
30
/* Allocation    */
 
31
/*---------------*/
 
32
 
 
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);
 
38
 
 
39
/*--------------------*/
 
40
/* Accessing elements */
 
41
/*--------------------*/
 
42
 
 
43
/* MATRIX */
 
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,
 
49
                                 BASE value);
 
50
 
 
51
/*------------------------------*/
 
52
/* Initializing matrix elements */
 
53
/*------------------------------*/
 
54
 
 
55
void FUNCTION(igraph_matrix,null)(TYPE(igraph_matrix) *m);
 
56
void FUNCTION(igraph_matrix,fill)(TYPE(igraph_matrix) *m, BASE e);
 
57
 
 
58
/*------------------*/
 
59
/* Copying matrices */
 
60
/*------------------*/
 
61
 
 
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);
 
70
 
 
71
/*--------------------------*/
 
72
/* Copying rows and columns */
 
73
/*--------------------------*/
 
74
 
 
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);
 
89
 
 
90
/*-----------------------------*/
 
91
/* Exchanging rows and columns */
 
92
/*-----------------------------*/
 
93
 
 
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);
 
101
 
 
102
/*-----------------------------*/
 
103
/* Matrix operations           */
 
104
/*-----------------------------*/
 
105
 
 
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);
 
116
 
 
117
/*-----------------------------*/
 
118
/* Finding minimum and maximum */
 
119
/*-----------------------------*/
 
120
 
 
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);
 
132
 
 
133
/*-------------------*/
 
134
/* Matrix properties */
 
135
/*-------------------*/
 
136
 
 
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);
 
153
 
 
154
/*------------------------*/
 
155
/* Searching for elements */
 
156
/*------------------------*/
 
157
 
 
158
igraph_bool_t FUNCTION(igraph_matrix,contains)(const TYPE(igraph_matrix) *m,
 
159
                                               BASE e);
 
160
igraph_bool_t FUNCTION(igraph_matrix,search)(const TYPE(igraph_matrix) *m,
 
161
                                             long int from, BASE what, 
 
162
                                             long int *pos, 
 
163
                                             long int *row, long int *col);
 
164
 
 
165
/*------------------------*/
 
166
/* Resizing operations    */
 
167
/*------------------------*/
 
168
 
 
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);
 
175
 
 
176
/* ----------------------------------------------------------------------------*/
 
177
/* For internal use only, may be removed, rewritten ... */
 
178
/* ----------------------------------------------------------------------------*/
 
179
 
 
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, 
 
184
                                            long int nremove);
 
185