H2Lib  3.0
Data Structures | Macros | Typedefs | Functions
h2matrix

Representation of an $\mathcal{H}^2$-matrix. More...

Data Structures

struct  _h2matrix
 Representation of $\mathcal{H}^2$-matrices. More...
 
struct  _h2matrixlist
 List of h2matrix objects. More...
 

Typedefs

typedef struct _h2matrix h2matrix
 Representation of an $\mathcal{H}^2$-matrix.
 
typedef h2matrixph2matrix
 Pointer to h2matrix object.
 
typedef const h2matrixpch2matrix
 Pointer to constant h2matrix object.
 
typedef struct _h2matrixlist h2matrixlist
 List of h2matrix objects.
 
typedef h2matrixlistph2matrixlist
 Pointer to h2matrixlist object.
 
typedef const h2matrixlistpch2matrixlist
 Pointer to constant h2matrixlist object.
 
typedef void(* h2matrix_callback_t) (ph2matrix G, uint mname, uint rname, uint cname, uint pardepth, void *data)
 Callback function for h2matrix iterators. More...
 
typedef void(* h2matrixlist_callback_t) (pccluster t, uint tname, uint pardepth, pch2matrixlist hl, void *data)
 Callback function for h2matrixlist iterators. More...
 

Functions

ph2matrix new_h2matrix (pclusterbasis rb, pclusterbasis cb)
 Create a new h2matrix object. More...
 
ph2matrix new_uniform_h2matrix (pclusterbasis rb, pclusterbasis cb)
 Create a new h2matrix object representing a uniform matrix. More...
 
ph2matrix new_full_h2matrix (pclusterbasis rb, pclusterbasis cb)
 Create a new h2matrix object representing a standard dense matrix. More...
 
ph2matrix new_super_h2matrix (pclusterbasis rb, pclusterbasis cb, uint rsons, uint csons)
 Create a new hmatrix object representing a subdivided matrix. More...
 
ph2matrix new_zero_h2matrix (pclusterbasis rb, pclusterbasis cb)
 Create a new h2matrix object representing a zero matrix. More...
 
ph2matrix clonestructure_h2matrix (pch2matrix h2, pclusterbasis rb, pclusterbasis cb)
 Builds a new h2matrix with clusterbasis rb and cb and the block structure of h2. More...
 
ph2matrix clone_h2matrix (pch2matrix h2, pclusterbasis rb, pclusterbasis cb)
 Builds a new h2matrix with clusterbasis rb and cb and the block structure of h2. Copies all coupling matrices $ S_b,\ b \in \mathcal L_{\mathcal I \times \mathcal J}^+$ to the clone. More...
 
void update_h2matrix (ph2matrix h2)
 Complete the initialisation of a h2matrix object. More...
 
void del_h2matrix (ph2matrix h2)
 Delete an h2matrix object. More...
 
void ref_h2matrix (ph2matrix *ptr, ph2matrix h2)
 Set a pointer to an h2matrix object, increase its reference counter, and decrease reference counter of original pointer target. More...
 
void unref_h2matrix (ph2matrix h2)
 Reduce the reference counter of an h2matrix object. More...
 
size_t getsize_h2matrix (pch2matrix h2)
 Get size of a given h2matrix object. More...
 
size_t gettotalsize_h2matrix (pch2matrix h2)
 Get total size of a given h2matrix object, including cluster bases. More...
 
size_t getnearsize_h2matrix (pch2matrix h2)
 Get size of the nearfield part of a given h2matrix object. More...
 
size_t getfarsize_h2matrix (pch2matrix h2)
 Get size of the farfield part of a given h2matrix object. More...
 
void clear_h2matrix (ph2matrix h2)
 Set an h2matrix to zero by clearing all far- and nearfield matrices. More...
 
void scale_h2matrix (field alpha, ph2matrix h2)
 Scale an h2matrix by a factor. More...
 
void random_h2matrix (ph2matrix h2)
 Fill an h2matrix with random coefficients. More...
 
ph2matrix build_from_block_h2matrix (pcblock b, pclusterbasis rb, pclusterbasis cb)
 Build an h2matrix object from a block tree using given cluster bases. More...
 
pblock build_from_h2matrix_block (pch2matrix G)
 Build an block tree from an h2matrix. More...
 
ph2matrixenumerate_h2matrix (ph2matrix h2)
 Enumerate h2matrix according to block tree. More...
 
