Idenso · latest
On this page

BroadcastFunction

symbolica.community.tensor Class

BroadcastFunction(name: str, *, is_symmetric: Optional[bool] = None, is_antisymmetric: Optional[bool] = None, is_cyclesymmetric: Optional[bool] = None, is_linear: Optional[bool] = None, is_flat: Optional[bool] = None, is_scalar: Optional[bool] = None, is_real: Optional[bool] = None, is_integer: Optional[bool] = None, is_positive: Optional[bool] = None, tags: Optional[Sequence[str]] = None, aliases: Optional[Sequence[str]] = None, normalization: Optional[symbolica.core.Transformer | Callable[[symbolica.core.Expression], symbolica.core.Expression]] = None, print: Optional[Any] = None, derivative: Optional[Any] = None, series: Optional[Any] = None, eval: Optional[Any] = None, data: Optional[_ScalarInput | str | dict | list | bytes] = None)

A unary function applied independently to each tensor component.

Calling it on a TensorExpression preserves the tensor interface. Calling it on Tensor or TensorNetwork creates a lazy network. Scalar inputs produce ordinary Symbolica Expressions. Register numerical behavior separately in a TensorFunctionLibrary.

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 BroadcastFunction
conjugated = BroadcastFunction.conj()(tensor)
conjugated.shape

Constructor

#

Register a Symbolica function for elementwise tensor application.

Returns

BroadcastFunction

Callable wrapper with tensor-aware result types.

Examples

from symbolica.community.tensor import BroadcastFunction, TensorExpression
function = BroadcastFunction("elementwise")
applied = function(TensorExpression(2))
applied.is_scalar

Parameters

NameTypeDefaultDescription
namestr—

Registered unary function name. It receives the broadcast tag and cannot also be a tensor head.

is_symmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_antisymmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_cyclesymmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_linearOptional[bool]None

Distribute the function over sums in its arguments.

is_flatOptional[bool]None

Flatten nested calls with the same head.

is_scalarOptional[bool]None

Declare calls scalar for Symbolica's algebra. The broadcast acts on scalar component values.

is_realOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

is_integerOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

is_positiveOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

tagsOptional[Sequence[str]]None

Additional Symbolica tags; Spenso's required tags are included automatically.

aliasesOptional[Sequence[str]]None

Additional names for the same Symbolica symbol.

normalizationOptional[symbolica.core.Transformer | Callable[[symbolica.core.Expression], symbolica.core.Expression]]None

Normalize a newly constructed call. A callable receives an Expression and returns its normalized Expression; tensor interfaces must remain valid.

printOptional[Any]None

Symbolica custom-print callback for the complete function call. Returning None selects standard printing.

derivativeOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

seriesOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

evalOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

dataOptional[_ScalarInput | str | dict | list | bytes]None

Symbolica user data attached to the symbol, such as a dict, list, or bytes.

Member details

conj

Static method#
conj() -> BroadcastFunction

Return the built-in elementwise complex-conjugation function.

Returns

BroadcastFunction

Registered conjugation, with a built-in numerical implementation.

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 BroadcastFunction
BroadcastFunction.conj()(tensor).to_tensor()[0, 1]

__repr__

Method#
__repr__() -> str

Return a readable object description for inspection.

Examples

from symbolica.community import tensor as sp
conjugate = sp.BroadcastFunction.conj()
text = repr(conjugate)

__str__

Method#
__str__() -> str

Return a readable text representation.

Examples

from symbolica.community import tensor as sp
conjugate = sp.BroadcastFunction.conj()
text = str(conjugate)

to_expression

Method#
to_expression() -> Expression

Return this function name as a Symbolica symbol.

Returns

Expression

The bare function head, without arguments or tensor structure.

Examples

from symbolica.community.tensor import BroadcastFunction
name = BroadcastFunction("tagged_BroadcastFunction", tags=["example::example"])
head = name.to_expression()

has_tag

Method#
has_tag(tag: str) -> bool

Check whether the registered function carries a tag.

Returns

bool

Whether the tag is present.

Examples

from symbolica.community.tensor import BroadcastFunction
name = BroadcastFunction("tagged_BroadcastFunction", tags=["example::example"])
name.has_tag("example::example")

Parameters

NameTypeDefaultDescription
tagstr—

Exact tag name. An unqualified name also matches its "python::" form.

get_tags

Method#
get_tags() -> list[str]

List the tags attached to the registered function.

Returns

list of str

Fully qualified tags, including the tags required by Spenso.

Examples

from symbolica.community.tensor import BroadcastFunction
name = BroadcastFunction("tagged_BroadcastFunction", tags=["example::example"])
"example::example" in name.get_tags()

__call__

Method#

Overloads

Overload 1 #
__call__(arg: Tensor | TensorNetwork) -> TensorNetwork

Apply this unary function to a scalar or to every tensor component.

Returns

Expression, TensorExpression, or TensorNetwork

Scalar inputs return Expression; symbolic tensors retain TensorExpression; component-bearing inputs return TensorNetwork.

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 BroadcastFunction
result = BroadcastFunction.conj()(tensor).to_tensor()
result.shape
Parameters
NameTypeDefaultDescription
argTensor | TensorNetwork—

Value to transform independently at each component.

Overload 2 #
__call__(arg: TensorExpression) -> TensorExpression

Apply this unary function to a scalar or to every tensor component.

Returns

Expression, TensorExpression, or TensorNetwork

Scalar inputs return Expression; symbolic tensors retain TensorExpression; component-bearing inputs return TensorNetwork.

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 BroadcastFunction
result = BroadcastFunction.conj()(tensor).to_tensor()
result.shape
Parameters
NameTypeDefaultDescription
argTensorExpression—

Value to transform independently at each component.

Overload 3 #
__call__(arg: _ScalarInput) -> Expression

Apply this unary function to a scalar or to every tensor component.

Returns

Expression, TensorExpression, or TensorNetwork

Scalar inputs return Expression; symbolic tensors retain TensorExpression; component-bearing inputs return TensorNetwork.

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 BroadcastFunction
result = BroadcastFunction.conj()(tensor).to_tensor()
result.shape
Parameters
NameTypeDefaultDescription
arg_ScalarInput—

Value to transform independently at each component.