H2Lib
3.0
|
Representation of cluster bases for -matrices. More...
Data Structures | |
struct | _clusterbasis |
Representation of a cluster basis. More... | |
Typedefs | |
typedef struct _clusterbasis | clusterbasis |
Representation of a cluster basis. | |
typedef clusterbasis * | pclusterbasis |
Pointer to clusterbasis object. | |
typedef const clusterbasis * | pcclusterbasis |
Pointer to constant clusterbasis object. | |
Representation of cluster bases for -matrices.
The clusterbasis class represents a cluster basis , typically described by transfer matrices as for non-leaf clusters .
void addeval_clusterbasis_avector | ( | field | alpha, |
pcclusterbasis | cb, | ||
pcavector | yc, | ||
pavector | yp | ||
) |
Compute .
Similar to expand_clusterbasis_avector , but allocates and frees the required auxiliary storage automatically.
alpha | Scaling factor . |
cb | Cluster basis. |
yc | Source vector of dimension cb->k . |
yp | Target vector of dimension cb->t->size using cluster numbering corresponding to cb->t . |
void addevaltrans_clusterbasis_avector | ( | field | alpha, |
pcclusterbasis | cb, | ||
pcavector | xp, | ||
pavector | xc | ||
) |
Compute .
Similar to compress_clusterbasis_avector , but allocates and frees the required auxiliary storage automatically.
alpha | Scaling factor . |
cb | Cluster basis. |
xp | Source vector of dimension cb->t->size using cluster numbering corresponding to cb->t . |
xc | Target vector of dimension cb->k . |
void backward_clusterbasis_amatrix | ( | pcclusterbasis | cb, |
pamatrix | Yt, | ||
pamatrix | Yp | ||
) |
Matrix backward transformation.
Compute for all elements of the cluster basis.
Matrix version of backward_nopermutation_clusterbasis_avector.
cb | Cluster basis. |
Yt | Source matrix with cb->ktree rows, filled with a mix of transformed coefficients and permuted coefficients. The matrix will be overwritten by the function. |
Yp | Target matrix using cluster numbering corresponding to cb->t in the rows. |
void backward_clusterbasis_avector | ( | pcclusterbasis | cb, |
pavector | yt, | ||
pavector | y | ||
) |
Backward transformation.
Compute for all elements of the cluster basis. This function also adds permuted coefficients contained in yt
to the result vector. It can be used to add the result of fastaddeval_h2matrix_avector or fastaddevaltrans_h2matrix_avector to the target vector.
The contents of yt
are interpreted as in the function forward_clusterbasis_avector : if cb
is not a leaf, the first cb->k
rows of yt
are coefficients to be multiplied by , followed by cb->son[0]->ktree
coefficients for the first son, and cb->son[i]->ktree
coefficients for the i
-th son, until the last son with i==sons-1
has been reached.
If cb
is a leaf, the first cb->k
rows of yt
are also coefficients to be multiplied by , followed by cb->t->size
coefficients in cluster numbering to be added to appropriate entries of the target vector.
y
via the indices in cb->t->idx
, so even if cb
corresponds only to a small cluster, y
usually has to be a vector corresponding to the root of the cluster tree in the original numbering. In order to work efficiently with subvectors, consider using backward_nopermutation_clusterbasis_avector .cb | Cluster basis. |
yt | Source vector of dimension cb->ktree , filled with a mix of transformed coefficients and permuted coefficients. This vector will be overwritten by the function. |
y | Target vector. |
void backward_clusterbasis_trans_amatrix | ( | pcclusterbasis | cb, |
pamatrix | Yt, | ||
pamatrix | Yp | ||
) |
Adjoint matrix backward transformation.
Compute for all elements of the cluster basis.
Matrix version of backward_nopermutation_clusterbasis_avector.
cb | Cluster basis. |
Yt | Source matrix with cb->ktree rows, filled with a mix of transformed coefficients and permuted coefficients. The matrix will be overwritten by the function. |
Yp | Target matrix using cluster numbering corresponding to cb->t in the columns. |
void backward_nopermutation_clusterbasis_avector | ( | pcclusterbasis | cb, |
pavector | yt, | ||
pavector | yp | ||
) |
Backward transformation for vectors in cluster numbering.
Version of backward_clusterbasis_avector that takes a vector using cluster numbering.
cb | Cluster basis. |
yt | Source vector of dimension cb->ktree , filled with a mix of transformed coefficients and permuted coefficients. This vector will be overwritten by the function. |
yp | Target vector of dimension cb->t->size using cluster numbering corresponding to cb->t . |
void backward_notransfer_clusterbasis_avector | ( | pcclusterbasis | cb, |
pavector | yt, | ||
pavector | y | ||
) |
Backward transformation without transfer matrices.
Version of backward_clusterbasis_avector that uses the matrices cb->V
for all clusters, not only for leaves.
cb | Cluster basis with cb->V initialized for all descendants. |
yt | Source vector of dimension cb->ktree , filled with a mix of transformed coefficients and permuted coefficients. This vector will be overwritten by the function. |
y | Target vector. |
void backward_parallel_clusterbasis_avector | ( | pcclusterbasis | cb, |
pavector | yt, | ||
pavector | y, | ||
uint | pardepth | ||
) |
Parallel backward transformation.
Parallel version of backward_clusterbasis_avector.
cb | Cluster basis. |
yt | Source vector of dimension cb->ktree , filled with a mix of transformed coefficients and permuted coefficients. This vector will be overwritten by the function. |
y | Target vector. |
pardepth | Parallelization depth. |
pclusterbasis build_from_cluster_clusterbasis | ( | pccluster | t | ) |
Construct a clusterbasis from a cluster tree.
All ranks will be set to zero.
t | Root cluster. |
real check_ortho_clusterbasis | ( | pcclusterbasis | cb | ) |
Check whether a cluster basis is orthogonal.
Returns the maximum of (for leaf clusters) and (for non-leaf clusters). If the result is significantly larger than machine eps, the cluster basis should not be considered orthogonal.
cb | Cluster basis. |
cb
. void clear_weight_clusterbasis | ( | pclusterbasis | cb | ) |
Delete all weight matrices of the clusterbasis and its descendants.
cb | Target clusterbasis object. |
pclusterbasis clone_clusterbasis | ( | pcclusterbasis | cb | ) |
Create a copy of a clusterbasis.
All sons are copied as well, including all coefficients.
cb | Source clusterbasis. |
cb
. pclusterbasis clonestructure_clusterbasis | ( | pcclusterbasis | cb | ) |
Copy the tree structure of a clusterbasis.
All sons are copied as well. Coefficients are not copied, all ranks of the new clusterbasis are set to zero.
cb | Source clusterbasis. |
cb
. void compress_clusterbasis_amatrix | ( | pcclusterbasis | cb, |
pcamatrix | Xp, | ||
pamatrix | Xt | ||
) |
Compute .
Version of compress_clusterbasis_avector that works for matrices instead of vectors, applying the transformation to all columns simultaneously.
cb | Cluster basis. |
Xp | Source matrix using cluster numbering corresponding to cb->t in the rows. |
Xt | Target vector with cb->kbranch rows. Its first cb->k rows will be filled by the transformed coefficients. |
void compress_clusterbasis_avector | ( | pcclusterbasis | cb, |
pcavector | xp, | ||
pavector | xt | ||
) |
Compute .
Similar to forward_nopermutation_clusterbasis_avector , this function computes using the transfer matrices and the leaf matrices .
It differs from forward_nopermutation_clusterbasis_avector in that is returned only for the root cluster, not for its descendants. This allows the function to reduce auxiliary storage requirements by re-using storage among different branches of the cluster tree.
cb | Cluster basis. |
xp | Source vector using cluster numbering corresponding to cb->t . |
xt | Target vector of dimension cb->kbranch . Its first cb->k rows will be filled by the transformed coefficients. |
void compress_parallel_clusterbasis_amatrix | ( | pcclusterbasis | cb, |
pcamatrix | Xp, | ||
pamatrix | Xt, | ||
uint | pardepth | ||
) |
Compute .
Parallel version of compress_clusterbasis_amatrix.
cb | Cluster basis. |
Xp | Source matrix using cluster numbering corresponding to cb->t in the rows. |
Xt | Target vector with cb->kbranch rows. Its first cb->k rows will be filled by the transformed coefficients. |
pardepth | Parallelization depth |
void del_clusterbasis | ( | pclusterbasis | cb | ) |
Delete a clusterbasis object.
Releases the storage corresponding to the object. If this clusterbasis references sons, these sons are unreferenced.
Only objects with cb->refs==0
may be deleted.
cb | Object to be deleted. |
pclusterbasis* enumerate_clusterbasis | ( | pccluster | t, |
pclusterbasis | cb | ||
) |
Enumerate clusterbasis according to cluster tree.
The clusterbasis elements are enumerated in an array of size t->desc
. The enumeration starts with 0
assigned to the root and then proceeds with cb->son[0]
corresponding to the entries 1
to t->son[0]->desc
in the array and ending with cb->son[sons-1]
corresponding to the last t->son[sons-1]->desc
entries.
t | Cluster tree. |
cb | Cluster basis matching the cluster tree given by t . |
t->desc
containing pointers to the clusterbasis objects corresponding to cb
and its descendants. void expand_clusterbasis_avector | ( | pcclusterbasis | cb, |
pavector | yt, | ||
pavector | yp | ||
) |
Add to target vector .
Similar to backward_nopermutation_clusterbasis_avector, this function computes using the transfer matrices and the leaf matrices .
It differs from forward_nopermutation_clusterbasis_avector in that only is added, not the contributions of the descendants. This allows the function to reduce auxiliary storage requirements by re-using storage among different branches of the cluster tree.
cb | Cluster basis. |
yt | Target vector of dimension cb->kbranch . Its first cb->k rows contain transformed coefficients. |
yp | Source vector using cluster numbering corresponding to cb->t . |
void forward_clusterbasis_amatrix | ( | pcclusterbasis | cb, |
pcamatrix | Xp, | ||
pamatrix | Xt | ||
) |
Matrix forward transformation.
Compute for all elements of the cluster basis.
Matrix version of forward_nopermutation_clusterbasis_avector.
cb | Cluster basis. |
Xp | Source matrix using cluster numbering corresponding to cb->t in the rows. |
Xt | Target matrix with cb->ktree rows, will be filled with a mix of transformed coefficients and permuted coefficients. |
void forward_clusterbasis_avector | ( | pcclusterbasis | cb, |
pcavector | x, | ||
pavector | xt | ||
) |
Forward transformation.
Compute for all elements of the cluster basis. This function also stores the permuted coefficients corresponding to the leaves of the cluster basis in the result, preparing all the necessary information for the multiplication phase realized in fastaddeval_h2matrix_avector and fastaddevaltrans_h2matrix_avector.
If cb
is not a leaf, the first cb->k
rows of xt
are filled with . The following cb->son[0]->ktree
entries are filled with the coefficients for the first son, proceeding until the last cb->son[sons-1]->ktree
entries are filled with the coefficients for the last son.
If cb
is a leaf, the first cb->k
rows of xt
are also filled with . The following cb->t->size
rows are filled with the coefficients of the original vector x
using the cluster numbering of cb->t
.
x
via the indices in cb->t->idx
, so even if cb
corresponds only to a small cluster, x
usually has to be a vector corresponding to the root of the cluster tree in the original numbering. In order to work efficiently with subvectors, consider using forward_nopermutation_clusterbasis_avector .cb | Cluster basis. |
x | Source vector. |
xt | Target vector of dimension cb->ktree , will be filled with a mix of transformed coefficients and permuted coefficients. |
void forward_clusterbasis_trans_amatrix | ( | pcclusterbasis | cb, |
pcamatrix | Xp, | ||
pamatrix | Xt | ||
) |
Adjoint matrix forward transformation.
Compute for all elements of the cluster basis.
Matrix version of forward_nopermutation_clusterbasis_avector.
cb | Cluster basis. |
Xp | Source matrix using cluster numbering corresponding to cb->t in the columns. |
Xt | Target matrix with cb->ktree rows, will be filled with a mix of transformed coefficients and permuted coefficients. |
void forward_nopermutation_clusterbasis_avector | ( | pcclusterbasis | cb, |
pcavector | xp, | ||
pavector | xt | ||
) |
Forward transformation for vectors using cluster numbering.
Version of forward_clusterbasis_avector that takes a vector using cluster numbering.
cb | Cluster basis. |
xp | Source vector of dimension cb->t->size using cluster numbering corresponding to cb->t . |
xt | Target vector of dimension cb->ktree , will be filled with a mix of transformed coefficients and permuted coefficients. |
void forward_notransfer_clusterbasis_avector | ( | pcclusterbasis | cb, |
pcavector | x, | ||
pavector | xt | ||
) |
Forward transformation without transfer matrices.
Version of forward_clusterbasis_avector that uses the matrices cb->V
for all clusters, not only for leaves.
cb | Cluster basis with cb->V initialized for all descendants. |
x | Source vector. |
xt | Target vector of dimension cb->ktree , will be filled with a mix of transformed coefficients and permuted coefficients. |
void forward_parallel_clusterbasis_avector | ( | pcclusterbasis | cb, |
pcavector | x, | ||
pavector | xt, | ||
uint | pardepth | ||
) |
Parallel forward transformation.
Parallel version of forward_clusterbasis_avector.
cb | Cluster basis. |
x | Source vector. |
xt | Target vector of dimension cb->ktree , will be filled with a mix of transformed coefficients and permuted coefficients. |
pardepth | Parallelization depth. |
uint getactives_clusterbasis | ( | ) |
Get number of active clusterbasis objects.
size_t getsize_clusterbasis | ( | pcclusterbasis | cb | ) |
Get the size of a given clusterbasis object.
Yields the total size of this object and all its descendants.
cb | clusterbasis root. |
pclusterbasis init_clusterbasis | ( | pclusterbasis | cb, |
pccluster | t | ||
) |
Initialize a clusterbasis object.
Sets up the components of the object. If t
is not a leaf, the array son
is allocated, otherwise it is set to null.
cb | Object to be initialized. |
t | Corresponding cluster. |
pclusterbasis init_leaf_clusterbasis | ( | pclusterbasis | cb, |
pccluster | t | ||
) |
Initialize a clusterbasis object for a leaf.
Sets up the components of the object. Sets son
to null. If t->sons>0
, this yields a partial cluster basis.
cb | Object to be initialized. |
t | Corresponding cluster. |
pclusterbasis init_sub_clusterbasis | ( | pclusterbasis | cb, |
pclusterbasis | src, | ||
pccluster | t, | ||
uint | off | ||
) |
Initialize a clusterbasis object representing a leaf son cluster for a leaf cluster basis.
Sets up the components of the object, making V
a submatrix of src->V
. Sets son
to null. If t->sons>0,
this yields a partial cluster basis.
cb | Object to be initialized. |
src | Source cluster basis. |
t | Corresponding cluster. |
off | Row offset in src->V, should be number of elements of preceding sons. |
void iterate_clusterbasis | ( | pcclusterbasis | cb, |
uint | cbname, | ||
void(*)(pcclusterbasis cb, uint cbname, void *data) | pre, | ||
void(*)(pcclusterbasis cb, uint cbname, void *data) | post, | ||
void * | data | ||
) |
Hierarchical iterator for a clusterbasis.
Iterate over the cluster basis and all its descendants. The pre
function is called for each element before its descendants are processed, the post
function is called afterwards.
cbname
will take values between cbname
and cbname+cb->t->sons-1,
where cbname
is interpreted as the index of the root cb,
while the indices of the first son start at cbname+1,
the indices of the second at cbname+1+cb->t->son[0]->desc,
and so on.
cb | Root of the cluster basis tree. |
cbname | Number of the root. |
pre | Function to be called before the descendants of cb are processed. |
post | Function to be called after the descentants of cb have been processed. |
data | Additional data passed on to pre and post . |
void iterate_parallel_clusterbasis | ( | pcclusterbasis | cb, |
uint | cbname, | ||
uint | pardepth, | ||
void(*)(pcclusterbasis cb, uint cbname, void *data) | pre, | ||
void(*)(pcclusterbasis cb, uint cbname, void *data) | post, | ||
void * | data | ||
) |
Parallel hierarchical iterator for a clusterbasis.
Iterate over the cluster basis and all its descendants. The pre
function is called for each element before its descendants are processed, the post
function is called afterwards.
cbname
will take values between cbname
and cbname+cb->t->sons-1,
where cbname
is interpreted as the index of the root cb,
while the indices of the first son start at cbname+1,
the indices of the second at cbname+1+cb->t->son[0]->desc,
and so on.
cb | Root of the cluster basis tree. |
cbname | Number of the root. |
pardepth | Parallelization depth. |
pre | Function to be called before the descendants of cb are processed. |
post | Function to be called after the descentants of cb have been processed. |
data | Additional data passed on to pre and post . |
pclusterbasis new_clusterbasis | ( | pccluster | t | ) |
Create a new clusterbasis object.
Allocates storage for the object and sets up its components.
t | Corresponding cluster. |
pavector new_coeffs_clusterbasis_avector | ( | pcclusterbasis | cb | ) |
Create coefficient vector for cluster basis.
Creates a vector of dimension cb->ktree
to hold the coefficients computed by forward_clusterbasis_avector and expected by backward_clusterbasis_avector.
cb | Cluster basis. |
cb->ktree
. pclusterbasis new_leaf_clusterbasis | ( | pccluster | t | ) |
Create a new clusterbasis object for a leaf.
Allocates storage for the object and sets up its components.
t | Corresponding cluster. |
void ortho_clusterbasis | ( | pclusterbasis | cb, |
pclusteroperator | co | ||
) |
Orthogonalize a cluster basis.
Replace a given cluster basis by an orthogonal clusterbasis such that holds for suitable matrices .
cb | Original cluster basis . Will be overwritten by the orthogonal basis . |
co | If not null, will be filled with the matrices describing the basis change from the old to the new basis. The structure of this cluster operator has to match the structure of the cluster basis, you might consider using build_from_clusterbasis_clusteroperator |
pclusterbasis read_cdf_clusterbasis | ( | const char * | name, |
pccluster | t | ||
) |
Read clusterbasis from NetCdf file.
name | File name. |
t | Root cluster for cluster basis. |
pclusterbasis read_cdfpart_clusterbasis | ( | int | nc_file, |
const char * | prefix, | ||
pccluster | t | ||
) |
Read clusterbasis from part of a NetCdf file.
nc_file | File handle. |
prefix | Prefix for variable names. |
t | Root cluster for cluster basis. |
void ref_clusterbasis | ( | pclusterbasis * | ptr, |
pclusterbasis | cb | ||
) |
Set a pointer to a clusterbasis object, increase its reference counter, and decrease reference counter of original pointer target.
ptr | Pointer to the pclusterbasis variable that will be changed. |
cb | clusterbasis that will be referenced. |
void resize_clusterbasis | ( | pclusterbasis | cb, |
uint | k | ||
) |
Change the rank of a cluster basis and resize cb->V,
cb->son[i]->E
is resized for all sons.
cb->E
is not resized, since this is in most standard algorithms a task for the father cluster.cb | Cluster basis that will be changed. |
k | New rank, i.e., number of columns of V or cb->son[i]->E . |
void setrank_clusterbasis | ( | pclusterbasis | cb, |
uint | k | ||
) |
Change the rank of a cluster basis and resize cb->V
, while cb->son[i]->E
is resized for all sons.
cb->E
is not resized, since this is in most standard algorithms a task for the father cluster.cb | Cluster basis that will be changed. |
k | New rank, i.e., number of columns of V or cb->son[i]->E . |
void uninit_clusterbasis | ( | pclusterbasis | cb | ) |
Uninitializes a clusterbasis object.
Invalidates pointers, freeing corresponding storage if appropriate, and prepares the object for deletion.
If this clusterbasis references sons, these sons are unreferences.
Only objects with cb->refs==0
may be uninitialized.
cb | Object to be uninitialized. |
void unref_clusterbasis | ( | pclusterbasis | cb | ) |
Reduce the reference counter of a clusterbasis object.
If the reference counter reaches zero, the object is deleted.
cb=NULL
instead, since this guarantees that the pointer is properly invalidated.cb | clusterbasis that will be unreferenced. |
void update_clusterbasis | ( | pclusterbasis | cb | ) |
Updates bookkeeping information, e.g., cb->ktree,
for a clusterbasis object after its sons have been altered.
cb | clusterbasis that will be updated. |
void update_tree_clusterbasis | ( | pclusterbasis | cb | ) |
Updates bookkeeping information, e.g., cb->ktree,
for a clusterbasis object and all its descendants.
cb
itself, consider using update_clusterbasis.cb | Root of the clusterbasis tree that will be updated. |
pclusteroperator weight_clusterbasis_clusteroperator | ( | pcclusterbasis | cb, |
pclusteroperator | co | ||
) |
Compute weight matrices for a cluster basis.
Computes matrices for all clusters such that holds for all .
cb | Cluster basis . |
co | clusteroperator structure matching the tree of cb , will be overwritten with weight matrices. A simple way to set up this clusteroperator it to use build_from_clusterbasis_clusteroperator. |
co
. pamatrix weight_enum_clusterbasis_clusteroperator | ( | pcclusterbasis | cb | ) |
Compute weight matrices for a cluster basis using an iterator over the cluster tree.
Computes matrices for all clusters such that holds for all .
cb | Cluster basis . should be computed. |
void write_cdf_clusterbasis | ( | pcclusterbasis | cb, |
const char * | name | ||
) |
Write clusterbasis to NetCDF file.
cb | Cluster basis. |
name | File name. |
void write_cdfpart_clusterbasis | ( | pcclusterbasis | cb, |
int | nc_file, | ||
const char * | prefix | ||
) |
Write clusterbasis to part of NetCDF file.
cb | Cluster basis. |
nc_file | File handle. |
prefix | Prefix for variable names. |