void iterate_h2matrix (ph2matrix G, uint mname, uint rname, uint cname, uint pardepth, h2matrix_callback_t pre, h2matrix_callback_t post, void *data)
 Iterate through all submatrices of an h2matrix. More...
 
void iterate_rowlist_h2matrix (ph2matrix G, uint mname, uint rname, uint cname, uint pardepth, h2matrixlist_callback_t pre, h2matrixlist_callback_t post, void *data)
 Iterate through all submatrices of an h2matrix, collecting all row blocks in an h2matrixlist object. More...
 
void iterate_collist_h2matrix (ph2matrix G, uint mname, uint rname, uint cname, uint pardepth, h2matrixlist_callback_t pre, h2matrixlist_callback_t post, void *data)
 Iterate through all submatrices of an h2matrix, collecting all column blocks in an h2matrixlist object. More...
 
void iterate_byrow_h2matrix (ph2matrix G, uint mname, uint rname, uint cname, uint pardepth, h2matrix_callback_t pre, h2matrix_callback_t post, void *data)
 Iterate through all submatrices of an h2matrix. More...
 
void iterate_bycol_h2matrix (ph2matrix G, uint mname, uint rname, uint cname, uint pardepth, h2matrix_callback_t pre, h2matrix_callback_t post, void *data)
 Iterate through all submatrices of an h2matrix. More...
 
void mvm_h2matrix_avector (field alpha, bool h2trans, pch2matrix h2, pcavector x, pavector y)
 Matrix-vector multiplication $y \gets y + \alpha A x$ or $y \gets y + \alpha A^* x$. More...
 
void fastaddeval_h2matrix_avector (field alpha, pch2matrix h2, pavector xt, pavector yt)
 Interaction phase of the matrix-vector multiplication. More...
 
void addeval_h2matrix_avector (field alpha, pch2matrix h2, pcavector x, pavector y)
 Matrix-vector multiplication $y \gets y + \alpha A x$. More...
 
void fastaddevaltrans_h2matrix_avector (field alpha, pch2matrix h2, pavector xt, pavector yt)
 Interaction phase of the adjoint matrix-vector multiplication. More...
 
void addevaltrans_h2matrix_avector (field alpha, pch2matrix h2, pcavector x, pavector y)
 Adjoint matrix-vector multiplication $y \gets y + \alpha A^* x$. More...
 
void addevalsymm_h2matrix_avector (field alpha, pch2matrix h2, pcavector x, pavector y)
 Symmetric matrix-vector multiplication, $y \gets y + \alpha A x$, where $A$ is assumed to be self-adjoint and only its lower triangular part is used. More...
 
void fastaddmul_h2matrix_amatrix_amatrix (field alpha, bool atrans, pch2matrix A, pcamatrix Bt, pamatrix Ct)
 Interaction phase of the h2matrix - amatrix multiplication. More...
 
void addmul_h2matrix_amatrix_amatrix (field alpha, bool atrans, pch2matrix A, bool btrans, pcamatrix B, pamatrix C)
 Matrix multiplication $ C \gets C + \alpha A B $, $ C \gets C + \alpha A^* B $, $ C \gets C + \alpha A B^* $ or $ C \gets C + \alpha A^* B^* $. More...
 
void addmul_amatrix_h2matrix_amatrix (field alpha, bool atrans, pcamatrix A, bool btrans, pch2matrix B, pamatrix C)
 Matrix multiplication $ C \gets C + \alpha A B $, $ C \gets C + \alpha A^* B $, $ C \gets C + \alpha A B^* $ or $ C \gets C + \alpha A^* B^* $. More...
 
void collectdense_h2matrix (pcamatrix a, pcclusterbasis rb, pcclusterbasis cb, pamatrix s)
 Compute $S \gets V_t^* A W_s$. More...
 
void project_amatrix_h2matrix (ph2matrix h2, pcamatrix a)
 Compute the best approximation of a given matrix $A$ with respect to an $\mathcal{H}^2$-matrix space. More...
 
void project_hmatrix_h2matrix (ph2matrix h2, phmatrix h)
 Compute the best approximation of a given matrix $A$ with respect to an $\mathcal{H}^2$-matrix space. More...
 
real norm2_h2matrix (pch2matrix H2)
 Approximate the spectral norm $\|H\|_2$ of a matrix $H$. More...
 
