Skip to content

Builtins

Generated by sema doc from the compiler’s authoritative native-signature registry.

Ambient constructors and tensor/embedding builtins — no import required.

Exact rational constructor: canonical coprime form, positive denominator.

  • domain: one finite number (exact binary-rational conversion for floats), or int numerator and nonzero int denominator
  • shape: constructor
  • returns: rational
  • example: QQ(1, 3)

Exact rational constructor: canonical coprime form, positive denominator.

  • domain: one finite number (exact binary-rational conversion for floats), or int numerator and nonzero int denominator
  • shape: constructor
  • returns: rational
  • example: Rational(2, 4)

Exact rational constructor: canonical coprime form, positive denominator.

  • domain: one finite number (exact binary-rational conversion for floats), or int numerator and nonzero int denominator
  • shape: constructor
  • returns: rational
  • example: rational(0.5)

Exact rational constructor: canonical coprime form, positive denominator.

  • domain: one finite number (exact binary-rational conversion for floats), or int numerator and nonzero int denominator
  • shape: constructor
  • returns: rational
  • example: to_QQ(0.5)

Construct a canonical finite set from explicit elements.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: FiniteSet(1, 2, 2)

Explicitly convert a list, tuple, or FiniteSet to FiniteSet.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: set([1, 2, 2])

Test extensional subset.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: bool
  • example: subset({1}, {1, 2})

Test strict extensional subset.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: bool
  • example: proper_subset({1}, {1, 2})

Test extensional superset.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: bool
  • example: superset({1, 2}, {1})

Bounded finite-set union.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: union({1}, {2})

Bounded finite-set intersection.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: intersection({1, 2}, {2, 3})

Bounded finite-set difference.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: set_difference({1, 2}, {2})

symmetric_difference(left, right) -> FiniteSet

Section titled “symmetric_difference(left, right) -> FiniteSet”

Bounded symmetric difference.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: symmetric_difference({1, 2}, {2, 3})

cartesian_product(left, right) -> FiniteSet

Section titled “cartesian_product(left, right) -> FiniteSet”

Bounded Cartesian product as a set of tuples.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: cartesian_product({1}, {2})

Power set for at most twelve input elements.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: power_set({1, 2})

Union a bounded family of explicit finite sets.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: indexed_union([{1}, {2}])

Intersect a nonempty bounded family of explicit finite sets.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: FiniteSet
  • example: indexed_intersection([{1, 2}, {2}])

Exact 0/1 finite-set indicator.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: int
  • example: indicator({1, 2}, 2)

Strong-Kleene negation.

  • domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: logical_not(Truth.unknown)

Strong-Kleene conjunction.

  • domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: logical_and(Truth.unknown, false)

Strong-Kleene disjunction.

  • domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: logical_or(Truth.unknown, true)

Three-valued exclusive-or.

  • domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: logical_xor(true, false)

Strong-Kleene implication.

  • domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: implies(Truth.unknown, false)

Strong-Kleene biconditional.

  • domain: bool or explicit Truth; Unknown retains its reason and has no implicit bool conversion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: iff(true, true)

Universal quantification over an explicit FiniteSet.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: forall({1, 2}, lambda x: x > 0)

Existential quantification over an explicit FiniteSet.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: exists({1, 2}, lambda x: x == 2)

Unique-existence quantification over an explicit FiniteSet.

  • domain: explicit immutable finite sets, at most 4096 output elements; no tensor coercion
  • shape: finite set / three-valued logic
  • returns: Truth
  • example: exists_unique({1, 2}, lambda x: x == 2)

Finite approximate complex scalar with checked arithmetic and C99 branch conventions.

  • domain: zero to two finite f64-representable real components, or one complex value
  • shape: constructor
  • returns: complex
  • example: complex(1.5, -2.0)

Algebraic(coefficients, lower, upper) -> algebraic

Section titled “Algebraic(coefficients, lower, upper) -> algebraic”

Certified exact real algebraic number represented by a square-free polynomial and isolating interval.

  • domain: primitive bounded integer polynomial and exact rational isolating interval containing exactly one real root
  • shape: constructor
  • returns: algebraic
  • example: Algebraic([-2, 0, 1], 1, 2)

algebraic(coefficients, lower, upper) -> algebraic

Section titled “algebraic(coefficients, lower, upper) -> algebraic”

