H2Lib  3.0
hmatrix.h
Go to the documentation of this file.
1 
2 /* ------------------------------------------------------------
3  * This is the file "hmatrix.h" of the H2Lib package.
4  * All rights reserved, Steffen Boerm 2009
5  * ------------------------------------------------------------ */
6 
11 #ifndef HMATRIX_H
12 #define HMATRIX_H
13 
22 typedef struct _hmatrix hmatrix;
23 
25 typedef hmatrix *phmatrix;
26 
28 typedef const hmatrix *pchmatrix;
29 
30 #ifdef USE_CAIRO
31 #include <cairo.h>
32 #endif
33 
34 #include "amatrix.h"
35 #include "krylov.h"
36 #include "factorizations.h"
37 #include "block.h"
38 #include "rkmatrix.h"
39 #include "settings.h"
40 #include "eigensolvers.h"
41 #include "sparsematrix.h"
42 
49 struct _hmatrix {
54 
57 
60 
67 
72 };
73 
74 /* ------------------------------------------------------------
75  * Constructors and destructors
76  * ------------------------------------------------------------ */
77 
88 
98 HEADER_PREFIX void
100 
115 
130 
146 
165 
177 
190 
199 HEADER_PREFIX void
201 
211 HEADER_PREFIX void
213 
214 /* ------------------------------------------------------------
215  * Reference counting
216  * ------------------------------------------------------------ */
217 
224 HEADER_PREFIX void
225 ref_hmatrix(phmatrix *ptr, phmatrix hm);
226 
235 HEADER_PREFIX void
237 
238 /* ------------------------------------------------------------
239  * Statistics
240  * ------------------------------------------------------------ */
241 
246 HEADER_PREFIX size_t
248 
253 HEADER_PREFIX size_t
255 
260 HEADER_PREFIX size_t
262 
263 /* ------------------------------------------------------------
264  * Access methods
265  * ------------------------------------------------------------ */
266 
267 #ifdef __GNUC__
269 getrows_hmatrix(pchmatrix) __attribute__ ((const,unused));
271 getcols_hmatrix(pchmatrix) __attribute__ ((const,unused));
272 #endif
273 
279  return a->rc->size;
280 }
281 
287  return a->cc->size;
288 }
289 
290 /* ------------------------------------------------------------
291  * Simple utility functions
292  * ------------------------------------------------------------ */
293 
298 HEADER_PREFIX void
300 
307 HEADER_PREFIX void
308 clear_upper_hmatrix(phmatrix hm, bool strict);
309 
319 HEADER_PREFIX void
321 
330 HEADER_PREFIX void
332 
341 HEADER_PREFIX void
342 random_hmatrix(phmatrix hm, uint kmax);
343 
344 /* ------------------------------------------------------------
345  * Build H-matrix based on block tree
346  * ------------------------------------------------------------ */
347 
359 
360 /* ------------------------------------------------------------
361  * Build block tree from H-matrix
362  * ------------------------------------------------------------ */
363 
371 
372 /* ------------------------------------------------------------
373  * Matrix-vector multiplication
374  * ------------------------------------------------------------ */
375 
388 HEADER_PREFIX void
389 mvm_hmatrix_avector(field alpha, bool atrans, pchmatrix a, pcavector x,
390  pavector y);
391 
404 HEADER_PREFIX void
406  pavector yp);
407 
418 HEADER_PREFIX void
420 
433 HEADER_PREFIX void
435  pavector yp);
436 
447 HEADER_PREFIX void
449 
463 HEADER_PREFIX void
465  pavector yp);
466 
478 HEADER_PREFIX void
480 
481 /* ------------------------------------------------------------
482  * Enumeration by block number
483  * ------------------------------------------------------------ */
484 
500 
501 /* ------------------------------------------------------------
502  * Spectral norm
503  * ------------------------------------------------------------ */
504 
515 
528 
529 /* ------------------------------------------------------------
530  * File I/O
531  * ------------------------------------------------------------ */
532 
533 #ifdef USE_NETCDF
534 
538 HEADER_PREFIX void
539 write_cdf_hmatrix(pchmatrix G, const char *name);
540 
551 HEADER_PREFIX void
552 write_cdfpart_hmatrix(pchmatrix G, int nc_file, const char *prefix);
553 
569 read_cdf_hmatrix(const char *name, pccluster rc, pccluster cc);
570 
590 read_cdfpart_hmatrix(int nc_file, const char *prefix,
591  pccluster rc, pccluster cc);
592 
597 HEADER_PREFIX void
598 write_cdfcomplete_hmatrix(pchmatrix G, const char *name);
599 
605 read_cdfcomplete_hmatrix(const char *name);
606 #endif
607 
612 HEADER_PREFIX void
613 write_hlib_hmatrix(pchmatrix G, const char *filename);
614 
624 read_hlib_hmatrix(const char *filename);
625 
636 read_hlibsymm_hmatrix(const char *filename);
637 
638 /* ------------------------------------------------------------
639  * Drawing
640  * ------------------------------------------------------------ */
641 
642 #ifdef USE_CAIRO
643 
655 HEADER_PREFIX void
656 draw_cairo_hmatrix(cairo_t *cr, pchmatrix hm, bool storage, uint levels);
657 #endif
658 
659 
660 /* ------------------------------------------------------------
661  * Copy entries of a sparse matrix
662  * ------------------------------------------------------------ */
663 
678 HEADER_PREFIX void
680 
683 #endif
phmatrix read_cdfcomplete_hmatrix(const char *name)
Read hmatrix from NetCDF file, including cluster trees.
void mvm_hmatrix_avector(field alpha, bool atrans, pchmatrix a, pcavector x, pavector y)
Matrix-vector multiplication or .
Definition: avector.h:39
phmatrix read_cdfpart_hmatrix(int nc_file, const char *prefix, pccluster rc, pccluster cc)
Read a matrix from a NetCDF file.
phmatrix new_super_hmatrix(pccluster rc, pccluster cc, uint rsons, uint csons)
Create a new hmatrix object representing a subdivided matrix.
void unref_hmatrix(phmatrix hm)
Reduce the reference counter of a hmatrix object.
uint getrows_hmatrix(pchmatrix a)
Get the number of rows of a hmatrix .
Definition: hmatrix.h:278
Representation of -matrices.
Definition: hmatrix.h:49
const hmatrix * pchmatrix
Pointer to constant hmatrix object.
Definition: hmatrix.h:28
phmatrix init_hmatrix(phmatrix hm, pccluster rc, pccluster cc)
Initialize a hmatrix object.
uint getcols_hmatrix(pchmatrix a)
Get the number of columns of a hmatrix .
Definition: hmatrix.h:286
phmatrix clonestructure_hmatrix(pchmatrix src)
Clones the structure of an existing hmatrix.
uint rsons
Number of block rows.
Definition: hmatrix.h:64
pccluster cc
Column cluster.
Definition: hmatrix.h:53
unsigned uint
Unsigned integer type.
Definition: settings.h:70
phmatrix build_from_block_hmatrix(pcblock b, uint k)
Build an hmatrix object from a block tree using a given local rank.
void addevalsymm_hmatrix_avector(field alpha, pchmatrix hm, pcavector x, pavector y)
Matrix-vector multiplication with symmetric matrix .
pccluster rc
Row cluster.
Definition: hmatrix.h:51
phmatrix * son
Submatrices.
Definition: hmatrix.h:62
phmatrix read_hlibsymm_hmatrix(const char *filename)
Read a symmetric matrix from an ASCII file in the old HLib format.
double _Complex field
Field type.
Definition: settings.h:171
#define INLINE_PREFIX
Prefix for inline functions.
Definition: settings.h:36
size_t getfarsize_hmatrix(pchmatrix hm)
Get size of the farfield part of a given hmatrix object.
uint refs
Number of references to this hmatrix.
Definition: hmatrix.h:69
void write_cdfpart_hmatrix(pchmatrix G, int nc_file, const char *prefix)
Write a matrix into a NetCDF file.
void del_hmatrix(phmatrix hm)
Delete a hmatrix object.
uint csons
Number of block columns.
Definition: hmatrix.h:66
void draw_cairo_hmatrix(cairo_t *cr, pchmatrix hm, bool storage, uint levels)
Draw a hierarchical matrix.
void update_hmatrix(phmatrix hm)
Complete the initialisation of a hmatrix object.
size_t getsize_hmatrix(pchmatrix hm)
Get size of a given hmatrix object.
phmatrix clone_hmatrix(pchmatrix src)
Creates a clone of an existing hmatrix.
void fastaddevalsymm_hmatrix_avector(field alpha, pchmatrix hm, pcavector xp, pavector yp)
Matrix-vector multiplication with symmetric matrix .
phmatrix new_hmatrix(pccluster rc, pccluster cc)
Create a new hmatrix object.
void addevaltrans_hmatrix_avector(field alpha, pchmatrix hm, pcavector x, pavector y)
Adjoint matrix-vector multiplication .
size_t getnearsize_hmatrix(pchmatrix hm)
Get size of the nearfield part of a given hmatrix object.
uint desc
Number of descendants in matrix tree.
Definition: hmatrix.h:71
void clear_upper_hmatrix(phmatrix hm, bool strict)
Set the upper triangular part of a hmatrix to zero by clearing all far- and nearfield matrices...
void ref_hmatrix(phmatrix *ptr, phmatrix hm)
Set a pointer to a hmatrix object, increase its reference counter, and decrease reference counter of ...
real norm2_hmatrix(pchmatrix H)
Approximate the spectral norm of a matrix .
phmatrix new_rk_hmatrix(pccluster rc, pccluster cc, uint k)
Create a new hmatrix object representing a low-rank matrix.
void copy_sparsematrix_hmatrix(psparsematrix sp, phmatrix hm)
Copy entries of a sparsematrix into a hierarchical matrix.
void write_cdfcomplete_hmatrix(pchmatrix G, const char *name)
Write hmatrix to NetCDF file, including cluster trees.
#define HEADER_PREFIX
Prefix for function declarations.
Definition: settings.h:43
double real
real floating point type.
Definition: settings.h:97
void clear_hmatrix(phmatrix hm)
Set a hmatrix to zero by clearing all far- and nearfield matrices.
pblock build_from_hmatrix_block(pchmatrix G)
Build an block tree from an hmatrix.
Representation of block trees.
Definition: block.h:48
void fastaddevaltrans_hmatrix_avector(field alpha, pchmatrix hm, pcavector xp, pavector yp)
Adjoint matrix-vector multiplication .
void identity_hmatrix(phmatrix hm)
Fill a hmatrix with an identity matrix.
pamatrix f
Standard matrix, for inadmissible leaves.
Definition: hmatrix.h:59
hmatrix * phmatrix
Pointer to a hmatrix object.
Definition: hmatrix.h:25
Representation of cluster trees.
Definition: cluster.h:40
void copy_hmatrix(pchmatrix src, phmatrix trg)
Copy a matrix src to an existing matrix dst.
void write_hlib_hmatrix(pchmatrix G, const char *filename)
Write a matrix into an ASCII file in the old HLib format.
void write_cdf_hmatrix(pchmatrix G, const char *name)
Write a matrix into a NetCDF file.
Representation of a low-rank matrix in factorized form .
Definition: rkmatrix.h:36
void random_hmatrix(phmatrix hm, uint kmax)
Fill a hmatrix with random field values. The maximal rank for admissible leaves is determined by kmax...
void addeval_hmatrix_avector(field alpha, pchmatrix hm, pcavector x, pavector y)
Matrix-vector multiplication .
prkmatrix r
Low-rank matrix, for admissible leaves.
Definition: hmatrix.h:56
Representation of a sparse matrix in compressed row format.
Definition: sparsematrix.h:42
phmatrix read_cdf_hmatrix(const char *name, pccluster rc, pccluster cc)
Read a matrix from a NetCDF file.
Representation of a matrix as an array in column-major order.
Definition: amatrix.h:43
void fastaddeval_hmatrix_avector(field alpha, pchmatrix hm, pcavector xp, pavector yp)
Matrix-vector multiplication .
real norm2diff_hmatrix(pchmatrix a, pchmatrix b)
Approximate the spectral norm of the difference of two matrices and .
uint size
Number of indices.
Definition: cluster.h:42
phmatrix new_full_hmatrix(pccluster rc, pccluster cc)
Create a new hmatrix object representing a standard dense matrix.
phmatrix read_hlib_hmatrix(const char *filename)
Read a matrix from an ASCII file in the old HLib format.
phmatrix * enumerate_hmatrix(pcblock b, phmatrix hm)
Enumerate hmatrix according to block tree.
void uninit_hmatrix(phmatrix hm)
Uninitialize a hmatrix object.