real norm2diff_h2matrix (pch2matrix a, pch2matrix b)
 Approximate the spectral norm $\|A-B\|_2$ of the difference of two matrices $A$ and $B$. More...
 
void write_cdf_h2matrix (pch2matrix G, const char *name)
 Write h2matrix to NetCDF file. More...
 
void write_cdfpart_h2matrix (pch2matrix G, int nc_file, const char *prefix)
 Write h2matrix to part of a NetCDF file. More...
 
ph2matrix read_cdf_h2matrix (const char *name, pclusterbasis rb, pclusterbasis cb)
 Read h2matrix from NetCDF file. More...
 
ph2matrix read_cdfpart_h2matrix (int nc_file, const char *prefix, pclusterbasis rb, pclusterbasis cb)
 Read h2matrix from part of a NetCDF file. More...
 
void write_cdfcomplete_h2matrix (pch2matrix G, const char *name)
 Write h2matrix to NetCDF file, including cluster trees and cluster bases. More...
 
ph2matrix read_cdfcomplete_h2matrix (const char *name)
 Read h2matrix from NetCDF file, including cluster trees and cluster bases. More...
 
void draw_cairo_h2matrix (cairo_t *cr, pch2matrix G, bool storage, uint levels)
 Draw a h2matrix to a cairo surface. More...
 
uint getrows_h2matrix (pch2matrix h2)
 Get the number of rows of an h2matrix $G$. More...
 
uint getcols_h2matrix (pch2matrix h2)
 Get the number of columns of an h2matrix $G$. More...
 

Detailed Description

Representation of an $\mathcal{H}^2$-matrix.

The h2matrix class is used to represent $\mathcal{H}^2$-matrices with arbitrary block structures and arbitrary cluster bases.

Typedef Documentation

typedef void(* h2matrix_callback_t) (ph2matrix G, uint mname, uint rname, uint cname, uint pardepth, void *data)

Callback function for h2matrix iterators.

Parameters
GMatrix.
mnameNumber of matrix.
rnameNumber of row cluster.
cnameNumber of column cluster.
pardepthParallelization depth.
dataAdditional data.
typedef void(* h2matrixlist_callback_t) (pccluster t, uint tname, uint pardepth, pch2matrixlist hl, void *data)

Callback function for h2matrixlist iterators.

Parameters
tCluster.
tnameNumber of cluster.
pardepthParallelization depth.
hlList of h2matrix objects.
dataAdditional data.

Function Documentation

void addeval_h2matrix_avector ( field  alpha,
pch2matrix  h2,
pcavector  x,
pavector  y 
)

Matrix-vector multiplication $y \gets y + \alpha A x$.

The matrix is multiplied by the source vector $x$, the result is scaled by $\alpha$ and added to the target vector $y$.

Parameters
alphaScaling factor $\alpha$.
h2Matrix $A$.
xSource vector $x$.
yTarget vector $y$.
void addevalsymm_h2matrix_avector ( field  alpha,
pch2matrix  h2,
pcavector  x,
pavector  y 
)

Symmetric matrix-vector multiplication, $y \gets y + \alpha A x$, where $A$ is assumed to be self-adjoint and only its lower triangular part is used.

Parameters
alphaScaling factor $\alpha$.
h2Matrix $A$.
xSource vector $x$.
yTarget vector $y$.
void addevaltrans_h2matrix_avector ( field  alpha,
pch2matrix  h2,
pcavector  x,
pavector  y 
)

Adjoint matrix-vector multiplication $y \gets y + \alpha A^* x$.

The adjoint matrix is multiplied by the source vector $x$, the result is scaled by $\alpha$ and added to the target vector $y$.

Parameters
alphaScaling factor $\alpha$.
h2Matrix $A$.
xSource vector $x$.
yTarget vector $y$.
void addmul_amatrix_h2matrix_amatrix ( field  alpha,
bool  atrans,
pcamatrix  A,
bool  btrans,
pch2matrix  B,
pamatrix  C 
)

Matrix multiplication $ C \gets C + \alpha A B $, $ C \gets C + \alpha A^* B $, $ C \gets C + \alpha A B^* $ or $ C \gets C + \alpha A^* B^* $.

Multiplies an amatrix by an h2matrix. For the truncated multiplication of two h2matrix objects, see addmul_h2matrix.