Lowercase exact algebraic-real constructor.

  • domain: primitive bounded integer polynomial and exact rational isolating interval containing exactly one real root
  • shape: constructor
  • returns: algebraic
  • example: algebraic([-2, 0, 1], 1, 2)

Certified closed f64 interval with outward-rounded arithmetic and transcendentals.

  • domain: one finite real point or two ordered finite f64-representable endpoints
  • shape: constructor
  • returns: interval
  • example: interval(-0.1, 0.1)

Certified outward-rounded real ball for validated approximate computation.

  • domain: finite f64 midpoint and optional nonnegative finite radius
  • shape: constructor
  • returns: real_ball
  • example: real_ball(1.0, 0.01)

Physical quantity stored in SI base dimensions.

  • domain: finite f64 value and a supported SI-derived unit expression
  • shape: constructor
  • returns: quantity
  • example: Quantity(1.0, "km")

Lowercase physical-quantity constructor.

  • domain: finite f64 value and a supported SI-derived unit expression
  • shape: constructor
  • returns: quantity
  • example: quantity(1.0, "km")

Construct a physical quantity in a named unit.

  • domain: finite f64 value and a supported SI-derived unit expression
  • shape: constructor
  • returns: quantity
  • example: to_quantity(1.0, "km")

Return the quantity’s numeric value expressed in the target unit.

  • domain: physical quantity and a dimension-compatible supported unit expression
  • shape: scalar
  • returns: float
  • example: convert_unit(quantity(1.0, "km"), "m")

Alias for convert_unit.

  • domain: physical quantity and a dimension-compatible supported unit expression
  • shape: scalar
  • returns: float
  • example: to_unit(quantity(1.0, "km"), "m")

Return SI exponents in length, mass, time, current, temperature, amount, luminous-intensity order.

  • domain: physical quantity or supported SI unit spelling
  • shape: bounded discrete / graph
  • returns: list[int]
  • example: dimension(quantity(2.0, "N"))

Decide exact equality of two seven-axis SI dimension vectors.

  • domain: two physical quantities or supported SI unit spellings
  • shape: bounded discrete / graph
  • returns: bool
  • example: dimension_check("J", quantity(1.0, "N") * quantity(1.0, "m"))

Return a deterministic coherent SI spelling accepted by the quantity constructor.

  • domain: physical quantity or supported SI unit spelling
  • shape: bounded discrete / graph
  • returns: str
  • example: simplify_unit(quantity(1.0, "N") * quantity(1.0, "m"))

Alias for exact SI dimension equality; scale and magnitude do not affect equivalence.

  • domain: two physical quantities or supported SI unit spellings
  • shape: bounded discrete / graph
  • returns: bool
  • example: equivalent_unit("J", "N*m")

Return the seven supported SI base-unit dimension vectors.

  • domain: no arguments
  • shape: bounded discrete / graph
  • returns: any
  • example: base_units()

Return the curated coherent SI derived-unit dimension vectors.

  • domain: no arguments
  • shape: bounded discrete / graph
  • returns: any
  • example: derived_units()

Return the finite f64 decimal scale for an SI prefix.

  • domain: one explicit SI decimal prefix from quecto through quetta
  • shape: scalar
  • returns: float
  • example: unit_prefix("k")

quantity_uncertainty(center, uncertainty) -> any

Section titled “quantity_uncertainty(center, uncertainty) -> any”

Return closed lower and upper quantity bounds without inventing a distribution.

  • domain: two dimension-compatible finite quantities; uncertainty magnitude is interpreted as absolute
  • shape: bounded discrete / graph
  • returns: any
  • example: quantity_uncertainty(quantity(10.0, "m"), quantity(0.1, "m"))

Return a pinned finite-f64 SI nominal value and dimensions; this is not exact, proved, or uncertainty-bearing evidence.

  • domain: one curated SI constant name: c, h, G, e, k_B, or N_A (or its descriptive alias)
  • shape: constructor
  • returns: quantity
  • example: physical_constant("speed_of_light")

Finite approximate Hamilton quaternion with checked algebra and rotation operations.

  • domain: zero to four finite f64-representable Hamilton components, or one quaternion
  • shape: constructor
  • returns: quaternion
  • example: quaternion(1.0, 0.0, 0.0, 0.0)

Canonical exact residue class with checked same-modulus arithmetic, inverses, and powers.

  • domain: exact integer value and modulus in 2..=2^63
  • shape: constructor
  • returns: modint
  • example: modint(10, 7)

