TensorFunctionLibrary
symbolica.community.tensor Class
TensorFunctionLibrary()Numerical implementations of unary elementwise tensor functions.
Use with network execution to evaluate BroadcastFunction calls on numeric components. Complex conjugation is included by default. Symbolic function calls whose arguments are not numeric can remain symbolic.
Examples
from symbolica.community.tensor import TensorFunctionLibrary, BroadcastFunction
functions = TensorFunctionLibrary()
functions.register(BroadcastFunction("square"), lambda x: x * x)Constructor
#Create a numerical function library with built-in conjugation.
Returns
TensorFunctionLibrary
Mutable library for BroadcastFunction implementations.
Examples
from symbolica.community.tensor import TensorFunctionLibrary
functions = TensorFunctionLibrary()Member details
__repr__
Method#__repr__() -> strReturn a summary of the registered elementwise tensor functions.
Examples
from symbolica.community import tensor as sp
functions = sp.TensorFunctionLibrary()
text = repr(functions)register
Method#register(function: BroadcastFunction, callback: Callable[[float | complex], float | complex]) -> None Register a numerical implementation for an elementwise function.
Returns
None
Updates this function library.
Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(2)
A = TensorName("M")(space, space)
from symbolica.community.tensor import Tensor
tensor = Tensor.dense(A, [1.0, 2.0, 3.0, 4.0])
from symbolica.community.tensor import TensorFunctionLibrary, BroadcastFunction
square = BroadcastFunction("numeric_square")
functions = TensorFunctionLibrary()
functions.register(square, lambda value: value * value)
square(tensor).to_tensor(function_library=functions)[0, 1]Parameters
| Name | Type | Default | Description |
|---|---|---|---|
function | BroadcastFunction | — | Function to implement; an existing implementation is replaced. |
callback | Callable[ | — | Receives one float or complex value and returns a float or complex value. Results determine the numerical output type. |
View generated signature source: docs/api/python/spynso3.pyi:7161