Parameters
alphaScaling factor $\alpha$.
atransSet if $A^*$ is to be used instead of $A$.
AFirst source amatrix $A$.
btransSet if $B^*$ is to be used instead of $B$.
BSecond source h2matrix $B$.
CTarget amatrix $C$.
void addmul_h2matrix_amatrix_amatrix ( field  alpha,
bool  atrans,
pch2matrix  A,
bool  btrans,
pcamatrix  B,
pamatrix  C 
)

Matrix multiplication $ C \gets C + \alpha A B $, $ C \gets C + \alpha A^* B $, $ C \gets C + \alpha A B^* $ or $ C \gets C + \alpha A^* B^* $.

Multiplies an h2matrix by an amatrix. For the truncated multiplication of two h2matrix objects, see addmul_h2matrix.

Parameters
alphaScaling factor $\alpha$.
atransSet if $A^*$ is to be used instead of $A$.
AFirst source h2matrix $A$.
btransSet if $B^*$ is to be used instead of $B$.
BSecond source amatrix $B$.
CTarget amatrix $C$.
ph2matrix build_from_block_h2matrix ( pcblock  b,
pclusterbasis  rb,
pclusterbasis  cb 
)

Build an h2matrix object from a block tree using given cluster bases.

Remarks
Submatrices for far- and nearfield leaves are created, but their coefficients are not initialized.
Parameters
bBlock tree.
rbRow cluster basis.
cbColumn cluster basis.
Returns
New h2matrix object.
pblock build_from_h2matrix_block ( pch2matrix  G)

Build an block tree from an h2matrix.

Parameters
GInput h2matrix.
Returns
New block tree corresponding to the structure of G.
void clear_h2matrix ( ph2matrix  h2)

Set an h2matrix to zero by clearing all far- and nearfield matrices.

Parameters
h2Target matrix.
ph2matrix clone_h2matrix ( pch2matrix  h2,
pclusterbasis  rb,
pclusterbasis  cb 
)

Builds a new h2matrix with clusterbasis rb and cb and the block structure of h2. Copies all coupling matrices $ S_b,\ b \in \mathcal L_{\mathcal I \times \mathcal J}^+$ to the clone.

Parameters
h2Input h2matrix which has to be cloned.
rbRow clusterbasis for the clone.
cbColumn clusterbasis for the clone.
Returns
New h2matrix with clusterbasis rb and cb and the same data as h2.
ph2matrix clonestructure_h2matrix ( pch2matrix  h2,
pclusterbasis  rb,
pclusterbasis  cb 
)

Builds a new h2matrix with clusterbasis rb and cb and the block structure of h2.

Parameters
h2Input h2matrix whose structure has to be cloned.
rbRow clusterbasis for the clone.
cbColumn clusterbasis for the clone.
Returns
New h2matrix with clusterbasis rb and cb and the same block structure as h2.
void collectdense_h2matrix ( pcamatrix  a,
pcclusterbasis  rb,
pcclusterbasis  cb,
pamatrix  s 
)

Compute $S \gets V_t^* A W_s$.

If row and column basis are orthogonal, the result is the coupling matrix for the optimal approximation of $A$ in these bases with respect to the spectral and Frobenius norms.

Parameters
aSource matrix $A$.
rbRow basis $(V_t)_{t\in{\mathcal T}_{\mathcal I}}$.
cbColumn basis $(W_s)_{s\in{\mathcal T}_{\mathcal J}}$.
sTarget matrix, will be overwritten by $V_t^* A W_s$.
void del_h2matrix ( ph2matrix  h2)

Delete an h2matrix object.

Releases the storage corresponding to the object. If this h2matrix contains pointers to submatrices, the submatrices are released by unref_h2matrix.

Only objects with h2->refs==0 may be deleted.

Parameters
h2Object to be deleted.
void draw_cairo_h2matrix ( cairo_t *  cr,
pch2matrix  G,
bool  storage,
uint  levels 
)

Draw a h2matrix to a cairo surface.

Parameters
crCairo surface to be drawn to.
GThe h2matrix that should be drawn.
storageFlag that indicates if the storage requirements for every block should be depicted into the graphic.
levelsNumber of levels of the h2matrix that should be drawn. If level == 0 holds, all levels will be drawn.
ph2matrix* enumerate_h2matrix ( ph2matrix  h2)

Enumerate h2matrix according to block tree.