Canonical exact residue class with checked same-modulus arithmetic, inverses, and powers.

  • domain: exact integer value and modulus in 2..=2^63
  • shape: constructor
  • returns: modint
  • example: Modular(10, 7)

Exact decimal input with an explicit bounded significant-digit arithmetic context.

  • domain: decimal string or exact integer; precision 1..=4933; half_even or half_up
  • shape: constructor
  • returns: decimal
  • keywords: precision, rounding
  • example: decimal("1.25", precision=28, rounding="half_even")

Explicit checked conversion to the bounded machine-integer lane.

  • domain: exact integral value representable by signed i64; fractional and out-of-range inputs fail typed
  • shape: constructor
  • returns: int
  • example: machine_int(42)

Explicit checked conversion to the bounded machine-integer lane.

  • domain: exact integral value representable by signed i64; fractional and out-of-range inputs fail typed
  • shape: constructor
  • returns: int
  • example: to_machine_int(QQ(42, 1))

Construct Sema’s canonical arbitrary-precision integer lane.

  • domain: exact integral number or integer text under the 16,384-bit value ceiling; no truncation
  • shape: constructor
  • returns: int
  • example: ZZ("12345678901234567890")

Alias for the checked ZZ constructor.

  • domain: exact integral number or integer text under the 16,384-bit value ceiling; no truncation
  • shape: constructor
  • returns: int
  • example: BigInt("12345678901234567890")

Explicit lossless conversion to the canonical exact-integer lane.

  • domain: exact integral number or integer text under the 16,384-bit value ceiling; no truncation
  • shape: constructor
  • returns: int
  • example: to_ZZ(QQ(9, 1))

Explicit finite-f64 real constructor.

  • domain: value explicitly convertible to a finite IEEE-754 f64
  • shape: constructor
  • returns: float
  • example: Real(QQ(1, 2))

Explicit finite-f64 conversion; overflow and non-finite results fail typed.

  • domain: value explicitly convertible to a finite IEEE-754 f64
  • shape: constructor
  • returns: float
  • example: to_real(QQ(1, 2))

Uppercase alias for the checked complex constructor.

  • domain: zero to two finite f64-representable real components, or one complex value
  • shape: constructor
  • returns: complex
  • example: Complex(1.0, -2.0)

Explicit conversion to the checked complex domain.

  • domain: one finite numeric/complex value or two finite f64-representable components
  • shape: constructor
  • returns: complex
  • example: to_complex(1.0, -2.0)

Uppercase alias for the outward-rounded interval constructor.

  • domain: one finite real point or two ordered finite f64-representable endpoints
  • shape: constructor
  • returns: interval
  • example: Interval(-0.1, 0.1)

Explicit conversion to a checked closed interval.

  • domain: one finite real point or two ordered finite f64-representable endpoints
  • shape: constructor
  • returns: interval
  • example: to_interval(1.0)

Uppercase alias for the checked Hamilton quaternion constructor.

  • domain: zero to four finite f64-representable Hamilton components, or one quaternion
  • shape: constructor
  • returns: quaternion
  • example: Quaternion(1.0, 0.0, 0.0, 0.0)

to_quaternion(w, x?, y?, z?) -> quaternion

Section titled “to_quaternion(w, x?, y?, z?) -> quaternion”

Explicit conversion to the checked quaternion domain.

  • domain: one quaternion or one to four finite f64-representable Hamilton components
  • shape: constructor
  • returns: quaternion
  • example: to_quaternion(1.0)

Explicit conversion to the canonical modular-integer domain.

  • domain: exact integer value and modulus in 2..=2^63
  • shape: constructor
  • returns: modint
  • example: to_modular(10, 7)

Uppercase alias for the exact decimal constructor.

  • domain: decimal string or exact integer; precision 1..=4933; half_even or half_up
  • shape: constructor
  • returns: decimal
  • keywords: precision, rounding
  • example: Decimal("1.25", precision=28)

Explicit conversion to the bounded exact-decimal domain.

  • domain: decimal string, exact integer, or decimal value with an explicit bounded arithmetic context
  • shape: constructor
  • returns: decimal
  • keywords: precision, rounding
  • example: to_decimal("1.25", precision=28)

Explicit dense-tensor constructor.

  • domain: uniform bounded rectangular nested numeric/bool data or an existing dense Tensor
  • shape: constructor
  • returns: Tensor
  • keywords: dtype
  • example: DenseTensor([[1.0, 2.0]])

