H2Lib  3.0
rkmatrix.h
Go to the documentation of this file.
1 /* ------------------------------------------------------------
2  * This is the file "rkmatrix.h" of the H2Lib package.
3  * All rights reserved, Steffen Boerm 2010
4  * ------------------------------------------------------------ */
5 
10 #ifndef RKMATRIX_H
11 #define RKMATRIX_H
12 
22 typedef struct _rkmatrix rkmatrix;
23 
26 
28 typedef const rkmatrix *pcrkmatrix;
29 
30 #include "amatrix.h"
31 #include "krylov.h"
32 #include "settings.h"
33 
36 struct _rkmatrix {
41 
44 };
45 
46 /* ------------------------------------------------------------
47  * Constructors and destructors
48  * ------------------------------------------------------------ */
49 
63 init_rkmatrix(prkmatrix r, uint rows, uint cols, uint k);
64 
87 init_sub_rkmatrix(prkmatrix r, pcrkmatrix src, uint rows, uint roff, uint cols,
88  uint coff);
89 
96 HEADER_PREFIX void
98 
110 new_rkmatrix(uint rows, uint cols, uint k);
111 
132 new_sub_rkmatrix(pcrkmatrix src, uint rows, uint roff, uint cols, uint coff);
133 
143 HEADER_PREFIX void
145 
146 /* ------------------------------------------------------------
147  * Change rank
148  * ------------------------------------------------------------ */
149 
159 void
161 
173 void
174 resize_rkmatrix(prkmatrix r, uint rows, uint cols, uint k);
175 
176 /* ------------------------------------------------------------
177  * Statistics
178  * ------------------------------------------------------------ */
179 
190 HEADER_PREFIX size_t
192 
203 HEADER_PREFIX size_t
205 
206 /* ------------------------------------------------------------
207  * Simple utility functions
208  * ------------------------------------------------------------ */
209 
219 
229 HEADER_PREFIX void
230 copy_rkmatrix(bool atrans, pcrkmatrix a, prkmatrix b);
231 
237 HEADER_PREFIX void
238 scale_rkmatrix(field alpha, prkmatrix r);
239 
244 HEADER_PREFIX void
246 
247 /* ------------------------------------------------------------
248  * Matrix-vector multiplication
249  * ------------------------------------------------------------ */
250 
262 HEADER_PREFIX void
264 
276 HEADER_PREFIX void
278  pavector y);
279 
292 HEADER_PREFIX void
293 mvm_rkmatrix_avector(field alpha, bool rtrans, pcrkmatrix r, pcavector x,
294  pavector y);
295 
296 /* ------------------------------------------------------------
297  * Spectral norm
298  * ------------------------------------------------------------ */
299 
310 
323 
324 #endif
325 
326 /* ------------------------------------------------------------
327  * Access methods
328  * ------------------------------------------------------------ */
329 
330 #ifndef RKMATRIX_COMPLETE
331 #define RKMATRIX_COMPLETE
332 
333 #ifdef __GNUC__
335 getrows_rkmatrix(pcrkmatrix) __attribute__ ((const,unused));
337 getcols_rkmatrix(pcrkmatrix) __attribute__ ((const,unused));
339 getrank_rkmatrix(pcrkmatrix r) __attribute__ ((const, unused));
341 getA_rkmatrix(prkmatrix r) __attribute__ ((unused));
343 getB_rkmatrix(prkmatrix r) __attribute__ ((unused));
344 #endif
345 
352  return r->A.rows;
353 }
354 
361  return r->B.rows;
362 }
363 
370  assert(r->A.cols == r->B.cols);
371 
372  return r->A.cols;
373 }
374 
381  return &r->A;
382 }
383 
390  return &r->B;
391 }
392 
393 #endif
394 
prkmatrix clone_rkmatrix(pcrkmatrix r)
Create a copy of an rkmatrix.
pamatrix getA_rkmatrix(prkmatrix r)
Get the factor A of an rkmatrix .
Definition: rkmatrix.h:380
amatrix B
Definition: rkmatrix.h:40
Definition: avector.h:39
pcrkmatrix init_sub_rkmatrix(prkmatrix r, pcrkmatrix src, uint rows, uint roff, uint cols, uint coff)
Initialize an rkmatrix object to represent a submatrix.
real norm2diff_rkmatrix(pcrkmatrix a, pcrkmatrix b)
Approximate the spectral norm of the difference of two low-rank matrices and .
prkmatrix init_rkmatrix(prkmatrix r, uint rows, uint cols, uint k)
Initialize an rkmatrix object.
uint getrows_rkmatrix(pcrkmatrix r)
Get the number of rows of an rkmatrix .
Definition: rkmatrix.h:351
void setrank_rkmatrix(prkmatrix r, uint k)
Change the rank of an rkmatrix.
unsigned uint
Unsigned integer type.
Definition: settings.h:70
pamatrix getB_rkmatrix(prkmatrix r)
Get the factor B of an rkmatrix .
Definition: rkmatrix.h:389
void copy_rkmatrix(bool atrans, pcrkmatrix a, prkmatrix b)
Copy an rkmatrix into another rkmatrix.
void scale_rkmatrix(field alpha, prkmatrix r)
Scale an rkmatrix by a factor.
double _Complex field
Field type.
Definition: settings.h:171
void random_rkmatrix(prkmatrix r, uint kmax)
Fill an rkmatrix with random values.
uint rows
Number of rows.
Definition: amatrix.h:51
#define INLINE_PREFIX
Prefix for inline functions.
Definition: settings.h:36
void uninit_rkmatrix(prkmatrix r)
Uninitialize an rkmatrix object.
uint k
Definition: rkmatrix.h:43
void mvm_rkmatrix_avector(field alpha, bool rtrans, pcrkmatrix r, pcavector x, pavector y)
Multiply a low-rank matrix or its adjoint by a vector, or .
size_t getsize_heap_rkmatrix(pcrkmatrix r)
Get heap size of a given rkmatrix object.
uint getcols_rkmatrix(pcrkmatrix r)
Get the number of columns of an rkmatrix .
Definition: rkmatrix.h:360
void addevaltrans_rkmatrix_avector(field alpha, pcrkmatrix r, pcavector x, pavector y)
Multiply the adjoint of a low-rank matrix by a vector , .
#define HEADER_PREFIX
Prefix for function declarations.
Definition: settings.h:43
double real
real floating point type.
Definition: settings.h:97
amatrix A
Definition: rkmatrix.h:38
pcrkmatrix new_sub_rkmatrix(pcrkmatrix src, uint rows, uint roff, uint cols, uint coff)
Create a new rkmatrix object representing a submatrix.
uint getrank_rkmatrix(pcrkmatrix r)
Get the rank of an rkmatrix .
Definition: rkmatrix.h:369
void addeval_rkmatrix_avector(field alpha, pcrkmatrix r, pcavector x, pavector y)
Multiply a low-rank matrix by a vector , .
Representation of a low-rank matrix in factorized form .
Definition: rkmatrix.h:36
rkmatrix * prkmatrix
Pointer to rkmatrix object.
Definition: rkmatrix.h:25
Representation of a matrix as an array in column-major order.
Definition: amatrix.h:43
prkmatrix new_rkmatrix(uint rows, uint cols, uint k)
Create a new rkmatrix object.
void resize_rkmatrix(prkmatrix r, uint rows, uint cols, uint k)
Change the size of an rkmatrix.
uint cols
Number of columns.
Definition: amatrix.h:53
size_t getsize_rkmatrix(pcrkmatrix r)
Get size of a given rkmatrix object.
real norm2_rkmatrix(pcrkmatrix R)
Approximate the spectral norm of a matrix .
const rkmatrix * pcrkmatrix
Pointer to constant rkmatrix object.
Definition: rkmatrix.h:28
void del_rkmatrix(prkmatrix r)
Delete an rkmatrix object.