The h2matrix submatrices are enumerated in an array of size h2->desc. The enumeration starts with 0 assigned to the root and then proceeds column-wise starting with b->sons[0] corresponding to the entries 1 to h2->sons[0]->desc in the array and ending with h2->sons[rsons*csons-1] corresponding to the last b->sons[rsons*csons-1]->desc entries.

Parameters
h2Matrix matching the block structure given by b.
Returns
Array of size h2->desc containing pointers to the h2matrix objects corresponding to descendants of h2.
void fastaddeval_h2matrix_avector ( field  alpha,
pch2matrix  h2,
pavector  xt,
pavector  yt 
)

Interaction phase of the matrix-vector multiplication.

Nearfield blocks are added directly $y|_{\hat t} \gets y|_{\hat t} + A|_{\hat t\times\hat s} x|_{\hat s}$, farfield block contributions are accumulated $\hat y_t \gets \hat y_t + S_{t,s} \hat x_s$.

Both xt and yt should be coefficient vectors provided by new_coeffs_clusterbasis_avector, xt is usually initialized by forward_clusterbasis_avector, while yt is typically added to the result using backward_clusterbasis_avector.

Parameters
alphaScaling factor $\alpha$.
h2Matrix $A$.
xtCoefficients $(\hat x_s)_{s\in\mathcal{T}_{\mathcal J}}$ of the source vector with respect to the column basis h2->cb.
ytCoefficients $(\hat y_t)_{t\in\mathcal{T}_{\mathcal I}}$ of the target vector with respect to the row basis h2->rb.
void fastaddevaltrans_h2matrix_avector ( field  alpha,
pch2matrix  h2,
pavector  xt,
pavector  yt 
)

Interaction phase of the adjoint matrix-vector multiplication.

Nearfield blocks are added directly $y|_{\hat s} \gets y|_{\hat s} + A|_{\hat t\times\hat s}^* x|_{\hat t}$, farfield block contributions are accumulated $\hat y_s \gets \hat y_s + S_{t,s}^* \hat x_t$.

Both xt and yt should be coefficient vectors provided by new_coeffs_clusterbasis_avector, xt is usually initialized by forward_clusterbasis_avector, while yt is typically added to the result using backward_clusterbasis_avector.

Parameters
alphaScaling factor $\alpha$.
h2Matrix $A$.
xtCoefficients $(\hat x_t)_{t\in\mathcal{T}_{\mathcal I}}$ of the source vector with respect to the row basis h2->rb.
ytCoefficients $(\hat y_s)_{s\in\mathcal{T}_{\mathcal J}}$ of the target vector with respect to the column basis h2->cb.
void fastaddmul_h2matrix_amatrix_amatrix ( field  alpha,
bool  atrans,
pch2matrix  A,
pcamatrix  Bt,
pamatrix  Ct 
)

Interaction phase of the h2matrix - amatrix multiplication.

If atrans==false, nearfield blocks are added directly $C|_{\hat t\times m} \gets C|_{\hat t\times m} + \alpha A|_{\hat t\times\hat s} B|_{\hat s\times m}$, farfield block contributions are accumulated $\widehat Y_t \gets \widehat Y_t + \alpha S_{t,s} \widehat B_s$. Both bt and ct should be coefficient matrices with the same number of columns and cb->ktree and rb->ktree rows, respectively.

If atrans==true, nearfield blocks are treated by $C|_{\hat s\times m} \gets C|_{\hat s\times m} + \alpha A|_{\hat t\times\hat s}^* B|_{\hat t\times m}$, farfield block contributions are accumulated $\widehat Y_s \gets \widehat Y_s + \alpha S_{t,s}^* \widehat B_t$. Both bt and ct should be coefficient matrices with the same number of columns and rb->ktree and cb->ktree rows, respectively.

bt is usually initialized by forward_clusterbasis_amatrix, while ct is typically added to the result using backward_clusterbasis_amatrix.