Explicit checked conversion to a dense Tensor.

  • domain: uniform bounded rectangular nested numeric/bool data or an existing dense Tensor
  • shape: constructor
  • returns: Tensor
  • keywords: dtype
  • example: to_dense_tensor([1.0, 2.0])

SparseTensor(value_or_rows, cols?, row_indices?, col_indices?, values?) -> SparseMatrix

Section titled “SparseTensor(value_or_rows, cols?, row_indices?, col_indices?, values?) -> SparseMatrix”

Explicit sparse-tensor constructor retaining canonical CSR storage.

  • domain: one existing SparseMatrix, or five validated finite COO constructor arguments
  • shape: constructor
  • returns: SparseMatrix
  • example: SparseTensor(2, 2, [0, 1], [0, 1], [1.0, 2.0])

to_sparse_tensor(value_or_rows, cols?, row_indices?, col_indices?, values?) -> SparseMatrix

Section titled “to_sparse_tensor(value_or_rows, cols?, row_indices?, col_indices?, values?) -> SparseMatrix”

Explicit sparse conversion; no implicit dense-to-sparse threshold is guessed.

  • domain: one existing SparseMatrix, or five validated finite COO constructor arguments
  • shape: constructor
  • returns: SparseMatrix
  • example: to_sparse_tensor(sparse(1, 1, [0], [0], [1.0]))

Return the canonical observable scientific domain name.

  • domain: one runtime value
  • shape: scalar
  • returns: str
  • example: domain_of(QQ(1, 3))

Decide exact mathematical integrality without truncation.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_integer(QQ(4, 2))

Decide whether a bounded scalar has an exact rational value.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_rational(0.5)

Test membership in the exact-decimal runtime domain.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_decimal(decimal("1.25"))

Test membership in the certified algebraic-real runtime domain.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_algebraic(Algebraic([-2, 0, 1], 1, 2))

Decide whether a scalar value lies on the real axis.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_real(complex(1.0, 0.0))

Test membership in the explicit complex runtime domain.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_complex(complex(1.0, 2.0))

Decide whether every represented numeric component is finite.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_finite(tensor([1.0, 2.0]))

Detect NaN in a scalar or dense/sparse tensor payload.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_nan(math.nan)

Detect infinity in a scalar or dense/sparse tensor payload.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_infinite(math.inf)

Test membership in an exact or explicit enclosure domain.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_exact(QQ(1, 3))

Test whether a runtime value is a symbolic equation object.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_symbolic(None)

Test dense or sparse tensor membership.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_tensor(tensor([1.0]))

Test physical-quantity domain membership.

  • domain: one runtime value; values outside the predicate’s scientific domain return false
  • shape: scalar
  • returns: bool
  • example: is_quantity(quantity(1.0, "m"))

Rotate a three-vector by the orientation represented by a nonzero quaternion.

  • domain: nonzero quaternion and a finite length-3 real vector
  • shape: constructor
  • returns: list[float]
  • example: rotate(quaternion(1.0), [1.0, 2.0, 3.0])

Shortest-path normalized spherical interpolation between orientations.

  • domain: two nonzero quaternions and finite t in [0, 1]
  • shape: constructor
  • returns: quaternion
  • example: slerp(quaternion(1.0), quaternion(0.0, 0.0, 0.0, 1.0), 0.5)

Build a typed Tensor from rectangular nested data.

  • domain: uniform nested numeric or bool data with optional matching f64/bool dtype; bounded rank/elements
  • shape: constructor
  • returns: Tensor
  • keywords: dtype
  • example: tensor([true, false], dtype="bool")

Matrix product (or matrix·vector), shape-checked.

  • domain: 2-D shapes (m,k)·(k,n), or matrix·vector; typed ShapeError otherwise
  • shape: contraction
  • returns: Tensor
  • example: matmul(eye(2), ones([2, 2]))

Dot product of two vectors.

  • domain: two equal-length 1-D vectors (bounded reduction work)
  • shape: reduction
  • returns: float
  • example: dot(tensor([1.0, 2.0]), tensor([3.0, 4.0]))

Tensor of zeros with the given shape.

  • domain: nonnegative exact int or list/tuple of them (bounded elements)
  • shape: constructor
  • returns: Tensor
  • example: zeros([2, 3])

