e3j.utils.sparse.SparseMixin¶
- class e3j.utils.sparse.SparseMixin¶
Properties and methods depending on a
coefattribute.The
coefattribute can in fact be either of type:jax.experimental.sparse.BCOO, ornp.ndarray: in this case some properties and methods will fail, such as.aggregate(),.nnz…
To switch between possible equivalent methods – typically, a matrix product or scatter-add operation in a final reduction stage, child classes such as
TensorProductorBigotimesoverride theaggregation_methoddescriptor during__init__. The default attempts to read$E3J_AGGREGATION_METHODfrom environment.Methods
Attributes
Cache
self._aggregation_methodwith default.coefA writable cache descriptor.
indicesnnznnz_ratioshapeReturn aggregation matrix of shape
(nnz, dim_out).values- __init__()¶
- aggregate(values, layout: Layout | str = 'E3NN')¶
Aggregate a values-like vector on output coordinates.
- Parameters:
values (np.ndarray) – a vector of length
self.nnz, e.g. the product of CG coefficients with input coordinates.layout – array layout for scatter-based aggregation.
- Returns:
a vector of shape
target.dim.- Return type:
np.ndarray
- property aggregation_method: Aggregation¶
Cache
self._aggregation_methodwith default.
- property target_matrix: BCOO | Array¶
Return aggregation matrix of shape
(nnz, dim_out).By default, the aggregation matrix is a dense array. To get a sparse array, set the environment variable E3J_AGGREGATION_METHOD to “sparse”.
Example
Number of coefficients above each output coordinate:
>>> num_coefs = jnp.ones(op.nnz) @ op.target_matrix