Parameters
alphaScaling factor $\alpha$.
atransSet if $A^*$ is to be used instead of $A$.
AFirst source matrix $A$.
BtSecond source matrix, expressed through coefficient matrices $(\widehat X_s)_{s\in\mathcal{T}_{\mathcal J}}$ of the second source matrix with respect to the column basis h2->cb if atrans==false and through $(\widehat X_t)_{t\in\mathcal{T}_{\mathcal I}}$ with respect to the row basis h2->rb otherwise.
CtTarget matrix, expressed through coefficient matrices $(\widehat Y_t)_{t\in\mathcal{T}_{\mathcal I}}$ with respect to the row basis h2->rb if atrans==false and through $(\widehat Y_s)_{s\in\mathcal{T}_{\mathcal J}}$ with respect to the column basis h2->cb otherwise.
uint getcols_h2matrix ( pch2matrix  h2)

Get the number of columns of an h2matrix $G$.

Parameters
h2Matrix $G$.
Returns
Number of columns of $G$.
size_t getfarsize_h2matrix ( pch2matrix  h2)

Get size of the farfield part of a given h2matrix object.

Parameters
h2$\mathcal{H}^2$-matrix object.
Returns
Size of allocated storage for farfield in bytes.
size_t getnearsize_h2matrix ( pch2matrix  h2)

Get size of the nearfield part of a given h2matrix object.

Parameters
h2$\mathcal{H}^2$-matrix object.
Returns
Size of allocated storage for nearfield in bytes.
uint getrows_h2matrix ( pch2matrix  h2)

Get the number of rows of an h2matrix $G$.

Parameters
h2Matrix $G$.
Returns
Number of rows of $G$.
size_t getsize_h2matrix ( pch2matrix  h2)

Get size of a given h2matrix object.

Parameters
h2$\mathcal{H}^2$-matrix object.
Returns
Size of allocated storage in bytes.
size_t gettotalsize_h2matrix ( pch2matrix  h2)

Get total size of a given h2matrix object, including cluster bases.

Parameters
h2$\mathcal{H}^2$-matrix object.
Returns
Size of allocated storage in bytes.
void iterate_bycol_h2matrix ( ph2matrix  G,
uint  mname,
uint  rname,
uint  cname,
uint  pardepth,
h2matrix_callback_t  pre,
h2matrix_callback_t  post,
void *  data 
)

Iterate through all submatrices of an h2matrix.

If the iterator works with multiple threads, it guarantees that threads running in parallel call the pre and post functions with different column clusters.

Parameters
GMatrix.
mnameNumber of matrix block.
rnameNumber of row cluster.
cnameNumber of column cluster.
pardepthParallization depth.
preFunction called before accessing sons.
postFunction called after accessing sons.
dataAdditional data passed to callback functions.
void iterate_byrow_h2matrix ( ph2matrix  G,
uint  mname,
uint  rname,
uint  cname,
uint  pardepth,
h2matrix_callback_t  pre,
h2matrix_callback_t  post,
void *  data 
)

Iterate through all submatrices of an h2matrix.

If the iterator works with multiple threads, it guarantees that threads running in parallel call the pre and post functions with different row clusters.

Parameters
GMatrix.
mnameNumber of matrix block.
rnameNumber of row cluster.
cnameNumber of column cluster.
pardepthParallization depth.
preFunction called before accessing sons.
postFunction called after accessing sons.
dataAdditional data passed to callback functions.
void iterate_collist_h2matrix ( ph2matrix  G,
uint  mname,
uint  rname,
uint  cname,
uint  pardepth,
h2matrixlist_callback_t  pre,
h2matrixlist_callback_t  post,
void *  data 
)

Iterate through all submatrices of an h2matrix, collecting all column blocks in an h2matrixlist object.

Parameters
GMatrix.
mnameNumber of matrix block.
rnameNumber of row cluster.
cnameNumber of column cluster.
pardepthParallization depth.
preFunction called before accessing sons.
postFunction called after accessing sons.
dataAdditional data passed to callback functions.
void iterate_h2matrix ( ph2matrix  G,
uint  mname,
uint  rname,
uint  cname,
uint  pardepth,
h2matrix_callback_t  pre,
h2matrix_callback_t  post,
void *  data 
)

Iterate through all submatrices of an h2matrix.

If the iterator works with multiple threads, it guarantees that threads running in parallel call the pre and post functions with different row and column clusters.

Parameters
GMatrix.
mnameNumber of matrix block.
rnameNumber of row cluster.
cnameNumber of column cluster.
pardepthParallization depth.
preFunction called before accessing sons.
postFunction called after accessing sons.
dataAdditional data passed to callback functions.
void iterate_rowlist_h2matrix ( ph2matrix  G,
uint  mname,
uint  rname,
uint  cname,
uint  pardepth,
h2matrixlist_callback_t  pre,
h2matrixlist_callback_t  post,
void *  data 
)

