Problem class

Class Problem stores discretized problem and block cluster tree.

class h2tools.problem.Problem(func, row_tree, col_tree, symmetric, verbose=False, mpi_comm=None)

Container for problem (as linear operator) and block cluster tree.

Contains problem setting as linear operator, which is represented by geometric data, corresponding to domain and area of linear operator, and function of interaction of discrete elements of domain and area. Since geometric data is discontinuous, given linear operator is assumed as matrix of interactions.

Domain and area of operator transform to columns and rows of matrix of interaction correspondingly. For convinience, domain (rows) is also called destination of interaction and area (columns) is also called source of interaction. It is to be more appropriate for N-body, electrostatics and other particle-to-particle interactions.

Interaction of discrete elements can be a scalar, vector, matrix or even a tensor. If interaction is not scalar, corresponding function must return tensor of shape (n_rows, ..., n_columns). There are examples of vector function of interactions in examples folder of h2tools git repository.

Cluster trees, corresponding to domain and area (or to source and destination), are called column and row cluster trees accordingly.

Parameters:

func : callable

Function of interaction. Should take 4 parameters (row_data, row_index, column_data, columns).

row_tree : ClusterTree

Row cluster tree, corresponding to area of operator or destination of interaction.

col_tree : ClusterTree

Column cluster tree, corresponding to domain of operator or source of interaction.

symmetric : boolean

Shows if domain and area or source and destination are the same, while linear operator itself is symmetric. Reduces mcbh factorization time by a multiplier of 2.

verbose : boolean

If True, outputs additional information, such as number of levels, nodes and leaves of cluster trees.

Attributes

_func: callable Function of interaction of objects (input parameter func).
row_data (Python object) Geometric data, corresponding to area of operator or destination of interaction.
col_data (Python object) Geometric data, corresponding to domain of operator or source of interaction.
symmetric (boolean) Shows if the problem is symmetric (input parameter symmetric).
shape (tuple) Shape of corresponding matrix of interactions.
func_shape: tuple Shape of each element of matrix (scalar/vector/matrix interactions). Shape of function of interaction of 2 discrete elements.
dtype (numpy.dtype) Data type of corresponding matrix of interactions.
row_tree (ClusterTree) Row cluster tree.
col_tree (ClusterTree) Column cluster tree.
row_block_size (integer) Maximum size of leaf-node of row cluster tree with nonempty near-field interactions.
col_block_size (integer) Maximum size of leaf-node of row cluster tree with nonempty near-field interactions.
row_far (list of list of integer) List of lists of admissibly far nodes for each node of row cluster tree. row_far[i] is a list of admissibly far nodes, corresponding to i-th node of row cluster tree.
col_far (list of list of integer) List of lists of admissibly far nodes for each node of column cluster tree. col_far[i] is a list of admissibly far nodes, corresponding to i-th node of column cluster tree.
dot(x, max_items=125000000)

Applies linear operator to a given vector from left side.

Parameters:

x : numpy.ndarray

Vector or block-vector to multiply

max_items : integer

Size of buffer (number of elements, same data type as matrix elements).

Returns:

numpy.ndarray

Result of A * x.

far_dot(x)

Applies farfield part of operator to vector from left side.

Parameters:

x : numpy.ndarray

Vector or block-vector to multiply.

Returns:

numpy.ndarray

Result of farfield A * x.

far_rdot(x)

Applies farfield part of operator to vector from right side.

Parameters:

x : numpy.ndarray

Vector or block-vector to multiply.

Returns:

numpy.ndarray

Result of farfield x * A.

func(row, col)

Matrix-like proxy to function.

Parameters:

row : numpy.ndarray(dtype=numpy.uint64)

rows, where to compute submatrix

col: numpy.ndarray(dtype=numpy.uint64)

columns, where to compute submatrix

Returns:

numpy.ndarray of shape (row.size, self.func_shape, col.size)

submatrix on intersection of rows row and columns col. can be scalar, vector or even ndarray

rdot(x, max_items=125000000)

Applies linear operator to a given vector from right side.

Parameters:

x : numpy.ndarray

Vector or block-vector to multiply

max_items : integer

Size of buffer (number of elements, same data type as matrix elements).

Returns:

numpy.ndarray

Result of x * A.