Tensor of ones with the given shape.

  • domain: nonnegative exact int or list/tuple of them (bounded elements)
  • shape: constructor
  • returns: Tensor
  • example: ones(3)

n×n identity matrix.

  • domain: one nonnegative exact int dimension (bounded elements)
  • shape: constructor
  • returns: Tensor
  • example: eye(2)

1-D tensor of 0.0..stop-1.

  • domain: exact integer stop (negative yields an empty tensor; bounded elements)
  • shape: constructor
  • returns: Tensor
  • example: arange(4)

Build a typed dense tensor filled with one value.

  • domain: bounded shape and finite numeric, bool, or complex fill value
  • shape: constructor
  • returns: Tensor
  • example: full([2, 2], 3.0)

Reshape contiguous storage without changing element order.

  • domain: Tensor and bounded shape with exactly the same element count
  • shape: constructor
  • returns: Tensor
  • example: reshape(arange(6), [2, 3])

Flatten a Tensor to rank one or flatten one level of a list.

  • domain: Tensor or ordinary list; tensors preserve dtype
  • shape: constructor
  • returns: any
  • example: flatten(reshape(arange(6), [2, 3]))

Remove singleton dimensions.

  • domain: Tensor and optional singleton axis
  • shape: constructor
  • returns: Tensor
  • keywords: axis
  • example: squeeze(zeros([1, 2, 1]))

Insert a singleton dimension.

  • domain: Tensor and insertion axis
  • shape: constructor
  • returns: Tensor
  • example: unsqueeze(arange(3), 0)

Permute tensor axes into new contiguous storage.

  • domain: Tensor and optional complete signed-axis permutation
  • shape: constructor
  • returns: Tensor
  • example: transpose_axes(reshape(arange(6), [2, 3]), [1, 0])

Materialize NumPy-compatible broadcasting.

  • domain: Tensor and compatible higher-rank bounded shape
  • shape: elementwise
  • returns: Tensor
  • example: broadcast_to(tensor([1.0, 2.0]), [2, 2])

Broadcast all tensors to their common bounded shape.

  • domain: one tensor list or variadic broadcast-compatible tensors
  • shape: elementwise
  • returns: any
  • example: broadcast_arrays(tensor([[1.0], [2.0]]), tensor([3.0, 4.0]))

Concatenate tensors along one axis.

  • domain: nonempty same-rank, same-dtype tensor list with matching non-concatenated dimensions
  • shape: constructor
  • returns: Tensor
  • keywords: axis
  • example: concatenate([arange(2), arange(3)])

Alias for concatenate.

  • domain: same contract as concatenate
  • shape: constructor
  • returns: Tensor
  • keywords: axis
  • example: concat([arange(2), arange(3)])

Stack tensors along a new axis.

  • domain: nonempty identical-shape, same-dtype tensor list
  • shape: constructor
  • returns: Tensor
  • keywords: axis
  • example: stack([arange(3), arange(3)])

Build a dense batch by stacking equal-shape tensors.

  • domain: same contract as stack
  • shape: constructor
  • returns: Tensor
  • keywords: axis
  • example: batch([arange(3), arange(3)])

Split a tensor into equal contiguous sections.

  • domain: Tensor, bounded positive section count exactly dividing the selected axis
  • shape: constructor
  • returns: any
  • keywords: axis
  • example: split(arange(6), 3)

slice(tensor, start, stop, step?, axis?) -> Tensor

Section titled “slice(tensor, start, stop, step?, axis?) -> Tensor”

Copy a signed-step slice along one axis.

  • domain: Tensor and bounded Python-style signed slice coordinates
  • shape: constructor
  • returns: Tensor
  • keywords: step, axis
  • example: slice(arange(6), 1, 5, 2)

Read a scalar or trailing subtensor by signed prefix indices.

  • domain: Tensor and exact integer or prefix index tuple/list
  • shape: introspection
  • returns: any
  • example: index(reshape(arange(6), [2, 3]), [1, 2])

Gather positions along one axis.

  • domain: Tensor and bounded signed integer index list
  • shape: constructor
  • returns: Tensor
  • keywords: axis
  • example: gather(arange(4), [3, 1])

scatter(tensor, indices, updates, axis?) -> Tensor

Section titled “scatter(tensor, indices, updates, axis?) -> Tensor”