Iterate through all submatrices of an h2matrix, collecting all row blocks in an h2matrixlist object.

Parameters
GMatrix.
mnameNumber of matrix block.
rnameNumber of row cluster.
cnameNumber of column cluster.
pardepthParallization depth.
preFunction called before accessing sons.
postFunction called after accessing sons.
dataAdditional data passed to callback functions.
void mvm_h2matrix_avector ( field  alpha,
bool  h2trans,
pch2matrix  h2,
pcavector  x,
pavector  y 
)

Matrix-vector multiplication $y \gets y + \alpha A x$ or $y \gets y + \alpha A^* x$.

The matrix or its adjoint is multiplied by the source vector $x$, the result is scaled by $\alpha$ and added to the target vector $y$.

Parameters
alphaScaling factor $\alpha$.
h2transSet if $A^*$ is to be used instead of $A$.
h2Matrix $A$.
xSource vector $x$.
yTarget vector $y$.
ph2matrix new_full_h2matrix ( pclusterbasis  rb,
pclusterbasis  cb 
)

Create a new h2matrix object representing a standard dense matrix.

Allocates storage for the object containing an amatrix object.

Remarks
Should always be matched by a call to del_h2matrix. This call happens automatically if the last object referencing this object (see ref_h2matrix) is deleted.
Parameters
rbRow cluster basis.
cbColumn cluster basis.
Returns
New h2matrix object containing a new amatrix.
ph2matrix new_h2matrix ( pclusterbasis  rb,
pclusterbasis  cb 
)

Create a new h2matrix object.

Allocates storage for the object and sets the matrix pointers to NULL, representing a zero matrix.

Remarks
Should always be matched by a call to del_h2matrix. This call happens automatically if the last object referencing this object (see ref_h2matrix) is deleted.
Parameters
rbRow cluster basis.
cbColumn cluster basis.
Returns
New h2matrix object.
ph2matrix new_super_h2matrix ( pclusterbasis  rb,
pclusterbasis  cb,
uint  rsons,
uint  csons 
)

Create a new hmatrix object representing a subdivided matrix.

Allocates storage for the object representing a matrix with submatrices. The submatrices are initialized with NULL pointers and have to be set up with ref_hmatrix.

Remarks
Should always be matched by a call to del_h2matrix. This call happens automatically if the last object referencing this object (see ref_h2matrix) is deleted.
Parameters
rbRow cluster basis.
cbColumn cluster basis.
rsonsNumber of block rows.
csonsNumber of block columns.
Returns
New h2matrix object with submatrices.
ph2matrix new_uniform_h2matrix ( pclusterbasis  rb,
pclusterbasis  cb 
)

Create a new h2matrix object representing a uniform matrix.

Allocates storage for the object containing a uniform object.

Remarks
Should always be matched by a call to del_h2matrix. This call happens automatically if the last object referencing this object (see ref_h2matrix) is deleted.
Parameters
rbRow cluster basis.
cbColumn cluster basis.
Returns
New h2matrix object containing a new uniform matrix.
ph2matrix new_zero_h2matrix ( pclusterbasis  rb,
pclusterbasis  cb 
)

Create a new h2matrix object representing a zero matrix.

Allocates storage for the object representing a zero matrix.

Remarks
Should always be matched by a call to del_h2matrix. This call happens automatically if the last object referencing this object (see ref_h2matrix) is deleted.
Parameters
rbRow cluster basis.
cbColumn cluster basis.
Returns
New h2matrix object.
real norm2_h2matrix ( pch2matrix  H2)

Approximate the spectral norm $\|H\|_2$ of a matrix $H$.

The spectral norm is approximated by applying a few steps of the power iteration to the matrix $H^* H$ and computing the square root of the resulting eigenvalue approximation.

Parameters
H2$\mathcal H^2$ matrix $H$.
Returns
Approximation of $\|H\|_2$.
real norm2diff_h2matrix ( pch2matrix  a,
pch2matrix  b 
)

Approximate the spectral norm $\|A-B\|_2$ of the difference of two matrices $A$ and $B$.

The spectral norm is approximated by applying a few steps of the power iteration to the matrix $(A-B)^* (A-B)$ and computing the square root of the resulting eigenvalue approximation.

