Linear Maps

Linear and affine maps between manifolds.

A LinearMap is itself a Manifold whose points are the parameters of the map. The main concrete implementation is EmbeddedMap, which combines a MatrixRep (from matrix.py) with domain/codomain embeddings to handle the project-multiply-embed pipeline. BlockMap sums several such maps for heterogeneous block structure, and AffineMap adds a bias term.

Class Hierarchy

Inheritance diagram of goal.geometry.manifold.linear

Linear Maps

class LinearMap[source]

Bases: Manifold, ABC, Generic

A linear transformation between manifolds, which is itself a manifold (its points are the map’s parameters).

The key pattern: a LinearMap knows its domain, codomain, and how to apply itself, transpose itself, and compute outer products. Concrete implementations choose how to store and execute the map.

Mathematically, a linear map \(L: V \to W\) satisfies \(L(\alpha x + \beta y) = \alpha L(x) + \beta L(y)\).

abstract property dom_man: Domain

The domain manifold.

abstract property cod_man: Codomain

The codomain manifold.

abstract property trn_man: LinearMap[Codomain, Domain]

Manifold of transposed linear maps.

abstractmethod transpose(f_coords: Array) Array[source]

Return parameters of the transposed map.

abstractmethod outer_product(w_coords: Array, v_coords: Array) Array[source]

Outer product \(w \otimes v\), returned as map parameters.

abstractmethod map_domain_embedding(f: Callable[[LinearEmbedding[Manifold, Domain]], LinearEmbedding[Manifold, NewDomain]]) LinearMap[NewDomain, Codomain][source]

Transform the domain embedding(s) using the given function.

This enables operations like tensoring with a new factor by wrapping the domain embedding in a more complex structure.

abstractmethod map_codomain_embedding(f: Callable[[LinearEmbedding[Manifold, Codomain]], LinearEmbedding[Manifold, NewCodomain]]) LinearMap[Domain, NewCodomain][source]

Transform the codomain embedding(s) using the given function.

This enables operations like tensoring with a new factor by wrapping the codomain embedding in a more complex structure.

transpose_apply(f_coords: Array, w_coords: Array) Array[source]

Apply the transpose: takes map parameters and a codomain point, returns a domain point.

prepend_embedding(emb: LinearEmbedding[Domain, NewDomain]) LinearMap[NewDomain, Codomain][source]

Prepend an embedding to the domain.

append_embedding(emb: LinearEmbedding[Codomain, NewCodomain]) LinearMap[Domain, NewCodomain][source]

Append an embedding to the codomain.

class SquareMap(rep: MatrixRep, dom_man: M)[source]

Bases: AmbientMap, Generic

Square AmbientMap (domain = codomain), exposing inverse, log-determinant, and positive-definiteness checks.

rep: Square

The matrix representation strategy for this linear map.

inverse(f_coords: Array) Array[source]

Parameters of the inverse matrix.

logdet(f_coords: Array) Array[source]

Log determinant.

is_positive_definite(f_coords: Array) Array[source]

Check positive definiteness.

Affine Maps

class AffineMap(map_man: LinearMap[Domain, Codomain], dom_man: Domain)[source]

Bases: Pair[Codomain, LinearMap], Generic

A linear map plus a bias: \(A(x) = L(x) + b\).

Stored as a Pair of the bias \(b\) (on the codomain) and the linear map \(L\). This is the natural parameter space for exponential family likelihoods (bias = observable natural parameters, linear part = interaction).

map_man: LinearMap

The linear transformation for this affine map.

dom_man: Domain

The domain of the affine map.

property fst_man: Codomain

First component manifold.

property snd_man: LinearMap[Domain, Codomain]

Second component manifold.