Module Contents

indexing = ()
threshold = 1e-12
class TensorOperator(function, codomain, indexing=indexing, threshold=threshold)

Class for lazy evaluation of spin/regularity tensor operations.

  • codomain (TensorCodomain object) – keeps track of the difference in rank of TensorOperators.

  • indexing (tuple) – must be a permutation of (-1,+1) or (-1,0,+1)

  • threshold (float (1e-12 default)) – send smaller values to 0.

  • dimension (int) – number of basis indices.


all TensorOperator objects are callable on the input rank of a tensor.


sigma,tau tuples of spin/regularity indices


generate all lenght-rank tuples according to a given indexing.


from self[sigma,tau] compute flattened (dimension**ranks[0],dimension**ranks[1]) np.ndarray.

property indexing
property threshold
property dimension
class Identity(**kwargs)

Spin/regularity space identity transformation of arbitrary rank.

self[sigma,tau] = 1 if sigma == tau else 0
class Metric(**kwargs)

Spin-space representation of arbitrary-rank local Cartesian metric tensor. E.g.:

Id = e(+)e(-) + e(0)e(0) + e(-)e(+) = e(x)e(x) + e(y)e(y) + e(z)e(z)

self[sigma,tau] = 1 if sigma == -tau else 0
class Transpose(permutation=(1, 0), **kwargs)

Transpose operator for arbitrary rank tensor.

T[i,j,…,k] -> T[permutation(i,j,…,k)]

Default transposes 0 <–> 1 indices.


permutation (tuple) – Relative to natural order, using Cauchy’s “one-line notation”.

self[sigma,tau] = self[sigma,permutation(tau)]
property permutation
class Trace(indices, **kwargs)

Class for contracting arbitrary indices down to a scalar in those indices:

sum_(i+j=0) T[..i,..j,..]

This can generalise to (e.g.):

sum_(i+j+k+l=0) T[..i,..j,..k,..l,..]

It might seem like we would prefer to do

sum_(i+j=0,k+l=0) T[..i,..j,..k,..l,..] = sum_(i+j=0) sum_(k+l=0) T[..i,..j,..k,..l,..]

However, we can accomplish the latter by multiple operations over two indices. Conversly, repeted apllication of 2-index sums cannot sum more than two indices simultaneously.

For a few examples:

len(indices) == 0:

Identity() S –> S

len(indices) == 1:
Selects spin=0 component from given axis:

V –> V[0]

len(indices) == 2:
Traditional Trace((0,1)):

T –> T[-,+] + T[0,0] + T[+,-]

Trace((0,)) @ Trace((1,)) produces T[0,0] individually.

Trace((0,1)) - Trace((0,)) @ Trace((1,)) produces T[-,+] + T[+,-] individually.

len(indices) == 3:

R[+,-,0]+R[-,+,0] + R[+,0,-]+R[-,0,+] + R[0,+,-]+R[0,-,+] + R[0,0,0]

We can select different scalars in this sum by application of lower-rank traces.


indices (tuple of -1,0,+1) –

property indices
class TensorProduct(element, action='left', **kwargs)

Action of multiplication by single spin-tensor basis element:

e(kappa) (X) T = sum_(sigma) T(sigma) e(kappa+sigma)


T (X) e(kappa) = sum_(sigma) T(sigma) e(sigma+kappa)

  • element (tuple) – single tensor basis element, kappa

  • action (str ('left' or 'right')) –

property element
property action
xi(mu, ell)

Normalised derivative scale factors. xi(-1,ell)**2 + xi(+1,ell)**2 = 1.

  • mu (int) – regularity; -1,+1,0. xi(0,ell) = 0 by definition.

  • ell (int) – spherical-harmonic degree.

class Intertwiner(L, **kwargs)

Regularity-to-spin map.



L (int) – spherical-harmonic degree

k: int mu, s

angular spherical wavenumbers.

forbidden_spin: tuple spin

filter spin components that don’t exist.

forbidden_regularity: tuple regularity

filter regularity components that don’t exist.


regularity-to-spin coupling coefficients

property L
k(mu, s)
class TensorCodomain(rank_change)

Class for keeping track of TensorOperator codomains.


arrow (int) – relative change in rank between input and output.