Parameters
a$\mathcal H^2$ matrix $A$.
b$\mathcal H^2$ matrix $B$.
Returns
Approximation of $\|A-B\|_2$.
void project_amatrix_h2matrix ( ph2matrix  h2,
pcamatrix  a 
)

Compute the best approximation of a given matrix $A$ with respect to an $\mathcal{H}^2$-matrix space.

All nearfield blocks will be copied (and permuted according to the cluster numbering), all farfield blocks will be approximated by coupling matrices $S_{t,s} = V_t^* A|_{\hat t\times\hat s} W_s$.

Remarks
In order to obtain the best approximation, both the row basis h2->rb and the column basis h2->cb should be orthogonal.
Parameters
h2Target matrix, will be overwritten by the best approximation of the source matrix.
aSource matrix.
void project_hmatrix_h2matrix ( ph2matrix  h2,
phmatrix  h 
)

Compute the best approximation of a given matrix $A$ with respect to an $\mathcal{H}^2$-matrix space.

All nearfield blocks will be copied (and permuted according to the cluster numbering), all farfield blocks $A|_{\hat t\times\hat s} = X Y^*$ will be approximated by coupling matrices $S_{t,s} = (V_t^* X) (W_s^* Y)^*$.

Remarks
In order to obtain the best approximation, both the row basis h2->rb and the column basis h2->cb should be orthogonal.
Parameters
h2Target matrix, will be overwritten by the best approximation of the source matrix.
hSource matrix.
void random_h2matrix ( ph2matrix  h2)

Fill an h2matrix with random coefficients.

Parameters
h2Target matrix $G$.
ph2matrix read_cdf_h2matrix ( const char *  name,
pclusterbasis  rb,
pclusterbasis  cb 
)

Read h2matrix from NetCDF file.

Parameters
nameFile name.
rbRow cluster basis.
cbColumn cluster basis.
Returns
h2matrix read from file.
ph2matrix read_cdfcomplete_h2matrix ( const char *  name)

Read h2matrix from NetCDF file, including cluster trees and cluster bases.

Parameters
nameFile name.
Returns
h2matrix read from file.
ph2matrix read_cdfpart_h2matrix ( int  nc_file,
const char *  prefix,
pclusterbasis  rb,
pclusterbasis  cb 
)

Read h2matrix from part of a NetCDF file.

Parameters
nc_fileFile handle.
prefixPrefix for variable names.
rbRow cluster basis.
cbColumn cluster basis.
Returns
h2matrix read from file.
void ref_h2matrix ( ph2matrix ptr,
ph2matrix  h2 
)

Set a pointer to an h2matrix object, increase its reference counter, and decrease reference counter of original pointer target.

Parameters
ptrPointer to the ph2matrix variable that will be changed.
h2h2matrix that will be referenced.
void scale_h2matrix ( field  alpha,
ph2matrix  h2 
)

Scale an h2matrix by a factor.

Parameters
alphaScaling factor $\alpha$.
h2Target matrix $G$, will be overwritten by $\alpha G$.
void unref_h2matrix ( ph2matrix  h2)

Reduce the reference counter of an h2matrix object.

If the reference counter reaches zero, the object is deleted.

Remarks
Use ref_h2matrix with h2=NULL instead, since this guarantees that the pointer is properly invalidated.
Parameters
h2h2matrix that will be unreferenced.
void update_h2matrix ( ph2matrix  h2)

Complete the initialisation of a h2matrix object.

Complete the initialisation of the h2matrix object after all sons have been initialised. The number of the descendants of the $\mathcal{H}^2$-matrix is computed from the desc fields of its sons.

Parameters
h2$\mathcal{H}^2$-matrix to be completed.
void write_cdf_h2matrix ( pch2matrix  G,
const char *  name 
)

Write h2matrix to NetCDF file.

Parameters
GMatrix.
nameFile name.
void write_cdfcomplete_h2matrix ( pch2matrix  G,
const char *  name 
)

Write h2matrix to NetCDF file, including cluster trees and cluster bases.

Parameters
GMatrix.
nameFile name.
void write_cdfpart_h2matrix ( pch2matrix  G,
int  nc_file,
const char *  prefix 
)

Write h2matrix to part of a NetCDF file.

Parameters
GMatrix.
nc_fileFile handle.
prefixPrefix for variable names.