H2Lib  3.0
dh2matrix.h
Go to the documentation of this file.
1 
2 /* ------------------------------------------------------------
3  * This is the file "dh2matrix.h" of the H2Lib package.
4  * All rights reserved, Steffen Boerm 2015
5  * ------------------------------------------------------------ */
6 
10 #ifndef DH2MATRIX_H
11 #define DH2MATRIX_H
12 
18 typedef struct _dh2matrix dh2matrix;
19 
22 
24 typedef const dh2matrix *pcdh2matrix;
25 
26 #include "settings.h"
27 #include "amatrix.h"
28 #include "krylov.h"
29 #include "h2matrix.h"
30 #include "dblock.h"
31 #include "duniform.h"
32 #include "dclusterbasis.h"
33 #include "dclusteroperator.h"
34 
50 struct _dh2matrix {
55 
60 
67 
70 };
71 
72 /* ------------------------------------------------------------
73  * Constructors and destructors
74  * ------------------------------------------------------------ */
75 
83 
94 
103 
114  uint rsons, uint csons);
115 
120 HEADER_PREFIX void
122 
126 HEADER_PREFIX void
128 
142 
143 /* ------------------------------------------------------------
144  * Statistics
145  * ------------------------------------------------------------ */
146 
152 HEADER_PREFIX size_t
154 
160 HEADER_PREFIX size_t
162 
168 HEADER_PREFIX size_t
170 
176 HEADER_PREFIX size_t
178 
179 /* ------------------------------------------------------------
180  * Access methods
181  * ------------------------------------------------------------ */
182 
183 #ifdef __GNUC__
185 getrows_dh2matrix(pcdh2matrix h2) __attribute__ ((const,unused));
187 getcols_dh2matrix(pcdh2matrix h2) __attribute__ ((const,unused));
188 #endif
189 
196 {
197  return h2->rb->t->size;
198 }
199 
206 {
207  return h2->cb->t->size;
208 }
209 
210 /* ------------------------------------------------------------
211  * Build directional H^2-matrix based on directional block tree
212  * ------------------------------------------------------------ */
213 
223 
224 /* ------------------------------------------------------------
225  * Copy nearfield matrices from a given dense matrix
226  * ------------------------------------------------------------ */
227 
236 HEADER_PREFIX void
238 
239 /* ------------------------------------------------------------
240  * Matrix-vector multiplication
241  * ------------------------------------------------------------ */
242 
256 HEADER_PREFIX void
258  pcavector xt, pavector yt);
259 
273 HEADER_PREFIX void
275  pcavector xt, pavector yt);
276 
283 HEADER_PREFIX void
285  pcavector x, pavector y);
286 
293 HEADER_PREFIX void
295  pcavector x, pavector y);
296 
305 HEADER_PREFIX void
306 mvm_dh2matrix_avector(field alpha, bool h2trans, pcdh2matrix h2,
307  pcavector x, pavector y);
308 
309 /* ------------------------------------------------------------
310  * Matrix-vector multiplication based on the
311  * dclusterbasis parallel iterator
312  * ------------------------------------------------------------ */
313 
321 HEADER_PREFIX void
323  pcavector x, pavector y);
324 
332 HEADER_PREFIX void
334  pcavector x, pavector y);
335 
336 /* ------------------------------------------------------------
337  * Slow direct matrix-vector multiplication,
338  * for debugging purposes
339  * ------------------------------------------------------------ */
340 
349 HEADER_PREFIX void
351  pcavector x, pavector y);
352 
361 HEADER_PREFIX void
363  pcavector x, pavector y);
364 
365 
366 /* ------------------------------------------------------------
367  * Conversion to a full matrix
368  * ------------------------------------------------------------ */
369 
376 HEADER_PREFIX void
378 
379 /* ------------------------------------------------------------
380  * Hierarchical iterator
381  * ------------------------------------------------------------ */
382 
393 
410 HEADER_PREFIX void
411 iterate_dh2matrix(pdh2matrix G, uint mname, uint rname, uint cname,
412  uint pardepth,
413  void (*pre)(pdh2matrix G, uint mname,
414  uint rname, uint cname, uint pardepth,
415  void *data),
416  void (*post)(pdh2matrix G, uint mname,
417  uint rname, uint cname, uint pardepth,
418  void *data), void *data);
419 
420 /* ------------------------------------------------------------
421  * Matrix norms
422  * ------------------------------------------------------------ */
423 
434 
447 
448 /* ------------------------------------------------------------
449  * Drawing
450  * ------------------------------------------------------------ */
451 
452 #ifdef USE_CAIRO
453 
463 HEADER_PREFIX void
464 draw_cairo_dh2matrix(cairo_t * cr, pcdh2matrix G, bool storage,
465  bool ranks, uint levels);
466 #endif
467 
468 /* -----------------------------------------------------------
469  * Resize, projection and recompression
470  * ----------------------------------------------------------- */
471 
492 HEADER_PREFIX void
494 
515 
532 compress_dh2matrix_dh2matrix(pcdh2matrix G, bool rbortho, bool cbortho, pctruncmode tm, real eps);
533 
554 HEADER_PREFIX void
556 
559 #endif
void addeval_dh2matrix_avector(field alpha, pcdh2matrix h2, pcavector x, pavector y)
Matrix-vector multiplication .
void resize_coupling_dh2matrix(pdh2matrix A, pdclusteroperator ro, pdclusteroperator co)
Computes new coupling matrices after the directional cluster basis has been orthogonalized.
pamatrix f
Standard matrix (if nearfield leaf)
Definition: dh2matrix.h:59
pcdcluster t
Corresponding directional cluster.
Definition: dclusterbasis.h:48
void addevaltrans_dh2matrix_avector(field alpha, pcdh2matrix h2, pcavector x, pavector y)
Adjoint matrix-vector multiplication .
void fastaddevaltrans_dh2matrix_avector(field alpha, pcdh2matrix h2, pcavector xt, pavector yt)
Fast adjoint matrix-vector multiplication.
Definition: avector.h:39
void slowaddeval_dh2matrix_avector(field alpha, pcdh2matrix h2, pcavector x, pavector y)
Matrix-vector multiplication , slow version for debugging, all submatrices are handled independently...
pduniform u
Uniform matrix (if farfield leaf)
Definition: dh2matrix.h:57
pdclusterbasis rb
Row cluster basis.
Definition: dh2matrix.h:52
void addeval_parallel_dh2matrix_avector(field alpha, pcdh2matrix h2, pcavector x, pavector y)
Matrix-vector multiplication , parallelized version.
unsigned uint
Unsigned integer type.
Definition: settings.h:70
pdh2matrix clone_dh2matrix(pcdh2matrix dh2, pdclusterbasis rb, pdclusterbasis cb)
Builds a new dh2matrix with the same structure as dh2 and dclusterbasis rb as directional row cluster...
pdh2matrix compress_dh2matrix_dh2matrix(pcdh2matrix G, bool rbortho, bool cbortho, pctruncmode tm, real eps)
Computes a -matrix approximation of a -matrix.
double _Complex field
Field type.
Definition: settings.h:171
size_t getfarsize_dh2matrix(pcdh2matrix h2)
Compute the storage size of the admissible leaves of a dh2matrix.
void mvm_dh2matrix_avector(field alpha, bool h2trans, pcdh2matrix h2, pcavector x, pavector y)
Matrix-vector multiplication or .
pdh2matrix new_uniform_dh2matrix(pdclusterbasis rb, uint rd, pdclusterbasis cb, uint cd)
Create a new dh2matrix object representing an admissible leaf.
uint desc
Number of descendants.
Definition: dh2matrix.h:69
Tree structure representing a -matrix.
Definition: dh2matrix.h:50
void draw_cairo_dh2matrix(cairo_t *cr, pcdh2matrix G, bool storage, bool ranks, uint levels)
Draw a dh2matrix tree to a cairo surface.
#define INLINE_PREFIX
Prefix for inline functions.
Definition: settings.h:36
uint size
Number of indices.
Definition: dcluster.h:43
uint rsons
Block rows.
Definition: dh2matrix.h:64
Representation of a directional cluster operator.
Definition: dclusteroperator.h:33
void truncate_dclusterbasis(pdclusterbasis cold, pdclusterbasis cnew, pdclusteroperator co, pdclusteroperator bco, pctruncmode tm, real eps)
Computes truncated directional cluster basis and save basis change matrices.
void update_dh2matrix(pdh2matrix h2)
Update internal data structures after the sons have been modified, e.g., to recompute desc...
void expand_dh2matrix(field alpha, pcdh2matrix h2, pamatrix G)
Add a -matrix to a standard matrix, .
void iterate_dh2matrix(pdh2matrix G, uint mname, uint rname, uint cname, uint pardepth, void(*pre)(pdh2matrix G, uint mname, uint rname, uint cname, uint pardepth, void *data), void(*post)(pdh2matrix G, uint mname, uint rname, uint cname, uint pardepth, void *data), void *data)
Apply functions to all submatrices of a dh2matrix tree.
Directional block tree.
Definition: dblock.h:45
pdh2matrix new_dh2matrix(pdclusterbasis rb, pdclusterbasis cb)
Create a new empty dh2matrix object.
void slowaddevaltrans_dh2matrix_avector(field alpha, pcdh2matrix h2, pcavector x, pavector y)
Adjoint matrix-vector multiplication , slow version for debugging, all submatrices are handled indepe...
size_t getnearsize_dh2matrix(pcdh2matrix h2)
Compute the storage size of the inadmissible leaves of a dh2matrix.
Define different strategies used by various truncation and compression algorithms for hmatrices and h...
Definition: truncation.h:43
uint csons
Block columns.
Definition: dh2matrix.h:66
void fastaddeval_dh2matrix_avector(field alpha, pcdh2matrix h2, pcavector xt, pavector yt)
Fast matrix-vector multiplication.
uint getcols_dh2matrix(pcdh2matrix h2)
Return the number of columns of a dh2matrix.
Definition: dh2matrix.h:205
dh2matrix * pdh2matrix
Pointer to a dh2matrix.
Definition: dh2matrix.h:21
const dh2matrix * pcdh2matrix
Pointer to a constant dh2matrix.
Definition: dh2matrix.h:24
#define HEADER_PREFIX
Prefix for function declarations.
Definition: settings.h:43
double real
real floating point type.
Definition: settings.h:97
Uniform matrices with directional cluster bases.
Definition: duniform.h:36
real norm2diff_dh2matrix(pcdh2matrix a, pcdh2matrix b)
Approximate the spectral norm of the difference of two matrices and .
size_t gettotalsize_dh2matrix(pcdh2matrix h2)
Compute the storage size of a dh2matrix, including the cluster bases.
pdh2matrix * enumerate_dh2matrix(pdh2matrix h2)
Enumerate all submatrices of a dh2matrix tree.
size_t getsize_dh2matrix(pcdh2matrix h2)
Compute the storage size of a dh2matrix, without the cluster bases.
void addevaltrans_parallel_dh2matrix_avector(field alpha, pcdh2matrix h2, pcavector x, pavector y)
Adjoint matrix-vector multiplication , parallelized version.
pdclusterbasis cb
Column cluster basis.
Definition: dh2matrix.h:54
pdh2matrix build_projected_dh2matrix(pcdh2matrix dh2, pdclusterbasis rb, pdclusterbasis cb, pdclusteroperator ro, pdclusteroperator co)
Builds a new -matrix approximation of a given -matrix with new cluster bases.
pdh2matrix new_super_dh2matrix(pdclusterbasis rb, pdclusterbasis cb, uint rsons, uint csons)
Create a new dh2matrix object representing a subdivided matrix.
Representation of a matrix as an array in column-major order.
Definition: amatrix.h:43
void copynear_dh2matrix(pcamatrix G, pdh2matrix Gh)
Copy nearfield matrices from a given matrix.
pdh2matrix * son
Son matrices (if subdivided)
Definition: dh2matrix.h:62
pdh2matrix new_full_dh2matrix(pdclusterbasis rb, pdclusterbasis cb)
Create a new dh2matrix object representing an inadmissible leaf.
pdh2matrix buildfromblock_dh2matrix(pcdblock b, pdclusterbasis rb, pdclusterbasis cb)
Construct a dh2matrix based on a dblock tree and cluster bases.
Representation of a directional cluster basis.
Definition: dclusterbasis.h:45
real norm2_dh2matrix(pcdh2matrix DH2)
Approximate the spectral norm of a matrix .
void del_dh2matrix(pdh2matrix h2)
Delete a dh2matrix object.
uint getrows_dh2matrix(pcdh2matrix h2)
Return the number of rows of a dh2matrix.
Definition: dh2matrix.h:195