idamnjanovic@51
|
1 /**************************************************************************
|
idamnjanovic@51
|
2 *
|
idamnjanovic@51
|
3 * File name: myblas.h
|
idamnjanovic@51
|
4 *
|
idamnjanovic@51
|
5 * Ron Rubinstein
|
idamnjanovic@51
|
6 * Computer Science Department
|
idamnjanovic@51
|
7 * Technion, Haifa 32000 Israel
|
idamnjanovic@51
|
8 * ronrubin@cs
|
idamnjanovic@51
|
9 *
|
idamnjanovic@51
|
10 * Version: 1.1
|
idamnjanovic@51
|
11 * Last updated: 17.8.2009
|
idamnjanovic@51
|
12 *
|
idamnjanovic@51
|
13 * A collection of basic linear algebra functions, in the spirit of the
|
idamnjanovic@51
|
14 * BLAS/LAPACK libraries.
|
idamnjanovic@51
|
15 *
|
idamnjanovic@51
|
16 *************************************************************************/
|
idamnjanovic@51
|
17
|
idamnjanovic@51
|
18
|
idamnjanovic@51
|
19
|
idamnjanovic@51
|
20 #ifndef __MY_BLAS_H__
|
idamnjanovic@51
|
21 #define __MY_BLAS_H__
|
idamnjanovic@51
|
22
|
idamnjanovic@51
|
23
|
idamnjanovic@51
|
24 #include "mex.h"
|
idamnjanovic@51
|
25 #include <math.h>
|
idamnjanovic@51
|
26
|
idamnjanovic@51
|
27
|
idamnjanovic@51
|
28
|
idamnjanovic@51
|
29 /**************************************************************************
|
idamnjanovic@51
|
30 * Squared value.
|
idamnjanovic@51
|
31 **************************************************************************/
|
idamnjanovic@51
|
32 #define SQR(X) ((X)*(X))
|
idamnjanovic@51
|
33
|
idamnjanovic@51
|
34
|
idamnjanovic@51
|
35
|
idamnjanovic@51
|
36 /**************************************************************************
|
idamnjanovic@51
|
37 * Matrix-vector multiplication.
|
idamnjanovic@51
|
38 *
|
idamnjanovic@51
|
39 * Computes an operation of the form:
|
idamnjanovic@51
|
40 *
|
idamnjanovic@51
|
41 * y := alpha*A*x
|
idamnjanovic@51
|
42 *
|
idamnjanovic@51
|
43 * Parameters:
|
idamnjanovic@51
|
44 * A - matrix of size n X m
|
idamnjanovic@51
|
45 * x - vector of length m
|
idamnjanovic@51
|
46 * y - output vector of length n
|
idamnjanovic@51
|
47 * alpha - real constant
|
idamnjanovic@51
|
48 * n, m - dimensions of A
|
idamnjanovic@51
|
49 *
|
idamnjanovic@51
|
50 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
51 *
|
idamnjanovic@51
|
52 **************************************************************************/
|
idamnjanovic@51
|
53 void mat_vec(double alpha, double A[], double x[], double y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
54
|
idamnjanovic@51
|
55
|
idamnjanovic@51
|
56
|
idamnjanovic@51
|
57 /**************************************************************************
|
idamnjanovic@51
|
58 * Matrix-transpose-vector multiplication.
|
idamnjanovic@51
|
59 *
|
idamnjanovic@51
|
60 * Computes an operation of the form:
|
idamnjanovic@51
|
61 *
|
idamnjanovic@51
|
62 * y := alpha*A'*x
|
idamnjanovic@51
|
63 *
|
idamnjanovic@51
|
64 * Parameters:
|
idamnjanovic@51
|
65 * A - matrix of size n X m
|
idamnjanovic@51
|
66 * x - vector of length n
|
idamnjanovic@51
|
67 * y - output vector of length m
|
idamnjanovic@51
|
68 * alpha - real constant
|
idamnjanovic@51
|
69 * n, m - dimensions of A
|
idamnjanovic@51
|
70 *
|
idamnjanovic@51
|
71 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
72 *
|
idamnjanovic@51
|
73 **************************************************************************/
|
idamnjanovic@51
|
74 void matT_vec(double alpha, double A[], double x[], double y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
75
|
idamnjanovic@51
|
76
|
idamnjanovic@51
|
77
|
idamnjanovic@51
|
78 /**************************************************************************
|
idamnjanovic@51
|
79 * Sparse-matrix-vector multiplication.
|
idamnjanovic@51
|
80 *
|
idamnjanovic@51
|
81 * Computes an operation of the form:
|
idamnjanovic@51
|
82 *
|
idamnjanovic@51
|
83 * y := alpha*A*x
|
idamnjanovic@51
|
84 *
|
idamnjanovic@51
|
85 * where A is a sparse matrix.
|
idamnjanovic@51
|
86 *
|
idamnjanovic@51
|
87 * Parameters:
|
idamnjanovic@51
|
88 * pr,ir,jc - sparse representation of the matrix A, of size n x m
|
idamnjanovic@51
|
89 * x - vector of length m
|
idamnjanovic@51
|
90 * y - output vector of length n
|
idamnjanovic@51
|
91 * alpha - real constant
|
idamnjanovic@51
|
92 * n, m - dimensions of A
|
idamnjanovic@51
|
93 *
|
idamnjanovic@51
|
94 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
95 *
|
idamnjanovic@51
|
96 **************************************************************************/
|
idamnjanovic@51
|
97 void mat_sp_vec(double alpha, double pr[], mwIndex ir[], mwIndex jc[], double x[], double y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
98
|
idamnjanovic@51
|
99
|
idamnjanovic@51
|
100
|
idamnjanovic@51
|
101 /**************************************************************************
|
idamnjanovic@51
|
102 * Sparse-matrix-transpose-vector multiplication.
|
idamnjanovic@51
|
103 *
|
idamnjanovic@51
|
104 * Computes an operation of the form:
|
idamnjanovic@51
|
105 *
|
idamnjanovic@51
|
106 * y := alpha*A'*x
|
idamnjanovic@51
|
107 *
|
idamnjanovic@51
|
108 * where A is a sparse matrix.
|
idamnjanovic@51
|
109 *
|
idamnjanovic@51
|
110 * Parameters:
|
idamnjanovic@51
|
111 * pr,ir,jc - sparse representation of the matrix A, of size n x m
|
idamnjanovic@51
|
112 * x - vector of length m
|
idamnjanovic@51
|
113 * y - output vector of length n
|
idamnjanovic@51
|
114 * alpha - real constant
|
idamnjanovic@51
|
115 * n, m - dimensions of A
|
idamnjanovic@51
|
116 *
|
idamnjanovic@51
|
117 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
118 *
|
idamnjanovic@51
|
119 **************************************************************************/
|
idamnjanovic@51
|
120 void matT_sp_vec(double alpha, double pr[], mwIndex ir[], mwIndex jc[], double x[], double y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
121
|
idamnjanovic@51
|
122
|
idamnjanovic@51
|
123
|
idamnjanovic@51
|
124 /**************************************************************************
|
idamnjanovic@51
|
125 * Matrix-sparse-vector multiplication.
|
idamnjanovic@51
|
126 *
|
idamnjanovic@51
|
127 * Computes an operation of the form:
|
idamnjanovic@51
|
128 *
|
idamnjanovic@51
|
129 * y := alpha*A*x
|
idamnjanovic@51
|
130 *
|
idamnjanovic@51
|
131 * where A is a matrix and x is a sparse vector.
|
idamnjanovic@51
|
132 *
|
idamnjanovic@51
|
133 * Parameters:
|
idamnjanovic@51
|
134 * A - matrix of size n X m
|
idamnjanovic@51
|
135 * pr,ir,jc - sparse representation of the vector x, of length m
|
idamnjanovic@51
|
136 * y - output vector of length n
|
idamnjanovic@51
|
137 * alpha - real constant
|
idamnjanovic@51
|
138 * n, m - dimensions of A
|
idamnjanovic@51
|
139 *
|
idamnjanovic@51
|
140 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
141 *
|
idamnjanovic@51
|
142 **************************************************************************/
|
idamnjanovic@51
|
143 void mat_vec_sp(double alpha, double A[], double pr[], mwIndex ir[], mwIndex jc[], double y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
144
|
idamnjanovic@51
|
145
|
idamnjanovic@51
|
146
|
idamnjanovic@51
|
147 /**************************************************************************
|
idamnjanovic@51
|
148 * Matrix-transpose-sparse-vector multiplication.
|
idamnjanovic@51
|
149 *
|
idamnjanovic@51
|
150 * Computes an operation of the form:
|
idamnjanovic@51
|
151 *
|
idamnjanovic@51
|
152 * y := alpha*A'*x
|
idamnjanovic@51
|
153 *
|
idamnjanovic@51
|
154 * where A is a matrix and x is a sparse vector.
|
idamnjanovic@51
|
155 *
|
idamnjanovic@51
|
156 * Parameters:
|
idamnjanovic@51
|
157 * A - matrix of size n X m
|
idamnjanovic@51
|
158 * pr,ir,jc - sparse representation of the vector x, of length n
|
idamnjanovic@51
|
159 * y - output vector of length m
|
idamnjanovic@51
|
160 * alpha - real constant
|
idamnjanovic@51
|
161 * n, m - dimensions of A
|
idamnjanovic@51
|
162 *
|
idamnjanovic@51
|
163 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
164 *
|
idamnjanovic@51
|
165 **************************************************************************/
|
idamnjanovic@51
|
166 void matT_vec_sp(double alpha, double A[], double pr[], mwIndex ir[], mwIndex jc[], double y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
167
|
idamnjanovic@51
|
168
|
idamnjanovic@51
|
169
|
idamnjanovic@51
|
170 /**************************************************************************
|
idamnjanovic@51
|
171 * Sparse-matrix-sparse-vector multiplication.
|
idamnjanovic@51
|
172 *
|
idamnjanovic@51
|
173 * Computes an operation of the form:
|
idamnjanovic@51
|
174 *
|
idamnjanovic@51
|
175 * y := alpha*A*x
|
idamnjanovic@51
|
176 *
|
idamnjanovic@51
|
177 * where A is a sparse matrix and x is a sparse vector.
|
idamnjanovic@51
|
178 *
|
idamnjanovic@51
|
179 * Parameters:
|
idamnjanovic@51
|
180 * pr,ir,jc - sparse representation of the matrix A, of size n x m
|
idamnjanovic@51
|
181 * prx,irx,jcx - sparse representation of the vector x (of length m)
|
idamnjanovic@51
|
182 * y - output vector of length n
|
idamnjanovic@51
|
183 * alpha - real constant
|
idamnjanovic@51
|
184 * n, m - dimensions of A
|
idamnjanovic@51
|
185 *
|
idamnjanovic@51
|
186 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
187 *
|
idamnjanovic@51
|
188 **************************************************************************/
|
idamnjanovic@51
|
189 void mat_sp_vec_sp(double alpha, double pr[], mwIndex ir[], mwIndex jc[], double prx[], mwIndex irx[], mwIndex jcx[], double y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
190
|
idamnjanovic@51
|
191
|
idamnjanovic@51
|
192
|
idamnjanovic@51
|
193 /**************************************************************************
|
idamnjanovic@51
|
194 * Sparse-matrix-transpose-sparse-vector multiplication.
|
idamnjanovic@51
|
195 *
|
idamnjanovic@51
|
196 * Computes an operation of the form:
|
idamnjanovic@51
|
197 *
|
idamnjanovic@51
|
198 * y := alpha*A'*x
|
idamnjanovic@51
|
199 *
|
idamnjanovic@51
|
200 * where A is a sparse matrix and x is a sparse vector.
|
idamnjanovic@51
|
201 *
|
idamnjanovic@51
|
202 * Importnant note: this function is provided for completeness, but is NOT efficient.
|
idamnjanovic@51
|
203 * If possible, convert x to non-sparse representation and use matT_vec_sp instead.
|
idamnjanovic@51
|
204 *
|
idamnjanovic@51
|
205 * Parameters:
|
idamnjanovic@51
|
206 * pr,ir,jc - sparse representation of the matrix A, of size n x m
|
idamnjanovic@51
|
207 * prx,irx,jcx - sparse representation of the vector x (of length n)
|
idamnjanovic@51
|
208 * y - output vector of length n
|
idamnjanovic@51
|
209 * alpha - real constant
|
idamnjanovic@51
|
210 * n, m - dimensions of A
|
idamnjanovic@51
|
211 *
|
idamnjanovic@51
|
212 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
213 *
|
idamnjanovic@51
|
214 **************************************************************************/
|
idamnjanovic@51
|
215 void matT_sp_vec_sp(double alpha, double pr[], mwIndex ir[], mwIndex jc[], double prx[], mwIndex irx[], mwIndex jcx[], double y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
216
|
idamnjanovic@51
|
217
|
idamnjanovic@51
|
218
|
idamnjanovic@51
|
219 /**************************************************************************
|
idamnjanovic@51
|
220 * Matrix-matrix multiplication.
|
idamnjanovic@51
|
221 *
|
idamnjanovic@51
|
222 * Computes an operation of the form:
|
idamnjanovic@51
|
223 *
|
idamnjanovic@51
|
224 * X := alpha*A*B
|
idamnjanovic@51
|
225 *
|
idamnjanovic@51
|
226 * Parameters:
|
idamnjanovic@51
|
227 * A - matrix of size n X m
|
idamnjanovic@51
|
228 * B - matrix of size m X k
|
idamnjanovic@51
|
229 * X - output matrix of size n X k
|
idamnjanovic@51
|
230 * alpha - real constant
|
idamnjanovic@51
|
231 * n, m, k - dimensions of A, B
|
idamnjanovic@51
|
232 *
|
idamnjanovic@51
|
233 * Note: This function re-writes the contents of X.
|
idamnjanovic@51
|
234 *
|
idamnjanovic@51
|
235 **************************************************************************/
|
idamnjanovic@51
|
236 void mat_mat(double alpha, double A[], double B[], double X[], mwSize n, mwSize m, mwSize k);
|
idamnjanovic@51
|
237
|
idamnjanovic@51
|
238
|
idamnjanovic@51
|
239
|
idamnjanovic@51
|
240 /**************************************************************************
|
idamnjanovic@51
|
241 * Matrix-transpose-matrix multiplication.
|
idamnjanovic@51
|
242 *
|
idamnjanovic@51
|
243 * Computes an operation of the form:
|
idamnjanovic@51
|
244 *
|
idamnjanovic@51
|
245 * X := alpha*A*B
|
idamnjanovic@51
|
246 *
|
idamnjanovic@51
|
247 * Parameters:
|
idamnjanovic@51
|
248 * A - matrix of size n X m
|
idamnjanovic@51
|
249 * B - matrix of size m X k
|
idamnjanovic@51
|
250 * X - output matrix of size n X k
|
idamnjanovic@51
|
251 * alpha - real constant
|
idamnjanovic@51
|
252 * n, m, k - dimensions of A, B
|
idamnjanovic@51
|
253 *
|
idamnjanovic@51
|
254 * Note: This function re-writes the contents of X.
|
idamnjanovic@51
|
255 *
|
idamnjanovic@51
|
256 **************************************************************************/
|
idamnjanovic@51
|
257 void matT_mat(double alpha, double A[], double B[], double X[], mwSize n, mwSize m, mwSize k);
|
idamnjanovic@51
|
258
|
idamnjanovic@51
|
259
|
idamnjanovic@51
|
260
|
idamnjanovic@51
|
261 /**************************************************************************
|
idamnjanovic@51
|
262 * Tensor-matrix multiplication.
|
idamnjanovic@51
|
263 *
|
idamnjanovic@51
|
264 * This function accepts a 3-D tensor A of size n X m X k
|
idamnjanovic@51
|
265 * and a 2-D matrix B of size l X k.
|
idamnjanovic@51
|
266 * The function computes the 3-D tensor X of size n X m X l, where
|
idamnjanovic@51
|
267 *
|
idamnjanovic@51
|
268 * X(i,j,:) = B*A(i,j,:)
|
idamnjanovic@51
|
269 *
|
idamnjanovic@51
|
270 * for all i,j.
|
idamnjanovic@51
|
271 *
|
idamnjanovic@51
|
272 * Parameters:
|
idamnjanovic@51
|
273 * A - tensor of size n X m X k
|
idamnjanovic@51
|
274 * B - matrix of size l X k
|
idamnjanovic@51
|
275 * X - output tensor of size n X m X l
|
idamnjanovic@51
|
276 * alpha - real constant
|
idamnjanovic@51
|
277 * n, m, k, l - dimensions of A, B
|
idamnjanovic@51
|
278 *
|
idamnjanovic@51
|
279 * Note: This function re-writes the contents of X.
|
idamnjanovic@51
|
280 *
|
idamnjanovic@51
|
281 **************************************************************************/
|
idamnjanovic@51
|
282 void tens_mat(double alpha, double A[], double B[], double X[], mwSize n, mwSize m, mwSize k, mwSize l);
|
idamnjanovic@51
|
283
|
idamnjanovic@51
|
284
|
idamnjanovic@51
|
285
|
idamnjanovic@51
|
286 /**************************************************************************
|
idamnjanovic@51
|
287 * Tensor-matrix-transpose multiplication.
|
idamnjanovic@51
|
288 *
|
idamnjanovic@51
|
289 * This function accepts a 3-D tensor A of size n X m X k
|
idamnjanovic@51
|
290 * and a 2-D matrix B of size k X l.
|
idamnjanovic@51
|
291 * The function computes the 3-D tensor X of size n X m X l, where
|
idamnjanovic@51
|
292 *
|
idamnjanovic@51
|
293 * X(i,j,:) = B'*A(i,j,:)
|
idamnjanovic@51
|
294 *
|
idamnjanovic@51
|
295 * for all i,j.
|
idamnjanovic@51
|
296 *
|
idamnjanovic@51
|
297 * Parameters:
|
idamnjanovic@51
|
298 * A - tensor of size n X m X k
|
idamnjanovic@51
|
299 * B - matrix of size k X l
|
idamnjanovic@51
|
300 * X - output tensor of size n X m X l
|
idamnjanovic@51
|
301 * alpha - real constant
|
idamnjanovic@51
|
302 * n, m, k, l - dimensions of A, B
|
idamnjanovic@51
|
303 *
|
idamnjanovic@51
|
304 * Note: This function re-writes the contents of X.
|
idamnjanovic@51
|
305 *
|
idamnjanovic@51
|
306 **************************************************************************/
|
idamnjanovic@51
|
307 void tens_matT(double alpha, double A[], double B[], double X[], mwSize n, mwSize m, mwSize k, mwSize l);
|
idamnjanovic@51
|
308
|
idamnjanovic@51
|
309
|
idamnjanovic@51
|
310
|
idamnjanovic@51
|
311 /**************************************************************************
|
idamnjanovic@51
|
312 * Vector-vector sum.
|
idamnjanovic@51
|
313 *
|
idamnjanovic@51
|
314 * Computes an operation of the form:
|
idamnjanovic@51
|
315 *
|
idamnjanovic@51
|
316 * y := alpha*x + y
|
idamnjanovic@51
|
317 *
|
idamnjanovic@51
|
318 * Parameters:
|
idamnjanovic@51
|
319 * x - vector of length n
|
idamnjanovic@51
|
320 * y - output vector of length n
|
idamnjanovic@51
|
321 * alpha - real constant
|
idamnjanovic@51
|
322 * n - length of x,y
|
idamnjanovic@51
|
323 *
|
idamnjanovic@51
|
324 * Note: This function re-writes the contents of y.
|
idamnjanovic@51
|
325 *
|
idamnjanovic@51
|
326 **************************************************************************/
|
idamnjanovic@51
|
327 void vec_sum(double alpha, double x[], double y[], mwSize n);
|
idamnjanovic@51
|
328
|
idamnjanovic@51
|
329
|
idamnjanovic@51
|
330
|
idamnjanovic@51
|
331 /**************************************************************************
|
idamnjanovic@51
|
332 * Triangular back substitution.
|
idamnjanovic@51
|
333 *
|
idamnjanovic@51
|
334 * Solve the set of linear equations
|
idamnjanovic@51
|
335 *
|
idamnjanovic@51
|
336 * T*x = b
|
idamnjanovic@51
|
337 *
|
idamnjanovic@51
|
338 * where T is lower or upper triangular.
|
idamnjanovic@51
|
339 *
|
idamnjanovic@51
|
340 * Parameters:
|
idamnjanovic@51
|
341 * ul - 'U' for upper triangular, 'L' for lower triangular
|
idamnjanovic@51
|
342 * A - matrix of size n x m containing T
|
idamnjanovic@51
|
343 * b - vector of length k
|
idamnjanovic@51
|
344 * x - output vector of length k
|
idamnjanovic@51
|
345 * n - size of first dimension of A
|
idamnjanovic@51
|
346 * k - the size of the equation set, k<=n,m
|
idamnjanovic@51
|
347 *
|
idamnjanovic@51
|
348 * Note:
|
idamnjanovic@51
|
349 * The matrix A can be of any size n X m, as long as n,m >= k.
|
idamnjanovic@51
|
350 * Only the lower/upper triangle of the submatrix A(1:k,1:k) defines the
|
idamnjanovic@51
|
351 * matrix T (depending on the parameter ul).
|
idamnjanovic@51
|
352 *
|
idamnjanovic@51
|
353 **************************************************************************/
|
idamnjanovic@51
|
354 void backsubst(char ul, double A[], double b[], double x[], mwSize n, mwSize k);
|
idamnjanovic@51
|
355
|
idamnjanovic@51
|
356
|
idamnjanovic@51
|
357
|
idamnjanovic@51
|
358 /**************************************************************************
|
idamnjanovic@51
|
359 * Solve a set of equations using a Cholesky decomposition.
|
idamnjanovic@51
|
360 *
|
idamnjanovic@51
|
361 * Solve the set of linear equations
|
idamnjanovic@51
|
362 *
|
idamnjanovic@51
|
363 * M*x = b
|
idamnjanovic@51
|
364 *
|
idamnjanovic@51
|
365 * where M is positive definite with a known Cholesky decomposition:
|
idamnjanovic@51
|
366 * either M=L*L' (L lower triangular) or M=U'*U (U upper triangular).
|
idamnjanovic@51
|
367 *
|
idamnjanovic@51
|
368 * Parameters:
|
idamnjanovic@51
|
369 * ul - 'U' for upper triangular, 'L' for lower triangular decomposition
|
idamnjanovic@51
|
370 * A - matrix of size n x m with the Cholesky decomposition of M
|
idamnjanovic@51
|
371 * b - vector of length k
|
idamnjanovic@51
|
372 * x - output vector of length k
|
idamnjanovic@51
|
373 * n - size of first dimension of A
|
idamnjanovic@51
|
374 * k - the size of the equation set, k<=n,m
|
idamnjanovic@51
|
375 *
|
idamnjanovic@51
|
376 * Note:
|
idamnjanovic@51
|
377 * The matrix A can be of any size n X m, as long as n,m >= k.
|
idamnjanovic@51
|
378 * Only the lower/upper triangle of the submatrix A(1:k,1:k) is used as
|
idamnjanovic@51
|
379 * the Cholesky decomposition of M (depending on the parameter ul).
|
idamnjanovic@51
|
380 *
|
idamnjanovic@51
|
381 **************************************************************************/
|
idamnjanovic@51
|
382 void cholsolve(char ul, double A[], double b[], double x[], mwSize n, mwSize k);
|
idamnjanovic@51
|
383
|
idamnjanovic@51
|
384
|
idamnjanovic@51
|
385
|
idamnjanovic@51
|
386 /**************************************************************************
|
idamnjanovic@51
|
387 * Maximum absolute value.
|
idamnjanovic@51
|
388 *
|
idamnjanovic@51
|
389 * Returns the index of the coefficient with maximal absolute value in a vector.
|
idamnjanovic@51
|
390 *
|
idamnjanovic@51
|
391 * Parameters:
|
idamnjanovic@51
|
392 * x - vector of length n
|
idamnjanovic@51
|
393 * n - length of x
|
idamnjanovic@51
|
394 *
|
idamnjanovic@51
|
395 **************************************************************************/
|
idamnjanovic@51
|
396 mwIndex maxabs(double x[], mwSize n);
|
idamnjanovic@51
|
397
|
idamnjanovic@51
|
398
|
idamnjanovic@51
|
399
|
idamnjanovic@51
|
400 /**************************************************************************
|
idamnjanovic@51
|
401 * Maximum vector element.
|
idamnjanovic@51
|
402 *
|
idamnjanovic@51
|
403 * Returns the index of the maximal coefficient in a vector.
|
idamnjanovic@51
|
404 *
|
idamnjanovic@51
|
405 * Parameters:
|
idamnjanovic@51
|
406 * x - vector of length n
|
idamnjanovic@51
|
407 * n - length of x
|
idamnjanovic@51
|
408 *
|
idamnjanovic@51
|
409 **************************************************************************/
|
idamnjanovic@51
|
410 mwIndex maxpos(double x[], mwSize n);
|
idamnjanovic@51
|
411
|
idamnjanovic@51
|
412
|
idamnjanovic@51
|
413
|
idamnjanovic@51
|
414 /**************************************************************************
|
idamnjanovic@51
|
415 * Vector-vector dot product.
|
idamnjanovic@51
|
416 *
|
idamnjanovic@51
|
417 * Computes an operation of the form:
|
idamnjanovic@51
|
418 *
|
idamnjanovic@51
|
419 * c = a'*b
|
idamnjanovic@51
|
420 *
|
idamnjanovic@51
|
421 * Parameters:
|
idamnjanovic@51
|
422 * a, b - vectors of length n
|
idamnjanovic@51
|
423 * n - length of a,b
|
idamnjanovic@51
|
424 *
|
idamnjanovic@51
|
425 * Returns: The dot product c.
|
idamnjanovic@51
|
426 *
|
idamnjanovic@51
|
427 **************************************************************************/
|
idamnjanovic@51
|
428 double dotprod(double a[], double b[], mwSize n);
|
idamnjanovic@51
|
429
|
idamnjanovic@51
|
430
|
idamnjanovic@51
|
431
|
idamnjanovic@51
|
432 /**************************************************************************
|
idamnjanovic@51
|
433 * Indexed vector assignment.
|
idamnjanovic@51
|
434 *
|
idamnjanovic@51
|
435 * Perform a permutation assignment of the form
|
idamnjanovic@51
|
436 *
|
idamnjanovic@51
|
437 * y = x(ind)
|
idamnjanovic@51
|
438 *
|
idamnjanovic@51
|
439 * where ind is an array of indices to x.
|
idamnjanovic@51
|
440 *
|
idamnjanovic@51
|
441 * Parameters:
|
idamnjanovic@51
|
442 * y - output vector of length k
|
idamnjanovic@51
|
443 * x - input vector of arbitrary length
|
idamnjanovic@51
|
444 * ind - array of indices into x (indices begin at 0)
|
idamnjanovic@51
|
445 * k - length of the array ind
|
idamnjanovic@51
|
446 *
|
idamnjanovic@51
|
447 **************************************************************************/
|
idamnjanovic@51
|
448 void vec_assign(double y[], double x[], mwIndex ind[], mwSize k);
|
idamnjanovic@51
|
449
|
idamnjanovic@51
|
450
|
idamnjanovic@51
|
451
|
idamnjanovic@51
|
452 /**************************************************************************
|
idamnjanovic@51
|
453 * Matrix transpose.
|
idamnjanovic@51
|
454 *
|
idamnjanovic@51
|
455 * Computes Y := X'
|
idamnjanovic@51
|
456 *
|
idamnjanovic@51
|
457 * Parameters:
|
idamnjanovic@51
|
458 * X - input matrix of size n X m
|
idamnjanovic@51
|
459 * Y - output matrix of size m X n
|
idamnjanovic@51
|
460 * n, m - dimensions of X
|
idamnjanovic@51
|
461 *
|
idamnjanovic@51
|
462 **************************************************************************/
|
idamnjanovic@51
|
463 void transpose(double X[], double Y[], mwSize n, mwSize m);
|
idamnjanovic@51
|
464
|
idamnjanovic@51
|
465
|
idamnjanovic@51
|
466
|
idamnjanovic@51
|
467 /**************************************************************************
|
idamnjanovic@51
|
468 * Print a matrix.
|
idamnjanovic@51
|
469 *
|
idamnjanovic@51
|
470 * Parameters:
|
idamnjanovic@51
|
471 * A - matrix of size n X m
|
idamnjanovic@51
|
472 * n, m - dimensions of A
|
idamnjanovic@51
|
473 * matname - name of matrix to display
|
idamnjanovic@51
|
474 *
|
idamnjanovic@51
|
475 **************************************************************************/
|
idamnjanovic@51
|
476 void printmat(double A[], int n, int m, char* matname);
|
idamnjanovic@51
|
477
|
idamnjanovic@51
|
478
|
idamnjanovic@51
|
479
|
idamnjanovic@51
|
480 /**************************************************************************
|
idamnjanovic@51
|
481 * Print a sparse matrix.
|
idamnjanovic@51
|
482 *
|
idamnjanovic@51
|
483 * Parameters:
|
idamnjanovic@51
|
484 * A - sparse matrix of type double
|
idamnjanovic@51
|
485 * matname - name of matrix to display
|
idamnjanovic@51
|
486 *
|
idamnjanovic@51
|
487 **************************************************************************/
|
idamnjanovic@51
|
488 void printspmat(mxArray *A, char* matname);
|
idamnjanovic@51
|
489
|
idamnjanovic@51
|
490
|
idamnjanovic@51
|
491 #endif
|
idamnjanovic@51
|
492
|