scimba_torch.numerical_solvers.functional_operator¶
Functional operators for PDEs with multiple labels.
Functions
|
Apply a dict of functions to a function. |
Apply a dict of vmaps to LabelTensors. |
|
|
Apply a function to a dict of functions. |
Concatenate a dict of tensors with indexes. |
|
|
Compose two functions. |
Split LabelTensors to a dict of tensors with indexes. |
|
|
Vectorize a dict of functions. |
Classes
|
Handle functional operators for PDEs with multiple labels. |
- split_label_tensors_to_dict_of_tensors_with_indexes(splitting_scheme, labels, *args)[source]¶
Split LabelTensors to a dict of tensors with indexes.
- Parameters:
splitting_scheme (
Sequence[int|tuple[int]]) – Sequence of keys to split the labels.labels (
Tensor) – Tensor of labels to be split.*args (
Tensor) – Tensors to be split according to the labels.
- Return type:
OrderedDict[int|tuple[int],tuple[Sequence[Tensor],Tensor]]- Returns:
A dictionary where each key from the splitting scheme maps to a tuple. The first element of the tuple is a list of tensors corresponding to the key, and the second element is a tensor of indexes.
- cat_dict_of_tensors_with_indexes(input)[source]¶
Concatenate a dict of tensors with indexes.
- Parameters:
input (
OrderedDict[int|tuple[int],tuple[Sequence[Tensor],Tensor]]) – A dictionary where each key maps to a tuple containing a list of tensors and a tensor of indexes.- Return type:
list[Tensor]- Returns:
A list of concatenated tensors.
- compose_funcs(func1, func2)[source]¶
Compose two functions.
- Parameters:
func1 (
Callable[[VarArgAnyCallable,VarArgAnyCallable],Tensor]) – A function that takes another function and additional arguments.func2 (
VarArgAnyCallable) – A function to be passed as an argument to func1.
- Return type:
- Returns:
A new function that represents the composition of func1 and func2.
- apply_dict_of_func_to_func(dict_of_func, func)[source]¶
Apply a dict of functions to a function.
- Parameters:
dict_of_func (
OrderedDict[int|tuple[int],Callable[[VarArgAnyCallable,VarArgAnyCallable],Tensor]]) – A dictionary where each key maps to a function that takes another function and additional arguments.func (
VarArgAnyCallable) – A function to be passed as an argument to each function in the dictionary.
- Return type:
OrderedDict[int|tuple[int],VarArgAnyCallable]- Returns:
A dictionary where each key maps to the result of composing the corresponding
- apply_func_to_dict_of_func(func, dict_of_func)[source]¶
Apply a function to a dict of functions.
- Parameters:
func (
Callable[[VarArgAnyCallable,VarArgAnyCallable],Tensor]) – A function that takes another function and additional arguments.dict_of_func (
OrderedDict[int|tuple[int],VarArgAnyCallable]) – A dictionary where each key maps to a function to be passed as an argument to func.
- Return type:
OrderedDict[int|tuple[int],VarArgAnyCallable]- Returns:
A dictionary where each key maps to the result of composing func with the corresponding function in dict_of_func.
- vectorize_dict_of_func(vectorizing_scheme, dict_of_func)[source]¶
Vectorize a dict of functions.
- Parameters:
vectorizing_scheme (
tuple[int|None,...]) – A tuple specifying the vectorization scheme.dict_of_func (
OrderedDict[int|tuple[int],VarArgAnyCallable]) – A dictionary where each key maps to a function to be vectorized.
- Return type:
OrderedDict[int|tuple[int],VarArgAnyCallable]- Returns:
A dictionary where each key maps to the vectorized version of the corresponding function in dict_of_func.
- apply_dict_of_vmap_to_label_tensors(splitting_scheme, vmdict, theta, labels, *args)[source]¶
Apply a dict of vmaps to LabelTensors.
- Parameters:
splitting_scheme (
Sequence[int|tuple[int]]) – Sequence of keys to split the labels.vmdict (
OrderedDict[int|tuple[int],VarArgAnyCallable]) – A dictionary where each key maps to a vectorized function.theta (
dict[str,Parameter]) – A dictionary of parameters to be passed to the functions.labels (
Tensor) – Tensor of labels to be split.*args (
Tensor) – Tensors to be passed as arguments to the functions.
- Return type:
Tensor- Returns:
The result of applying the appropriate vectorized function to the split tensors.
- class FunctionalOperator(pde, name, **kwargs)[source]¶
Bases:
objectHandle functional operators for PDEs with multiple labels.
- Parameters:
pde (
EllipticPDE|TemporalPDE|KineticPDE|LinearOrder2PDE) – An instance of a PDE class.name (
str) – The name of the operator method in the PDE class.**kwargs – Additional keyword arguments.
- Raises:
AttributeError – If the specified operator method does not exist in the PDE class or is not callable.
- split_label_tensors(labels, *args)[source]¶
Split LabelTensors to a dict of tensors with indexes.
- Parameters:
labels (
Tensor) – Tensor of labels to be split.*args (
Tensor) – Tensors to be split according to the labels.
- Return type:
OrderedDict[int|tuple[int],tuple[Sequence[Tensor],Tensor]]- Returns:
A dictionary where each key from the operator keys maps to a tuple. The first element of the tuple is a list of tensors corresponding to the key, and the second element is a tensor of indexes.
- cat_dict_of_tensors(input)[source]¶
Concatenate a dict of tensors with indexes.
- Parameters:
input (
OrderedDict[int|tuple[int],tuple[Sequence[Tensor],Tensor]]) – A dictionary where each key maps to a tuple containing a list of tensors and a tensor of indexes.- Return type:
list[Tensor]- Returns:
A list of concatenated tensors.
- apply_dict_of_vmap_to_label_tensors(vmdict, theta, labels, *args)[source]¶
Apply a dict of vmaps to LabelTensors.
- Parameters:
vmdict (
OrderedDict[int|tuple[int],VarArgAnyCallable]) – A dictionary where each key maps to a vectorized function.theta (
dict[str,Parameter]) – A dictionary of parameters to be passed to the functions.labels (
Tensor) – Tensor of labels to be split.*args (
Tensor) – Tensors to be passed as arguments to the functions.
- Return type:
Tensor- Returns:
The result of applying the appropriate vectorized function to the split tensors.
- apply_to_func(func)[source]¶
Apply the functional operator to a function.
- Parameters:
func (
VarArgAnyCallable) – A function to be passed as an argument to each function in the operator dictionary.- Return type:
OrderedDict[int|tuple[int],VarArgAnyCallable]- Returns:
A dictionary where each key maps to the result of composing the corresponding function in the operator dictionary with func.
- apply_func_to_dict_of_func(func, dict_of_func)[source]¶
Apply a function to a dict of functions.
- Parameters:
func (
Callable[[VarArgAnyCallable,VarArgAnyCallable],Tensor]) – A function that takes another function and additional arguments.dict_of_func (
OrderedDict[int|tuple[int],VarArgAnyCallable]) – A dictionary where each key maps to a function to be passed as an argument to func.
- Return type:
OrderedDict[int|tuple[int],VarArgAnyCallable]- Returns:
A dictionary where each key maps to the result of composing func with the corresponding function in dict_of_func.
- cat_tuple_of_tensors(input, labels, *args)[source]¶
Concatenate a tuple of tensors with indexes.
- Parameters:
input (
tuple[Tensor,...]) – A tuple of tensors to be concatenated.labels (
Tensor) – Tensor of labels to be split.*args (
Tensor) – Tensors to be split according to the labels.
- Return type:
Tensor- Returns:
A tensor resulting from concatenating the input tensors according to the split indexes derived from the labels.