Return an immutable tensor with indexed updates applied.

  • domain: Tensor, bounded signed indices, and same-dtype updates of the gathered shape
  • shape: constructor
  • returns: Tensor
  • keywords: axis
  • example: scatter(arange(4), [1, 3], tensor([9.0, 8.0]))

einsum(specification, left, right?) -> Tensor

Section titled “einsum(specification, left, right?) -> Tensor”

Bounded Einstein summation with exact shape validation.

  • domain: explicit-output ASCII-label Einstein notation over one or two same-dtype f64 or complex tensors
  • shape: contraction
  • returns: Tensor
  • example: einsum("ij,jk->ik", eye(2), ones([2, 2]))

Contract the final left and initial right axes.

  • domain: matching f64 or complex tensors and bounded trailing/leading contraction-axis count
  • shape: contraction
  • returns: Tensor
  • keywords: axes
  • example: tensordot(eye(2), ones([2, 2]), 1)

Return the tensor unchanged; all native tensors are contiguous.

  • domain: native Tensor (already row-major contiguous by invariant)
  • shape: introspection
  • returns: Tensor
  • example: contiguous(arange(3))

Report the honest native backend device (cpu).

  • domain: native Tensor
  • shape: introspection
  • returns: str
  • example: device(arange(3))

Select the native CPU device without fake accelerator transfers.

  • domain: native Tensor and cpu or auto; unsupported devices fail loudly
  • shape: introspection
  • returns: Tensor
  • example: to_device(arange(3), "cpu")

Convert tensor elements to a supported dtype.

  • domain: native Tensor and f64, bool, or complex dtype with checked conversion
  • shape: elementwise
  • returns: Tensor
  • example: to_dtype(arange(3), "complex")

Dimensions of a tensor as a list of ints.

  • domain: a Tensor/Embedding/list (scalars report [])
  • shape: introspection
  • returns: list[int]
  • example: shape(zeros([2, 3]))

Return the tensor dtype (f64, bool, or complex).

  • domain: Tensor with an explicit runtime dtype
  • shape: introspection
  • returns: str
  • example: dtype(tensor([true, false]))

where(condition, when_true, when_false) -> Tensor

Section titled “where(condition, when_true, when_false) -> Tensor”

Select broadcast branch elements using a boolean tensor condition.

  • domain: broadcastable bool condition and same-dtype f64, bool, or complex branches
  • shape: elementwise (binary broadcast)
  • returns: Tensor
  • example: where(tensor([true, false]), tensor([1.0, 2.0]), 0.0)

sparse(rows, cols, row_indices, col_indices, values) -> SparseMatrix

Section titled “sparse(rows, cols, row_indices, col_indices, values) -> SparseMatrix”

Construct a first-class canonical sparse CSR matrix.

  • domain: validated finite COO triplets canonicalized to immutable CSR under shape and nnz ceilings
  • shape: constructor
  • returns: SparseMatrix
  • example: sparse(2, 2, [0, 1], [0, 1], [1.0, 2.0])

sparse_matmul(matrix, operand) -> SparseMatrix | Vec | Matrix

Section titled “sparse_matmul(matrix, operand) -> SparseMatrix | Vec | Matrix”

Sparse-preserving product; dense operands produce dense tensors.

  • domain: CSR times CSR or a dense real vector/matrix under exact work and fill ceilings
  • shape: contraction
  • returns: SparseMatrix | Vec | Matrix
  • example: sparse_matmul(sparse(1, 1, [0], [0], [2.0]), sparse(1, 1, [0], [0], [3.0]))

Solve through bounded pivoted sparse LU without densification.

  • domain: square finite CSR system and length-matching dense real right-hand side
  • shape: contraction
  • returns: Vec
  • example: sparse_solve(sparse(1, 1, [0], [0], [2.0]), [4.0])

Transpose while preserving canonical CSR storage.

  • domain: canonical CSR matrix under shape and nnz ceilings
  • shape: decomposition
  • returns: SparseMatrix
  • example: sparse_transpose(sparse(1, 2, [0], [1], [2.0]))

sparse_lu(matrix) -> tuple[SparseMatrix, SparseMatrix, list[int]]

Section titled “sparse_lu(matrix) -> tuple[SparseMatrix, SparseMatrix, list[int]]”

Return sparse L/U factors and row permutation.

  • domain: square finite CSR matrix under pivot-search, work, and factor-fill ceilings
  • shape: decomposition
  • returns: tuple[SparseMatrix, SparseMatrix, list[int]]
  • example: sparse_lu(sparse(1, 1, [0], [0], [2.0]))

