# General Linear Group

$$\operatorname{SL}(n)$$ is the manifold of matrices of determinant equal to 1.

$\operatorname{SL}(n) = \{X \in \mathbb{R}^{n\times n}\:\mid\:\det(X) = 1\}$

It is realized via an SVD-like factorization:

\begin{split}\begin{align*} \pi \colon \operatorname{SO}(n) \times \mathbb{R}^n \times \operatorname{SO}(n) &\to \operatorname{SL}(n) \\ (U, \Sigma, V) &\mapsto Uf(\Sigma)V^\intercal \end{align*}\end{split}

where we have identified the vector $$\Sigma$$ with a diagonal matrix in $$\mathbb{R}^{n \times n}$$. The function $$f\colon \mathbb{R} \to (\varepsilon, \infty)$$ is applied element-wise to the diagonal for a small $$\varepsilon > 0$$. By default, a combination of the softplus function

\begin{split}\begin{align*} \operatorname{softplus} \colon \mathbb{R} &\to (\varepsilon, \infty) \\ x &\mapsto \log(1+\exp(x)) + \varepsilon \end{align*}\end{split}

composed with the normalization function

\begin{split}\begin{align*} \operatorname{g} \colon \mathbb{R}^n &\to (\varepsilon, \infty)^n \\ (x_1, \dots, x_n) &\mapsto \left(\frac{x_i}{\sqrt[\leftroot{-2}\uproot{2}n]{\prod_i x_i}}\right)_i \end{align*}\end{split}

to ensure that the product of all the singular values is equal to 1.

class geotorch.SL(size, f='softplus', triv='expm')[source]

Manifold of special linear matrices

Parameters
• size (torch.size) – Size of the tensor to be parametrized

• f (str or callable or pair of callables) –

Optional. Either:

• "softplus"

• A callable that maps real numbers to the interval $$(0, \infty)$$

• A pair of callables such that the first maps the real numbers to $$(0, \infty)$$ and the second is a (right) inverse of the first

Default: "softplus"

• triv (str or callable) – Optional. A map that maps skew-symmetric matrices onto the orthogonal matrices surjectively. This is used to optimize the $$U$$ and $$V$$ in the SVD. It can be one of ["expm", "cayley"] or a custom callable. Default: "expm"

sample(init_=<function xavier_normal_>, eps=5e-06, factorized=False)[source]

Returns a randomly sampled matrix on the manifold by sampling a matrix according to init_ and projecting it onto the manifold.

The output of this method can be used to initialize a parametrized tensor that has been parametrized with this or any other manifold as:

>>> layer = nn.Linear(20, 20)
>>> M = SL(layer.weight.size(), rank=6)
>>> geotorch.register_parametrization(layer, "weight", M)
>>> layer.weight = M.sample()

Parameters
• init_ (callable) – Optional. A function that takes a tensor and fills it in place according to some distribution. See torch.init. Default: torch.nn.init.xavier_normal_

• eps (float) – Optional. Minimum singular value of the sampled matrix. Default: 5e-6

in_manifold(X, eps=0.005)[source]

Checks that a given matrix is in the manifold.

Parameters
• X (torch.Tensor or tuple) – The input matrix or matrices of shape (*, n, k).

• eps (float) – Optional. Threshold at which the singular values are considered to be zero Default: 5e-3