dctkit.dec namespace

Submodules

dctkit.dec.cochain module

class dctkit.dec.cochain.Cochain(dim: int, is_primal: bool, complex: SimplicialComplex, coeffs: ndarray[tuple[Any, ...], dtype[_ScalarT]] | Array)[source]

Bases: object

Parent cochain class.

Parameters:
  • dim – dimension of the complex where the cochain is defined.

  • is_primal – True if the cochain is primal, False otherwise.

  • complex – the simplicial complex where the cochain is defined.

  • coeffs – array of the coefficients of the cochain.

class dctkit.dec.cochain.CochainD(dim: int, complex: SimplicialComplex, coeffs: ndarray[tuple[Any, ...], dtype[_ScalarT]] | Array)[source]

Bases: Cochain

Class for dual cochains.

class dctkit.dec.cochain.CochainD0(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD0T(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD0V(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD1(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD1T(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD1V(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD2(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD2T(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD2V(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD3(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD3T(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainD3V(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP(dim: int, complex: SimplicialComplex, coeffs: ndarray[tuple[Any, ...], dtype[_ScalarT]] | Array)[source]

Bases: Cochain

Class for primal cochains.

class dctkit.dec.cochain.CochainP0(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP0T(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP0V(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP1(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP1T(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP1V(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP2(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP2T(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP2V(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP3(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP3T(complex, coeffs)

Bases: Cochain

class dctkit.dec.cochain.CochainP3V(complex, coeffs)

Bases: Cochain

dctkit.dec.cochain.abs(c: Cochain) Cochain[source]

Compute the absolute value of a cochain.

Parameters:

c – a cochain.

Returns:

its absolute value.

dctkit.dec.cochain.add(c1: Cochain, c2: Cochain) Cochain[source]

Adds two cochains.

Parameters:
  • c1 – a cohcain.

  • c2 – a cochain.

Returns:

c1 + c2

dctkit.dec.cochain.arccos(c: Cochain) Cochain[source]

Computes the arcsin of a cochain.

Parameters:

c – a cochain.

Returns:

cochain with coefficients equal to arccos(c.coeffs).

dctkit.dec.cochain.arcsin(c: Cochain) Cochain[source]

Computes the arcsin of a cochain.

Parameters:

c – a cochain.

Returns:

cochain with coefficients equal to arcsin(c.coeffs).

dctkit.dec.cochain.coboundary(c: Cochain) Cochain[source]

Implements the coboundary operator.

Parameters:

c – a cochain.

Returns:

the cochain obtained by taking the coboundary of c.

dctkit.dec.cochain.cochain_mul(c1: Cochain, c2: Cochain) Cochain[source]

Multiplies two cochain component-wise

Parameters:
  • c1 – a cochain.

  • c2 – a cochain.

Returns:

cochain with coefficients = c1*c2.

dctkit.dec.cochain.codifferential(c: Cochain) Cochain[source]

Implements the discrete codifferential.

Parameters:

c – a cochain.

Returns:

the discrete codifferential of c.

dctkit.dec.cochain.convolution(c: Cochain, kernel: Cochain, kernel_window: float) Cochain[source]

Compute the convolution between two scalar 0-cochains.

Parameters:
  • c – a scalar 0-cochain.

  • kernel – the scalar 0-cochain kernel.

  • kernel_window – the kernel window.

Returns:

the convolution rho*kernel.

dctkit.dec.cochain.cos(c: Cochain) Cochain[source]

Computes the cos of a cochain.

Parameters:

c – a cochain.

Returns:

cochain with coefficients equal to cos(c.coeffs).

dctkit.dec.cochain.exp(c: Cochain) Cochain[source]

Compute the exp of a cochain.

Parameters:

c – a cochain.

Returns:

cochain with coefficients equal to exp(c.coeffs).

dctkit.dec.cochain.identity(c: Cochain) Cochain[source]

Implements the identity operator.

Parameters:

c – a cochain.

Returns:

the same cochain.

dctkit.dec.cochain.init(self, complex, coeffs)
dctkit.dec.cochain.inner(c1: Cochain, c2: Cochain) Array[source]

Computes the inner product between two cochains.

Parameters:
  • c1 – a cochain.

  • c2 – a cochain.

Returns:

inner product between c1 and c2.

dctkit.dec.cochain.laplacian(c: Cochain) Cochain[source]

Implements the discrete Laplace-de Rham (or Laplace-Beltrami) operator. (https://en.wikipedia.org/wiki/Laplace%E2%80%93Beltrami_operator)

Parameters:

c – a cochain.

Returns:

a cochain.

dctkit.dec.cochain.log(c: Cochain) Cochain[source]

Computes the natural log of a cochain.

Parameters:

c – a cochain.

Returns:

cochain with coefficients equal to log(c.coeffs).

dctkit.dec.cochain.maximum(c_1: Cochain, c_2: Cochain) Cochain[source]

Compute the component-wise maximum between two cochains.

Parameters:
  • c_1 – a cochain.

  • c_2 – a cochain.

Returns:

the component-wise maximum

class dctkit.dec.cochain.rank(*values)[source]

Bases: Enum

SCALAR = ''
TENSOR = 'T'
VECTOR = 'V'
dctkit.dec.cochain.scalar_mul(c: Cochain, k: float) Cochain[source]

Multiplies a cochain by a scalar.

Parameters:
  • c – a cochain.

  • k – a scalar.

Returns:

cochain with coefficients equal to k*(c.coeffs).

dctkit.dec.cochain.sin(c: Cochain) Cochain[source]

Computes the sin of a cochain.

Parameters:

c – a cochain.

Returns:

cochain with coefficients equal to sin(c.coeffs).

dctkit.dec.cochain.sqrt(c: Cochain) Cochain[source]

Compute the sqrt of a cochain.

Parameters:

c – a cochain.

Returns:

cochain with coefficients equal to sqrt(c.coeffs).

dctkit.dec.cochain.square(c: Cochain) Cochain[source]

Computes the square of a cochain.

Parameters:

c – a cochain.

Returns:

cochain with coefficients squared.

dctkit.dec.cochain.star(c: Cochain) Cochain[source]

Implements the diagonal Hodge star operator (see Grinspun et al.).

Parameters:

c – a cochain.

Returns:

the dual cochain obtained applying the Hodge star operator.

dctkit.dec.cochain.sub(c1: Cochain, c2: Cochain) Cochain[source]

Subtracts two cochains.

Parameters:
  • c1 – a cochain.

  • c2 – a cochain.

Returns:

c_1 - c_2

dctkit.dec.cochain.sym(c: Cochain) Cochain[source]

Compute the symmetric part of a tensor-valued cochain.

Parameters:

c – a tensor-valued cochain.

Returns:

its symmetric part.

dctkit.dec.cochain.trace(c: Cochain) Cochain[source]

Compute the trace of a tensor-valued cochain.

Parameters:

c – a tensor-valued cochain.

Returns:

its trace.

dctkit.dec.cochain.transpose(c: Cochain) Cochain[source]

Compute the transpose of a tensor-valued cochain.

Parameters:

c – a tensor-valued cochain.

Returns:

its transpose.

dctkit.dec.flat module

dctkit.dec.flat.flat(c: CochainP0 | CochainD0, weights: Array, edges: CochainP1V | CochainD1V, interp_func: Callable | None = None, interp_func_args: Dict | None = {}) CochainP1 | CochainD1[source]

Applies the flat to a vector/tensor-valued cochain representing a discrete vector/tensor field to obtain a scalar-valued cochain over primal/dual edges.

Parameters:
  • c – input vector/tensor-valued 0-cochain representing a primal/dual discrete vector/tensor field.

  • weights – array of weights that represent the contribution of each component of the input cochain to the primal/dual edges where the output cochain is defined (i.e. where integration is performed). The number of columns must be equal to the number of primal/dual target edges. Weights depend on the interpolation scheme chosen for the input discrete vector/tensor field.

  • edges – vector-valued cochain collecting the primal/dual edges over which the discrete vector/tensor field should be integrated.

  • interp_func – interpolation function (callable) taking in input the cochain c and providing in output a 1-cochain of the same type (primal/dual). If it is None, then an interpolation function is built as W^T@c.coeffs.

  • interp_func_args – additional keyword arguments for interp_func

Returns:

a primal/dual scalar/vector-valued cochain defined over primal/dual edges.

dctkit.dec.flat.flat_DPD(c: CochainD0V | CochainD0T) CochainD1[source]

Implements the flat DPD operator for dual 0-cochains.

Parameters:

v – a dual 0-cochain.

Returns:

the dual 1-cochain resulting from the application of the flat operator.

dctkit.dec.flat.flat_DPP(c: CochainD0V | CochainD0T) CochainP1[source]

Implements the flat DPP operator for dual 0-cochains.

Parameters:

v – a dual 0-cochain.

Returns:

the primal 1-cochain resulting from the application of the flat operator.

dctkit.dec.flat.flat_PDP(c: CochainP0V | CochainP0T) CochainP1[source]

Implements the flat PDP operator for primal 0-cochains.

Parameters:

c – a primal 0-cochain.

Returns:

the primal 1-cochain resulting from the application of the flat operator.

dctkit.dec.flat.flat_dual_upw(c: CochainD0V | CochainD0T) CochainD1[source]

Implements the flat upwind operator for dual 0-cochains.

Parameters:

v – a dual 0-cochain.

Returns:

the dual 1-cochain resulting from the application of the flat operator.

dctkit.dec.wedge module

dctkit.dec.wedge.wedge(c_1: Cochain, c_2: Cochain) Cochain[source]

Computes the wedge product of two cochains.

Parameters:
  • c_1 – the first cochain.

  • c_2 – the second cochain.

Returns:

a new cochain representing the wedge product of c_1 and c_2.

Raises:
  • Exception – If attempting a primal-dual wedge product, which is

  • undefined.

  • AssertionError – If computing a dual wedge product with dimension

  • greater than 1, which is not defined.