Sparse normal-equation least squares with typed rank deficiency.

  • domain: finite CSR design matrix and length-matching dense real right-hand side
  • shape: contraction
  • returns: Vec
  • example: sparse_lstsq(sparse(2, 1, [0, 1], [0, 0], [1.0, 1.0]), [1.0, 3.0])

sparse_eigs(matrix, iterations?, tolerance?) -> tuple[float, Vec, float, int, bool]

Section titled “sparse_eigs(matrix, iterations?, tolerance?) -> tuple[float, Vec, float, int, bool]”

Dominant sparse eigenpair with residual and convergence evidence.

  • domain: square finite CSR matrix, optional bounded positive iterations and finite positive tolerance
  • shape: decomposition
  • returns: tuple[float, Vec, float, int, bool]
  • example: sparse_eigs(sparse(2, 2, [0, 1], [0, 1], [4.0, 1.0]), 100, 0.0000000001)

Whether any element is true; bool tensors support axis reduction.

  • domain: ordinary iterable, or bool Tensor with optional signed axis/keepdims
  • shape: reduction
  • returns: bool | Tensor
  • keywords: axis, keepdims
  • example: any(tensor([true, false]))

Whether every element is true; bool tensors support axis reduction.

  • domain: ordinary iterable, or bool Tensor with optional signed axis/keepdims
  • shape: reduction
  • returns: bool | Tensor
  • keywords: axis, keepdims
  • example: all(tensor([true, false]))

mean(values) -> int | rational | float | Tensor

Section titled “mean(values) -> int | rational | float | Tensor”

Mean; exact rational for exact inputs, float once any float enters, or deterministic complex tensor reduction.

  • domain: non-empty iterable, or finite f64/complex tensor with optional integer axis/keepdims
  • shape: reduction
  • returns: int | rational | float | Tensor
  • keywords: axis, keepdims
  • example: mean([1.0, 2.0, 4.0])

sum(values, start?) -> int | rational | float | Tensor

Section titled “sum(values, start?) -> int | rational | float | Tensor”

Sum; exact for exact inputs, float once any float enters, or deterministic complex tensor reduction.

  • domain: iterable plus optional start, or finite f64/complex tensor with optional integer axis/keepdims
  • shape: reduction
  • returns: int | rational | float | Tensor
  • keywords: start, axis, keepdims
  • example: sum([1, 2, 3], start=4)

Minimum value, with signed-axis tensor reduction support.

  • domain: orderable values, or non-empty finite f64 Tensor
  • shape: reduction
  • returns: float | Tensor
  • keywords: axis, keepdims
  • example: min([3, 1, 2])

Maximum value, with signed-axis tensor reduction support.

  • domain: orderable values, or non-empty finite f64 Tensor
  • shape: reduction
  • returns: float | Tensor
  • keywords: axis, keepdims
  • example: max([3, 1, 2])

Deterministic product over all elements or one signed axis.

  • domain: finite f64/complex Tensor; empty products use the dtype’s one identity
  • shape: reduction
  • returns: float | Tensor
  • keywords: axis, keepdims
  • example: prod(tensor([2.0, 3.0, 4.0]))

Index of the first minimum over all elements or one signed axis.

  • domain: non-empty finite f64 Tensor; first index wins ties
  • shape: reduction
  • returns: int | Tensor
  • keywords: axis, keepdims
  • example: argmin(tensor([3.0, 1.0, 2.0]))

Index of the first maximum over all elements or one signed axis.

  • domain: non-empty finite f64 Tensor; first index wins ties
  • shape: reduction
  • returns: int | Tensor
  • keywords: axis, keepdims
  • example: argmax(tensor([3.0, 1.0, 2.0]))

Embed text as a rank-1 tensor via the configured embedding seam.

  • domain: any string (deterministic hash embedder unless a model is configured)
  • shape: constructor
  • returns: Tensor
  • effects: model.embed
  • example: embed("sema native registry")

divmod(a, b) -> tuple[int | rational | float, int | rational | float]

Section titled “divmod(a, b) -> tuple[int | rational | float, int | rational | float]”

Python-compatible floored quotient/remainder pair (a//b, a%b); exact for exact operands.

  • domain: numbers with a nonzero divisor
  • shape: scalar
  • returns: tuple[int | rational | float, int | rational | float]
  • example: divmod(9, 4)