% !TEX root = Main.tex
\section{Word Embeddings}
\textbf{Distributional Model:}\\
$p_\theta(w|w')$ = Pr[$w$ occurs in context of $w'$]\\
\textbf{Log-likelihood:}\\
$L(\theta; \mathbf{w}) = \sum_{t=1}^T\sum_{\Delta \in I}{\log p_\theta(w^{(t+\Delta)}|w^{(t)})}$\\
\textbf{Latent Vector Model:} $w \rightarrow (\mathbf{x}_w, b_w) \in \mathbb{R}^{D+1} \\p_{\theta}(w|w') = \frac{\exp[\langle \mathbf{x}_w,\mathbf{x}_{w'}\rangle + b_w]}{\sum_{v\in V}{\exp[\langle \mathbf{x}_v,\mathbf{x}_{w'}\rangle + b_v ]}}$ (soft-max).\\
\textbf{Modifications:}\\
$\log p_{\theta}(w|w') = \langle  y_{w} , x_{w'} \rangle + b_w$,  word $y_w$, c'txt $x_{w'}$\\
use GloVe objective\\
negative sampling (logistic classification) over-samples by factor $k$ and defines $p_n$ by reusing active words from the data with random context, apply the exponent $\alpha<1$ to reduce frequent words importance.\\
$
\sum_{(i,j)\in\Delta_+}log(\sigma(\langle x_i, y_j\rangle)) + \sum_{(i,j)\in\Delta_-}log(\sigma(-\langle x_i, y_j\rangle))
$
\subsection*{GloVe (Weighted Square Loss)}
\textbf{Co-occurence Matrix:}\\
$\textbf{N} = (n_{ij}) \in \mathbb{R}^{|V|\times|C|} = \textbf{\# of word} w_i$ in context $w_j$\\
$\textbf{N}$ easily computed (one data pass) and sparse\\
\textbf{Objective:} $H(\theta;\textbf{N})$\\
$= \sum_{n_{ij} > 0} f(n_{ij})(\log n_{ij} - \log \exp[\langle \textbf{x}_i, \textbf{y}_j \rangle + b_i + d_j])^2$\\
with $f(n) = \min\{1, (\frac{n}{n_{max}})^\alpha\}$, $\alpha \in (0;1]$, $f(n_{ij}$ small for small counts as noisy and limited for big counts,
\textbf{unnormalized} distr. $\rightarrow$ 2-sided loss function\\
1. sample $(i,j) u.a.r, s.t. n_{ij}>0$\\
2. $\mathbf{x}_i^{new} \leftarrow \mathbf{x}_i + 2\eta f(n_{ij})(\log n_{ij} - \langle \mathbf{x}_i, \mathbf{y}_j \rangle)\mathbf{y}_j$\\
3. $\mathbf{y}_j^{new} \leftarrow \mathbf{y}_j + 2\eta f(n_{ij})(\log n_{ij} - \langle \mathbf{x}_i, \mathbf{y}_j \rangle)\mathbf{x}_i$

\subsection*{Discussion}
Word embeddings can model analogies and relatedness, but antonyms are usually not.


\documentclass[en,12pt]{elegantpaper}

\begin{document}
    \section*{3}
    \noindent For Beta($\alpha. \alpha$),
    \[
        f(x|\alpha)=\mathbf{1}_{0<x<1}\exp\left((\alpha-1)\log(x(1-x))-\log\left(\frac{\Gamma^2(\alpha)}{\Gamma(2\alpha)}\right)\right).
    \]
    Let $\eta=\alpha-1$, then $A(\eta)=\log\frac{\Gamma^2(\eta+1)}{\Gamma(2\eta+2)}$. And we know that $T(X)=\log(X(1-X))$ is a sufficient statistics. So,
    \[
        \begin{aligned}
            \mathbb{E}(T(X))=A'(\eta){}&=\log(\Gamma^2(\eta+1))-\log(\Gamma(2\eta+2))\\&=\frac{2\Gamma(\eta+1)\Gamma'(\eta+1)}{\Gamma^2(\eta+1)}-\frac{2\Gamma'(2\eta+2)}{\Gamma(2\eta+2)}\\
            &=\frac{2\Gamma(\alpha)\Gamma'(\alpha)}{\Gamma^2(\alpha)}-\frac{2\Gamma'(2\alpha)}{\Gamma(2\alpha)}
        \end{aligned}
    \]
    where $\Gamma'(n)=(n-1)!\left(\sum_{i=1}^{n-1}\frac{1}{i}-\gamma\right)$, $\gamma$ is Euler's constant.
\end{document}


% JuliaCon proceedings template
\documentclass{juliacon}
\setcounter{page}{1}

%-------- user macros -----------------------------------------------------------
\usepackage{mathtools} %add-on and patches to amsmath
\def\E{\mathbb{E}}
%================================================================================

\begin{document}

\input{header}

\maketitle

\begin{abstract}
Solid Modeling algorithms and applications usually demand very linked and pretty complex data structures, often denoted as ``non-manifold representations'' to remark the breadth of their domain. Conversely, we are implementing in Julia~\cite{bezanson2017julia} topological methods making only use of sparse binary or integer arrays, and their standard algebraic operations, like product, transposition and filtering, and standard topological operators of boundary and coboundary between linear spaces of chains generated by the cells of a space partition.
We show computational methods to generate the 2D/3D space partition induced by a collection of 1D/2D/3D geometric objects. Methods and language are those of basic geometric and algebraic topology. Only sparse arrays are used to compute spaces and maps (the chain complex) from dimension zero to three.
In particular, we show how to build a space arrangement with general non-convex and non-contractible piecewise-linear cells, and how to compute Boolean operations between solid models generated by this approach, reducing them to standard tables of Boolean values.
\end{abstract}

%================================================================================
\section{Introduction}
%================================================================================

In this paper we discuss the current status of a novel approach to geometric computing, and its  implementation in Julia. Rather than using standard methods of geometric computing and solid modeling, normally built on top of complicated data structures, our work is mostly developed making advantage of    sparse arrays and their algebraic operations. In particular, this approach is established over basic concepts of algebraic topology, like cellular complexes, chain and cochain spaces and operators, and chain complexes.  Piecewise-linear algebraic topology allows to treat rather general complexes, with cells homeomorphic to polyhedra, \emph{i.e.},~to triangulable spaces, and hence possibly non convex and multiply connected. We use simplicial complexes, \emph{i.e.}, triangulations, just for graphics, where to stream triangles to the GPU is almost mandatory.

At the knowledge of the author, there are no previous approaches to geometric and solid modeling that build over a similar framework, \emph{e.g}, to compute the \emph{chain complex} codifying the arrangement of $d$-space generated by a collection of ($d$-1)-geometric objects. A wide comparison with previous work in this field may be found in~\cite{TSAS:17,Dicarlo:2014:TNL:2543138.2543294}.
After a short synthesis of basic algebraic topological
concepts, this paper discusses the arrangement of space induced by solid objects, as the basis for resolution of solid-valued expressions. A survey of functions from our packages \texttt{LinearAlgebraicRepresentation}, \texttt{Triangle}, and \texttt{ViewerGL} follows. Simple examples generating pictures conclude the paper.

%================================================================================
\section{Linear Algebraic Representation}
%================================================================================

We summarize  in the following the concepts and definitions on which our \texttt{Lar} (Linear Algebraic Representation)~\cite{Dicarlo:2014:TNL:2543138.2543294} is based on.

\subsection{Cell, Complex, Chain}
%--------------------------------------------------------------------------------
A $p$-cell $\sigma$ ($0\leq p\leq d$) is a piecewise-linear, connected, but possibly non-contractible $p$-manifold. An $r$-face $\tau$ of a $p$-cell $\sigma$ ($0\leq r\leq p$) is a $r$-cell contained in the frontier of $\sigma$.
A $d$-complex $\Lambda$ is a partition of a topological $d$-space $X$ in a discrete set of $p$-cells ($0\leq p\leq d$) such that: (a) $\sigma\in \Lambda$ implies $\tau\in \Lambda$ for all faces $\tau$ of $\sigma$; (b) the closure intersection of every pair of cells of $\Lambda$ is either in $\Lambda$ or the empty set. A $p$-chain can be defined as a subset of $p$-cells. To the $p$-chains can be given the structure of a (graded) linear space $C_p$ by defining (a) sums of chains with the same dimension, and (b) products times scalars in a field, with the usual properties. A basis $U_p$ for $C_p$ is the set of elementary chains $u_p$, given by single cells in $\Lambda_p$. Every chain $c\in C_p$ may be uniquely generated by a linear combination of the basis $U_p$. Once fixed the basis $U_p$, the coordinate representation of each $\sigma\in C_p$ is unique. This one is an ordered sequence of coefficients, either from $\{0,1\}$ (said unsigned rep.) or from $\{-1,0,+1\}$ (called signed representation).

\subsection{Boundary and coboundary operators}
%--------------------------------------------------------------------------------
Bondary operators are linear maps $\partial_p : C_p \to C_{p-1}$, ($1\leq p\leq d$). Coboundary operators are linear maps $\delta_p : C_p \to C_{p+1}$, ($0\leq p\leq d-1$). Once fixed the bases $U_{p-1}, U_{p}, U_{p+1}$, \emph{i.e.}, once fixed an ordering among the cells in each $\Lambda_p$, their matrix representations $[\partial_{p}]$ and $[\delta_{p}]$ are uniquely determined.
It is worthwhile to remark the meaning of such matrices: once fixed the bases, the matrix $[M]$ of a linear operator $M: A\to B$ contains by columns the coordinate representation (\emph{i.e.}, the coefficients of the linear combination) of the $A$ basis expressed as linear combination of $B$ basis elements. This property is the conceptual key of our methods.

A \emph{$p$-cycle} is a chain \emph{without} boundary. It is a chain that the boundary operator $\partial_p$ sends to the kernel (zero-set) of $C_p$. In particular, the $j$-th column of $[\partial_p]$ contains a basis element $u_j\in U_p$ represented as a ($p-1$)-cycle, \emph{i.e.}, contains the coefficients of it as linear combination of elements of $U_{p-1}$. Such linear combinations are $(p-1)$-cycles, since $\partial_{p-1}\circ\partial_p = 0$.  In other words, the matrix $[\partial_2]$ represents the 2-cells in $\Lambda_2$ as 1-cycles (closed polygons) in $C_1$.  Analogously, $[\partial_3]$ contains by columns the 3-cells of $\Lambda_3$ as cycles (shells) made by 2-cells in $\Lambda_2$ (\emph{e.g.}, see Figure~\ref{fig:threecubes}d).

We  have already seen the topological equations $\partial_{p-1}\circ\partial_p = 0$ ($d\leq p\leq 2$) that guarantee the boundary of a boudary being empty. Think about the 2-disk $d \in C_2$ in the plane, with support $|d|\subset\E^2$. The circumference $c\in C_1$, with $|c| = |\partial_2\, d| \subset E^2$ is  a closed curve. In fact we have $\partial (\partial\, c) = 0$. In our case, where cells live in Euclidean spaces, chain spaces $C_p$ can be identified with their dual spaces of $p$-cochains $C^p$, that are spaces of maps $\mu^p: C_p\to \mathbb{F}$ from $p$-chains to the field $\mathbb{F}$ of coefficients. In this case we have $C^p = C_p^\top$, and hence $[C^p] = [C_p]^t$. The matrix-vector multiplication $[\partial_p][c]$ provides the (coordinate representation of) the ($p$-1)-cycle on the frontier of $c$, whereas $[\delta^p][c]$ gives the (coordinate repre. of) the ($p$+1)-chain made by all ($p$+1)-cells incident on $c$.

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=0.4\linewidth]{figs/image1.png}%
   \includegraphics[width=0.6\linewidth]{figs/image2.png}%
   \caption{The 3-cells of the arrangement of $\E^3$ generated by a collection of five random cubes.
   The 3-cells are here not in scale, and suitably rotated to better show their complex structure.
   Their assembly provides the union of the five cubes.
   Each \emph{3-cell is given} by \emph{a column} of the \emph{sparse matrix} of \emph{chain map} $\partial_3: C_3\to C_2$,  with values in $\{-1,0,1\}$.}
   \label{fig:example}
\end{figure}

\subsection{Incidence/adjacency operators}
%--------------------------------------------------------------------------------
Specialized data structures are commonly used to efficiently answer the queries about the incidence and adjacecy relations between boundary elements (vertices, edges and faces), in order to implement the various geometric and topological algorithms of solid modeling. Given the three sets \texttt{V}, \texttt{E}, and \texttt{F} (vertices, edges and faces), ${3\times 3}$ binary relations \texttt{VV}, \texttt{VE}, \texttt{VF}, \texttt{EV}, \texttt{EE}, \texttt{EF}, \texttt{FV}, \texttt{FE}, \texttt{FF} are used. Several different combinations of such relations have been defined as specialized data structures, with the aim of minimizing the time and space complexity of algorithms on solid models.

It is easy to see that each relation can be computed by a proper combination of one or two (co)boundary matrices, possibly transposed. Their ordered list follow: $\texttt{VV}\equiv[\partial_1][\delta_0]$, $\texttt{VE}\equiv[\partial_1]$, $\texttt{VF}\equiv[M_2]^t$, $\texttt{EV}\equiv[\partial_1]^t$, $\texttt{EE}\equiv[\delta_0][\partial_1]$, $\texttt{EF}\equiv[\partial_2]$, $\texttt{FV}\equiv[M_2]$, $\texttt{FE}\equiv[\delta_1]$, $\texttt{FF}\equiv[\delta_1][\partial_2]$, where $M_p$ is the sparse binary \emph{characteristic matrix} of $p$-cells, that holds by rows the images of characteristic functions of $p$-cells as subsets of $0$-cells (vertices).

A typical topological query may be asked as: ``what edges (elementary 1-chains) are adjacent to edge $e$?''
The \texttt{Lar} answer is computed as the product $[\delta_0][\partial_1][e]$, where $[e]$ is the coordinate representation of $e\in C_1$ (a sparse column vector with just one non-zero element) and, of course, the matrix $[\delta_0][\partial_1] =: [\texttt{EE}]$ was computed in advance, and once for all.

The cardinality of such incidence/adjacency algebraic tools between p-cells and q-cells $(0\leq p,q \leq 2)$ is equivalent to that of relations itself~\cite{Woo:85}, in force of their sparsity.  For example, $\#\texttt{EV} = O(Space([\delta_1]) = 2\#\texttt{E}$), where \texttt{V} are the vertices of a solid B-rep and \texttt{EV} are binary incidences of edges with vertices. Every set of local queries about the $3\times 3$ incidences/adjacencies between cells can be answered by multiplication, via software kernels for \emph{sparse matrix} product and transposition, just by collecting the coordinate vectors of unit chains, ``subject''  of elementary queries, as \emph{columns} of a sparse $Q$ matrix, and by left-multiplying $Q$ times one/two operator matrices $[\partial_1]$ and/or $[\partial_2]$, suitably ordered and/or transposed~\cite{Dicarlo:2014:TNL:2543138.2543294}, to get the algebraic equivalent of multiple database queries at once.

%================================================================================
\section{Arrangement Algorithms}
%================================================================================

A \emph{chain complex} is a short exact sequence of graded linear spaces \(C_p\) of (co)chains, with linear
boundary/coboundary maps \(\partial_p\) and
\(\delta_p=\partial_{p+1}^\top\):
\[
C_\bullet = (C_p, \partial_p) :=
C_3 \
\substack{
\delta_2 \\
\longleftarrow \\[-1mm]
\longrightarrow \\
\partial_3
}
\ C_2 \
\substack{
\delta_1 \\
\longleftarrow \\[-1mm]
\longrightarrow \\
\partial_2
}
\ C_1 \
\substack{
\delta_0 \\
\longleftarrow \\[-1mm]
\longrightarrow \\
\partial_1
}
\ C_0 .
\]

The subject of Reference~\cite{TSAS:17} is the computation of the chain complex $C_\bullet = (C_p,\partial_p)$, starting from some representation\footnote{Our prototype implementation in\\ \href{https://github.com/cvdlab/LinearAlgebraicRepresentation.jl}{\scriptsize \texttt{https://github.com/cvdlab/LinearAlgebraicRepresentation.jl}}, makes use of the \texttt{Lar} representation~\cite{Dicarlo:2014:TNL:2543138.2543294}, on which this approach strongly relies.} of an input set $\mathcal{S}$ of ($d$-1)-complexes. In particular, we compute the matrices of the linear maps $\partial_p$ (and their duals $\delta_{p-1}$)  between chain spaces $C_p$. All definitions and more examples are given in Reference~\cite{TSAS:17}. We describe here the main steps of space decomposition in reverse order, starting from the last operation, because of possible iteration on dimensions, starting from 3D.

\subsection{Topological gift wrapping}
%--------------------------------------------------------------------------------
The main goal is to compute, starting from ($d$-1)-dimensional geometric object, the $d$-cells of the space partition (arrangement) generated by them. Examples of input include, but are not limited to: line segments, quads, triangles, polygons, meshes, pixels, voxels, volume images, B-reps, \emph{etc.}
In mathematical terms, a geometric object is a topological space embedded in some $\E^d$ .

The topological method introduced in~\cite{TSAS:17} is reminiscent of the ``gift-wrapping'' algorithm~\cite{Cormen:2009:IAT:1614191,Jarvis:1973:ICH} for computing convex hulls of 2D and 3D discrete sets of points, but it works with higer-dimensional cells instead with points, and is mostly based on applications of boundary and coboundary operators. Our \texttt{TGW} (Topological Gift Wrapping) algorithm~\cite{TSAS:17} takes a sparse matrix $[\partial_{d-1}]$ as input and produces in output the \emph{unknown} sparse matrix  $[\partial_{d}^+]$, augmented with the outer cell. A geometric embedding function $\mu: X_0\to\E^d$ is used to compute the angular ordering, around some ($d$-2)-cells, of ($d$-1)-basis elements in the boundary's coboundary, while wrapping up a ($d$-1)-cycle, as illustrated in Figure~\ref{fig:3D}. The built cycles are set up as columns of $[\partial_d]$, in the construction of a $C_d$ basis.

\begin{figure*}[htbp] %  figure placement: here, top, bottom, or page
\hfill\includegraphics[height=0.15\textwidth,width=0.1428\textwidth]{figs/3D1a.png}%
\includegraphics[height=0.15\textwidth,width=0.1428\textwidth]{figs/3D2.png}%
\includegraphics[height=0.15\textwidth,width=0.1428\textwidth]{figs/3D3b.png}%
\includegraphics[height=0.15\textwidth,width=0.1428\textwidth]{figs/3D4a.png}%
\includegraphics[height=0.15\textwidth,width=0.1428\textwidth]{figs/3D5a.png}%
\includegraphics[height=0.15\textwidth,width=0.1428\textwidth]{figs/3D6b.png}%
\includegraphics[height=0.15\textwidth,width=0.1428\textwidth]{figs/3D7a.png}

{\footnotesize\hspace{.06\textwidth}(a)\hfill(b)\hfill(c)\hfill(d)\hfill(e)\hfill(f)\hfill(g)\hspace{.06\textwidth}}

\caption{Extraction of a minimal 2-cycle from $\mathcal{A}(X_2)$: (a) initial (0-th) value for $c\in C_2$; (b) cyclic subgroups on  $\delta\partial c$; (c)~1-st value of $c$; (d) cyclic subgroups on $\delta\partial c$; (e) 2-nd value of $c$; (f) cyclic subgroups on $\delta\partial c$; (g) 3-rd value of $c$, such that $\partial c=0$, hence stop.}
   \label{fig:3D}
\end{figure*}

\subsection{Merge of 2-skeletons}
%--------------------------------------------------------------------------------
The input to the computational pipeline is a collection $\mathcal{S}$ of geometric objects that do not necessarily constitute a cellular complex, since they can intersect out of cell boundaries. The first step is hence the computation of mutual interctions of their 2-skeletons, \emph{i.e.}, of their sets of 2-cells (for a 3D problem), or their 1-skeletons (for a 2D problem). This phase is executed by intersecting independently each 2-cell $\sigma\in\mathcal{S}_2$ with all 2-cells which might intersect it. Their subset is denoted $\mathcal{I}(\sigma)$ and is computed using efficient spatial indices on the containment boxes of 2-cells. In particular, each $\mathcal{I}(\sigma)$ is given by the intersection of outputs of $d$ independent queries over one-dimensional interval-trees built upon the input.

It may be interesting to remark that the \texttt{merge} algorithm is embarrassingly parallel, and is implemented in Julia making use of two \texttt{Channel}s to ditribute the jobs to workers and to return the output to the master node. This more efficient strategy is quite unusual in Solid Modeling, where even recent variadic approaches~\cite{Zhou:2016:MAS:2897824.2925901} iteratively intersect a new operand against the cell complex generated by the previous operations.

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=0.25\linewidth]{figs/1.png}%
   \includegraphics[width=0.25\linewidth]{figs/2.png}%
   \includegraphics[width=0.25\linewidth]{figs/3.png}%
   \includegraphics[width=0.25\linewidth]{figs/4.png}

   \includegraphics[width=0.25\linewidth]{figs/5.png}%
   \includegraphics[width=0.25\linewidth]{figs/6.png}%
   \includegraphics[width=0.25\linewidth]{figs/7.png}%
   \includegraphics[width=0.25\linewidth]{figs/8.png}%

   \caption{Cartoon display of the computational pipeline: (a) two solids in $\mathcal{S}$; (b) the exploded input collection $\mathcal{S}_2$ in $\E^3$; (c) 2-cell $\sigma$ (red) and the set $\Sigma(\sigma)$ (blue) of possible intersection; (d)  $\sigma\cup\Sigma$ affinely mapped on $z=0$;
   (e)~reduction to a set of 1D segments in $\E^2$ via intersection with $z=0$; (f) pairwise intersections; (g) exploded $U_2$ basis of $C_2$ generated as columns of $\partial_2: C_2 \to C_1$; (h) exploded $U_3$ basis of $C_3$ generated as columns of operator's $\partial_3: C_3 \to C_2$ sparse matrix, via the \texttt{TGW} algorithm in 3D.    }
   \label{fig:process}
\end{figure}

The independent processing of 2-cells is made possible by considering and enforcing the congruence (i.e.~the boundary compatibility) between adjacent fragmented cells. Hence, each input 2-cell $\sigma$ is fragmented in 2D independently from each other.  For this purpose,  a suitable affine transformation maps each set $\{\sigma\}\cup\mathcal{I}(\sigma)$ and puts $\sigma$ into the $z=0$ subspace.

\subsection{Reduction to line intersection in 2D}
%--------------------------------------------------------------------------------
At this point the single 3D arrangement problem is reduced to a collection of several independent 2D arrangement problems, one-to-one with the 2-cells in the 3D input. Every 2-cell in $\mathcal{I}(\sigma)$ is independently intersected (in parallel) with $z=0$, so providing a number $n$ of line segment sets $\mathcal{S}_1$ for independent computation of the 2D arrangement generated by it. The computational pipeline is depicted as cartoon in Figure~\ref{fig:process}. In particular: each set of line segments is mutually intersected (using again two 1D interval-trees of containment boxes of segments for acceleration); the dangling edges and subgraphs are removed from the generated linear graph; and the \texttt{TGW} is used in 2D to build the matrix $[\partial_2]$ of the arrangement, and the corresponding basis of elementary 2-chains (2-cells) of the  $\sigma$ cell decomposition.

\subsection{Congruence of 2D arrangements}
%--------------------------------------------------------------------------------
Each 2-complex $X_\sigma$ providing an independent arrangement of 2-space, is transformed back in 3D using the inverse affine transformation of $\sigma$. Here, congruent cells (e.g., edges member of the boundary of two or more fragmented faces) must be identified as belonging to the same equivalence class, and substituted by a single instance, so implementing a set quotient operation on fragmented cells. Numerical identification of vertices via dictionaries having arrays of floats as keys (permitted by Julia) are used for this purpose. Once identified congruent vertices, the identification of congruent edges and faces is done using their canonical \texttt{Lar} representation, \emph{i.e.,} the ordered arrays of integer indices of vertices.

%================================================================================
\section{Variadic Boolean Operations}
%================================================================================

When the unknown sparse boundary matrix $[\partial_3]$ has been generated by \texttt{TGW} in 3D, the computation of any Boolean operation or solid-valued expression, including solid arguments and Boolean operators, is actually straightforward\footnote{Even if not yet implemented.}. Let us note that the arrangement itself corresponds to the output of a union operation.
To compute any general solid-valued expression, it suffices to suitably store the dependencies, of each possibly fragmented 2-cell of resulting 3-cells, from the input 2-cells that generated it, i.e. from its ``father(s)". This storing allows to reconstruct the containment relations of arrangement's 3-cells with their parents, and hence to write truth tables having them on columns, and the original solids (or their boundaries) on the rows.
It is worthwhile to note that most of the required information is already coded by the non-zero coefficients of $[\partial_3]$, and in particular by their indices and signs.

\subsection{Columns and rows of 3-boundary matrix}
%--------------------------------------------------------------------------------
We already know that columns of $[\partial_3]$ represent the single 3-cells of the arrangement, corresponding to cycles (closed chains) of 2-cells.
First, let us consider a solid model $B$ as a 3-chain in $C_3$, which is possibly made by more then one 2-cycles, corresponding to one or more columns in $[\partial_3]$.
This set of columns $[\partial_3]_B$, possibly a singleton, codifies the non-empty set of shells of $B$, where each one may be either inner (boundary of empty holes) or outer (boundary of connected components).
The number of $[\partial_3]$ rows is the number of elements of the (combinatorial) set union of fragments of original 2-cells in the input of arrangement algorithm.
 The rows, one-to-one with fragmented 2-cells, can be subdivided in two classes, corresponding to the type of input they belong to, which can be either a B-rep or a cellular model~\cite{HofShapiro:2017}:

\begin{enumerate}
\item
if some shell of the ``solid'' chain $B\in C_3$ is represented by a 2-cycle $b\in\partial B\subseteq U_2$, then each elementary 2-chain --- \emph{i.e.}, basis element (2-cell) --- $\sigma\in b$  belongs to \emph{only one} elementary 3-chain $u_3$ of the $B$'s  linear combination  generated by our algorithmic pipeline.\footnote{Some conceptual and notational ambiguity may arise, since a chain or cycle may be seen either as element $(\in)$ of a chain space (linear combination of the basis) or as a subset $(\subset)$ of the basis.}

\item
if a row corresponds to a fragment of 2-cell originally in the interior of $B$, then it will belong to \emph{exactly two} cells $u_3\in C_3$ that are solid fragments of $B$.
\end{enumerate}

\subsection{Mapping from output $d$-cells to input ($d$-$1$)-cells}
%--------------------------------------------------------------------------------
According to the properties listed above, each column of $[\partial_3]$, \emph{i.e.}, each solid 3-cell in the output, must be mapped to the input surfaces that generated it, going from fragments on the related rows to their ancestor 2-cells. This parental relationship is carefully recorded and maintained during the pipeline computation.

\subsection{Boolean ops on truth tables}
%--------------------------------------------------------------------------------
Two binary parental relationships between input and output 2-cells, and between output 2-cells and output 3-cells are used to compute the solid-valued results of Boolean expressions between solid models. We call $Q$ matrix the first, whereas the second is simply the unsigned sparse matrix $[\partial_3]^o$. A third sparse binary matrix $P=[\delta_2]^i$ stores the membership of original 2-cells to solid models being operated.
It is interesting to note that $P$ is a diagonal block matrix, where the blocks are the coboundary matrices $[\delta_2]_k$ ($1\leq k\leq n$) of the $n$ solid arguments of the expression to be evaluated.
The analysis of results of compatible matrix product
$
[\delta_2]^i\,Q\,[\partial_3]^o
$
 finally produces the membership of the output 3-cells to the input arguments, and allows for on-off computation of solid-valued expression.

%================================================================================
\section{Julia packages}
%================================================================================

The methods and algorithms described above were implemented in the Julia packages \texttt{LinearAlgebraicRepresentation} and \texttt{Triangle}. In the following (and in our Julia software) it will be often called \texttt{\texttt{Lar}} for the sake of brevity. \texttt{ViewerGL} is a visual package whose development started recently.  It provides OpenGL interactive visualization for \texttt{\texttt{Lar}} in native Julia code, on top of \texttt{GLFW},
the multi-platform library for OpenGL, OpenGL ES and Vulkan, that  provides a simple API for creating windows and graphics context. The other dependency, \texttt{ModernGL}, provides OpenGL 3+ bindings for Julia. The main functionalities in our packages follow.

\subsection{\texttt{LinearAlgebraicRepresentation.jl}}
%--------------------------------------------------------------------------------
\texttt{\texttt{Lar}}, as its ancestor geometric
language \texttt{PLaSM} and its father library \texttt{pyplasm}, aims to
be multidimensional. Hence many functions generate geometric models of
varying dimensions. Important examples are \texttt{cuboidGrid} and
\texttt{simplexGrid}, whose unique parameter is the \texttt{shape} of the
generated mesh, i.e.~the number of \(1\)-dimensional cells in each
dimension, with \texttt{d = length(shape)}. The vertices of the mesh
stay on the integer grid of suitable dimension and size.

\paragraph*{\texttt{Lar} model}
A \texttt{Lar} model is a pair \emph{geometry}, \emph{topology}. The
\emph{geometry} is specified by the position vectors of \emph{vertices}
in a Euclidean point space $\E^d$
with $d$ coordinates. The \emph{topology} is specified by one or
more bases of singleton $k$-chains
(\emph{i.e.}, $k$-cells) for
$0 \leq\ k\leq d$. The vertex
sharing between cells implicitly provides the attachment maps between
cells of various dimensions. Vertex positions are represented, by
columns, by a 2-array of $d$ real coordinates.
With abuse of language, we consider a finite cellular complex $X$
as generated by a discrete partition of an Euclidean space. In computing
a cellular complex as the space arrangement of a collection of geometric
objects $\mathcal{S}$, \emph{i.e.}, when
$X\ := \mathcal{A}(\mathcal{S})$,
we actually compute the whole \emph{chain complex}
$C_\bullet$ generated by $X$.

\paragraph*{Multidimensional grids}
\texttt{src/largrid} and \texttt{src/simplexn} allow for multidimensional \emph{grids} of
\texttt{cuboidal} and \texttt{simplicial} cell complexes, and  \emph{Cartesian product} of cellular complexes. Both kind of
operators, depending on the dimension of their input, may generate
either \emph{full-dimensional} (i.e.~solid) output complexes, or
\emph{lower-dimensional} complexes of dimension $d$ embedded in
Euclidean space of dimension $n$, with
$d\leq n$. E.g., just think to a mesh of 3D cubes in three-dimensional space for
the first case, and to the (non-manifold) framework of boundary polygons
of such cubic meshes for the second case. In particular, both
$n$-dimensional \emph{solid grids} of (hyper)-cuboidal cells
and their $d$-dimensional \emph{skeletons}
($0\leq d\leq n$), embedded in
$\E^n$, are generated by assembling the cells produced by a
number $n$ of either $0$- or $1$-dimensional cell
complexes, that in such lowest dimensions coincide with \emph{simplicial
complexes}. Generation of \emph{grids} works by \emph{Cartesian product} of
$0/1$-complexes; the \emph{output complex} is generated by the product of
\emph{any number} of either 0- or 1-dimensional complexes. The
product of $d$ one-dimensional complexes generates \emph{solid}
$d$-cells, while the product of $n$ zero-dimensioanl complexes and
$n-d$ 1-complexes ($d < n$) generates
\emph{non-solid} $(n-d)$-cells, properly embedded in
$n$-space, i.e.~with vertices having $n$ coordinates.

\paragraph*{Assemblies of cellular complexes}
Hierarchical models of assemblies are generated by aggregation
of cellular complexes, each one defined in a local coordinate system,
and possibly relocated by affine transformations of coordinates. This
operation may be repeated hierarchically, with subassemblies defined by
aggregation of simpler parts, and so on, until to obtain a set of \texttt{Lar}
models, which are not further decomposed.
This \emph{hierarchical model}, defined inductively
as an assembly of component parts, is described by an \emph{acyclic
directed multigraph}, often called a \emph{scene graph} or
\emph{hierarchical structure} in computer graphics and modeling. The
main algorithm in \texttt{Lar} with hierarchical assemblies is the \texttt{traversal}
function, which transforms every component from \emph{local coordinates}
to global coordinates, called \emph{world coordinates}.

\paragraph*{Hierarchical modeling}
Two main advantages can be found in a hierarchical modeling approach.
(a) Each component complex and each assembly, at every hierarchical level,
are defined independently from each other, using a local coordinate
frame, suitably chosen to make its definition easier. (b) Only
one copy of each component is stored in memory, and may be instanced in
different locations and orientations how many times it is needed.

A \emph{container} of geometrical objects is defined by applying the
function \texttt{Struct} to the array of contained objects. The value
returned from the application is a value of \texttt{Struct} type. The
coordinate system of this value is the one associated with the first
object of the \texttt{Struct} parameters. Also, the resulting
geometrical value is often associated with a variable name.
An affine \(3\times 3\) transformation matrix, generated in homogeneous
normalized coordinates by the function call \texttt{t(-0.5,-0.5)}, can
be \emph{applied} to a \texttt{Lar} object \texttt{obj} both \emph{explicitly} by
using the function \texttt{apply(Matrix, obj)} or \emph{implicitly} by
creating a \texttt{Struct} hierarchical object.

\paragraph*{From hierarchical models to flat models}
The generation of container nodes may continue hierarchically by
suitably applying \texttt{Struct}. Notice that each \texttt{Lar} object in a
\texttt{Struct} container is transformed by each matrix before it
\emph{within the container}, going from right to left. The action of a
transformation (tensor) extends to every object rightwise within its
own container. Conversely, the action of a tensor does not extend outside
its container, according to the semantics of \texttt{PHIGS} structures.
The function \texttt{evalStruct}, when applied to a \texttt{Struct}
value, generates an \texttt{Array} of \texttt{Lar} models, each one originally
defined in a \emph{local coordinate} system, transforming all of them in
the same \emph{world coordinate}, equal to the one of the \emph{first}
object in the \texttt{Struct} parameter sequence (see Section~\ref{sec:boolean}).
Conversely, the \texttt{struct2lar} function generates a \emph{single}
\texttt{Lar} model (cellular complex), whose components are there assigned
 to variables \texttt{V} (coordinates of vertices),
\texttt{FV} faces (2-cells), and \texttt{EV} edges (1-cells). Notice
that the whole model is \emph{embedded in 3D}, since the \texttt{V}
array (coordinates by columns) has \emph{three rows}.

\paragraph*{Parametric objects}
The \texttt{src/mapper.jl} file contains the implementation of several
parametric primitives, including \emph{curves}, \emph{surfaces} and \emph{solids} embedded in
either 2D or 3D.
A constructive approach is common to all methods. It consists in
generating a simplicial or cuboidal decomposition of a simple
geometrical domain in ${u,v}$ or ${u,v,w}$ parametric space. Then
a change of coordinates, \emph{e.g.}, from polar or cylindrical
to Cartesian, is applied to vertices of the cellular complex which
decomposes the domain.

\paragraph*{Integration of monomials}
A finite integration method is implemented in \texttt{src/integr.jl}, to compute
monomial integrals over polyhedral solids and surfaces in
3D space. This integration can be used for the exact evaluation of
domain integrals of trivariate polynomials.
The evaluation of surface and volume integrals is achieved by
transform into line integrals over the boundary of every 2-simplex
of a boundary triangulation. The \texttt{Lar} integration formulae
may also be used with models consisting of the collection of its boundary's 2-loops (polygons).
Loops must be oriented counter-clockwise if external, clockwise if internal
to another loop.

\subsection{\texttt{ViewerGL.jl}}
%--------------------------------------------------------------------------------
The work on this package started only recently, but already provides useful visualization tools, allowing for fast 3D user interaction with 2D and 3D geometric models.

\paragraph*{Basic \texttt{ModernGL} infrastructure} Several Julia's \texttt{struct} objects are used at the basic implementation level of \texttt{ViewerGL}, and in particular for describing the current state of variables of  types  \texttt{Point}, \texttt{Matrix}, \texttt{Quaternion}, \texttt{Box}, \texttt{Frustum}, \texttt{Viewer}, \texttt{GLColorBuffer}, \texttt{GLMesh}, \texttt{GLPhongShader}, \texttt{GLShader}, \texttt{GLText}, \texttt{GLUtils}, \texttt{GLVertexArray}, and \texttt{GLVertexBuffer}.
\texttt{Graphictext} is a cellular implementation of a native Julia's vector font, mainly used to help  the visual testing and debugging of geometric codes, by visually numbering vertices, edges, faces, and solid cells.

\paragraph*{High-level visualization primitives}
At low-level, OpenGL uses only few basic primitives, whose vertices must suitably embedded into proper buffers for \texttt{points}, \texttt{normals}, and \texttt{colors}.
A number of high-level, user-oriented, graphics primitives were implemented to allow direct and easy rendering of various types of cellular complexes, both 2D and 3D, each reurning an object of type \texttt{GLMesh} to direvtly feed the \texttt{Viewer}. Those primitives currently include:
\texttt{GLHull}, \texttt{GLHull2d}, \texttt{GLHulls}, \texttt{GLPolygon}, \texttt{GLPolygons}, \texttt{GLLar2gl}, \texttt{GLLines}, \texttt{GLPoints}, \texttt{GLPolyhedron}, \texttt{GLPolyhedrons}, \texttt{GLGrid}, and \texttt{GLExplode}, that all accept as input a \texttt{\texttt{Lar}} model.

%================================================================================
\section{Examples}
%================================================================================

Both \texttt{LinearAlgebraicRepresentation} and \texttt{ViewerGL} packages contain several simple \texttt{examples/} scripts, to help the user to get acquainted. The actual APIs are not yet completely defined.

\subsection{Arrangement of circles and rectangles}
%--------------------------------------------------------------------------------

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=0.5\linewidth]{figs/bubble1.png}%
   \includegraphics[width=0.5\linewidth]{figs/bubble2.png}%

   \includegraphics[width=0.5\linewidth]{figs/bubble3.png}%
   \includegraphics[width=0.5\linewidth]{figs/bubble4.png}%
   \caption{Four views of the 2D arrangement generated by circles and regular polygons:
   (a) the input random polylines; (b) 2-space partition generated by the input;
   (c) exploded view of the output arrangement; (d) exploded view of boundary 1-cycles of
   unit 2-chains of the 2-space arrangement.}
   \label{fig:example}
\end{figure}

\begin{figure}[htb] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=0.5\linewidth]{figs/squares1.png}%
   \includegraphics[width=0.5\linewidth]{figs/squares2.png}

   \caption{Two views of the 2D arrangement generated by random rectangles:
   (a) exploded view of fragmented 1-chain generated by the input boundaries of rectangles;
   (b) the 2-space arrangement generated by the input.}
   \label{fig:example}
\end{figure}

\subsection{Boolean 3D workflow}\label{sec:boolean}\footnote{You may enjoy trying \texttt{Lar.cuboidGrid([2,2,2],true)}}
%--------------------------------------------------------------------------------
First define \texttt{cube} as a single element of a grid of cubes:

{\footnotesize\begin{verbatim}
using LinearAlgebraicRepresentation, ViewerGL, SparseArrays
Lar = LinearAlgebraicRepresentation; GL = ViewerGL
V,(VV,EV,FV,CV) = Lar.cuboidGrid([1,1,1],true)
cube = V,FV,EV
\end{verbatim}}

Then position three instances of cubes in $\E^3$ within a hierarchical scene graph, using the \texttt{Struct} function:

{\footnotesize\begin{verbatim}
threecubes = Lar.Struct([ cube,
	Lar.t(.3,.4,.25),Lar.r(pi/5,0,0),Lar.r(0,0,pi/12),cube,
	Lar.t(-.2,.4,-.2),Lar.r(0,pi/5,0),Lar.r(0,pi/12,0),cube ]);
\end{verbatim}}

Convert \texttt{threecubes} to single (self-intersecting) model \texttt{V,FV,EV}, and visualize the collection \texttt{FV} of faces (2-cells). It is not a cellular complex, since cells intersect out of boundaries. See Figure~\ref{fig:threecubes}a:

{\footnotesize\begin{verbatim}
V,FV,EV = Lar.struct2lar(threecubes)
GL.VIEW([ GL.GLGrid(V,FV), GL.GLFrame ])
\end{verbatim}}

Next, prepare the input data types for computing the 3-space arrangement.
We have to yet better define the  IDE. \texttt{Lar.Cells} and \texttt{Lar.ChainOp} are array or sparse matrix of $p$-cells, respectively.

{\footnotesize\begin{verbatim}
cop_EV = Lar.coboundary_0(EV::Lar.Cells);
cop_EW = convert(Lar.ChainOp, cop_EV);
cop_FE = Lar.coboundary_1(V,FV::Lar.Cells,EV::Lar.Cells);
W = convert(Lar.Points, V');
\end{verbatim}}

$[\delta_2],\;[\delta_1],\;[\delta_0]=\texttt{ChainOp[copCF}, \texttt{copFE}, \texttt{copEV]}$, \emph{Chain Complex} embedded in $\E^3$ by  $3\times n$ vertex matrix \texttt{V}, is finally generated:

{\footnotesize\begin{verbatim}
V, copEV, copFE, copCF =
	Lar.Arrangement.spatial_arrangement(W, cop_EW, cop_FE)
\end{verbatim}}

The 8 rows of the $\delta_2: C_2\to C_3$ matrix (below) or the 8 columns of $[\partial_3]=[\delta_2]^t$, $\partial_3: C_3\to C_2$, generate the eight
3-cells of Figure~\ref{fig:threecubes}d.

{\footnotesize\begin{verbatim}
@show Matrix(copCF);
\end{verbatim}}\vspace{-2mm}
{\tiny\begin{verbatim}
Int8[
-1 0 1 0 0 0 1 0 -1 0 -1 0 0 0 -1 1 0 1 0 0 -1 1 0 1 -1 0 0 0 -1 -1 0 1 0 0 -1 0 1 0 0 0 1 -1 0 -1 0 0 1;
 0 -1 0 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 0 0 0 1 0 -1 0 0 0 -1 1 0 1 0 0 -1;
 0 0 0 -1 0 0 0 -1 0 0 0 1 1 0 0 0 -1 0 0 1 0 0 -1 0 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 1 0 0 0 0 0 1 0 0;
 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 -1 0 0 0 0 0 -1 0 0;
 1 0 -1 0 0 0 -1 0 1 0 1 0 0 0 1 -1 0 -1 0 -1 0 0 1 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 1 0 0 0 0 -1 0 0 0 0;
 0 0 0 1 0 0 0 1 0 0 0 -1 -1 0 0 0 1 0 0 0 1 -1 0 -1 1 0 0 0 1 1 0 -1 0 0 0 -1 0 0 0 1 0 0 0 0 0 1 0;
 0 1 0 0 0 -1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 0 0 -1 0 0 0 0 1 0 0 0 0;
 0 0 0 0 1 0 0 0 0 0 0 0 0 -1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 -1 0 0 0 0 0 -1 0]
\end{verbatim}}

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=0.5\linewidth]{figs/3cubes1.png}%
   \includegraphics[width=0.5\linewidth]{figs/3cubes2.png}%

   \includegraphics[width=0.5\linewidth]{figs/3cubes3.png}%
   \includegraphics[width=0.5\linewidth]{figs/3cubes4.png}%
  \caption{Images of the 3D arrangement generated by three unit cubes:
   (a) transparent view of the input; (b) exploded 2-skeleton of 3D space partition;
   (c) exploded view of boundary 1-cycles of 2-cells; (d) exploded view of (transparent)
   3-chain, which is the basis of 3-space arrangement generated by the input. The white 2-cycle is the
   boundary of outer space.}
  \label{fig:threecubes}
 \end{figure}

Finally, the \texttt{Lar} model is triangulated, via \texttt{Triangle.jl} package, giving CDT (constrained Delaunay Triangulation), and converted to triangle arrays per 3-cell, per 2-cell, and per  polygon boundary:

{\footnotesize\begin{verbatim}
W = convert(Lar.Points, V')
V,CVs,FVs,EVs = Lar.pols2tria(W, copEV, copFE, copCF)
\end{verbatim}}

{\footnotesize\begin{verbatim}
GL.VIEW(GL.GLExplode(V,FVs,1.5,1.5,1.5,99,1));
GL.VIEW(GL.GLExplode(V,EVs,1.5,1.5,1.5,99,1));
meshes = GL.GLExplode(V,CVs[1:end],8,4,6,99,0.5);
GL.VIEW( push!( meshes, GL.GLFrame) );
\end{verbatim}}

%================================================================================
\section*{Acknowledgements}
%================================================================================
The author is grateful to Antonio DiCarlo and Vadim Shapiro for sharing a lasting curiosity in the exploration of novel geometric territories, and to Giorgio Scorzelli, Francesco Furiani and Giulio Martella for help with the software.

%================================================================================
\section{Conclusion}
%================================================================================
In this paper a very simple and general approach to geometric and topological computing using only Julia's~\cite{bezanson2017julia} sparse arrays was presented. Sparse arrays should fit well with the fast diffusion of hybrid architectures and their advanced applications, using the best-in-class numerical language. The future applications may cover disparate fields of visual calculus, including geomapping, solid and geometric computer-aided design, virtual reality, computer vision, and medical imaging.
We are just at the beginning of this journey. A lot of work remains, and this author has strong hope to share the enjoyment of discovery with the Julia's community.

\bibliographystyle{juliacon}
\scriptsize
\bibliography{ref}

%\input{bib.tex}

\end{document}

% Inspired by the International Journal of Computer Applications template


\section{Methods}

\subsection{Notation}

In the following, we will use definitions and notations introduced by \citep{rougier:2011} where a neural map is defined as the projection from a manifold $\Omega \subset \mathbb{R}^d$ onto a set $\mathcal{N}$ of $n$ {\em  neuron}s which is formally written as $\Phi : \Omega \rightarrow \mathcal{N}$. Each neuron $i$ is associated with a code word $\mathbf{w}_i \in \mathbb{R}^d$, all of which establish the set  $\{\mathbf{w}_i\}_{i \in   \mathcal{N}}$ that is referred as the code book. The mapping from $\Omega$ to $\mathcal{N}$ is a closest-neighbor winner-take-all rule such that any vector $\mathbf{v} \in \Omega$ is mapped to a neuron $i$ with the code $\mathbf{w}_\mathbf{v}$ being closest to the actual presented stimulus vector $\mathbf{v}$,
\begin{equation}
\Phi : \mathbf{v} \mapsto argmin_{i \in \mathcal{N}} (\lVert \mathbf{v} -
\mathbf{w}_i \rVert).
\label{eq:psi}
\end{equation}
The neuron $\mathbf{w}_\mathbf{v}$ is named the best matching unit (BMU) and the set $C_i = \{x \in \Omega | \Phi(x) = \mathbf{w}_i \}$ defines the {\em receptive field} of the neuron $i$.

%Before we present our new SOM learning algorithm, we introduce the notation  and terminology we are using throughout the present work. We borrow the notation from a previous work \citep{rougier:2011}.  A neural map is defined to be the projection from a manifold $\Omega \subset \mathbb{R}^d$ onto a set $\mathcal{N}$ of $n$ {\em neuron}s $\Phi : \Omega \rightarrow \mathcal{N}$. Each neuron $i$ is associated with a code word $\mathbf{w}_i \in \mathbb{R}^d$, all of which establish the set  $\mathcal{W} = \{\mathbf{w}_i, i \in \mathcal{N}\}$ that is referred as the code book. The mapping from $\Omega$ to $\mathcal{N}$ is a closest-neighbor winner-take-all rule such that any vector $\mathbf{v} \in \Omega$ is mapped to a neuron $i$ with the code $\mathbf{w}_\mathbf{v}$ being closest to the current input vector $\mathbf{v}$,
%\begin{equation}
%\Phi : \mathbf{v} \mapsto argmin_{i \in \mathcal{N}} (\lVert \mathbf{v} -
%\mathbf{w}_i \rVert).
%\label{eq:psi}
%\end{equation}
%The neuron $\mathbf{w}_\mathbf{v}$ is named the best matching unit (BMU) and the set $C_i = \{x \in \Omega | \Phi(x) = \mathbf{w}_i \}$ defines the {\em receptive field} of neuron $i$.

\subsection{Spatial distribution} % \& Centroidal Voronoi Tesselation}
\label{sec:spatial_dist}

The SOM space is usually defined as a two-dimensional region where nodes are arranged in a regular lattice (rectangular or hexagonal). Here, we consider instead the random placement of neurons with a specific spectral distribution (blue noise). As explained in \citep{Zhou:2012}, the spectral distribution property of noise patterns is often described in terms of the Fourier spectrum color. White noise corresponds to a flat spectrum with equal energy distributed in all frequency bands while blue noise has weak low-frequency energy, but strong high-frequency energy. In other words, blue noise has intuitively good properties with points evenly spread without visible structure (see figure~\ref{fig:sampling} for a comparison of spatial distributions).
%%
\begin{figure}[htbp]
  \includegraphics[width=\textwidth]{figure-blue-noise.pdf}
  \caption{\textbf{Spatial distributions.}
    \textbf{\textsf{A.}} Uniform sampling (n=1000) corresponding to white noise.
    \textbf{\textsf{B.}} Regular grid (n=32$\times$32) + jitter (2.5\%).
    \textbf{\textsf{C.}} Poisson disc sampling (n=988) corresponding to blue noise.}
  \label{fig:sampling}
\end{figure}
%%
There exists several methods \citep{Lagae:2008} to obtain blue noise sampling that have been originally designed for computer graphics (e.g. Poisson disk sampling, dart throwing, relaxation, tiling, etc.). Among these methods, the fast Poisson disk sampling in arbitrary dimensions \citep{Bridson:2007} is among the fastest ($\mathcal{O}(n)$) and easiest to use. This is the one we retained for the placement of neurons over the normalized region $[0,1]\times[0,1]$. Such Poisson disk sampling guarantees that samples are no closer to each other than a specified minimum radius. This initial placement is further refined by applying a LLoyd relaxation \citep{Lloyd:1982} scheme for 10 iterations, achieving a quasi centroidal Voronoi tesselation.

%The SOM space is usually defined as a two-dimensional manifold where nodes are arranged in a regular lattice (rectangular or hexagonal). Here, we follow a  different approach and, instead of the regular lattice, we place the neurons randomly by sampling a specific spectral distribution. More specifically, we assign neurons positions by drawing samples from a blue noise distribution. \citep{Zhou:2012}. have shown that the spectral distribution property of noise patterns is often described in terms of the Fourier spectrum color. For instance, white noise corresponds to a flat spectrum with signal's energy equally distributed to all frequency bands while blue  noise has weak low-frequency energy and strong high-frequency energy. An interesting property of the blue noise distribution is that  the resulting positions of neurons drawn are evenly spread without any apparent structure (see figure~\ref{fig:sampling} for a comparison of spatial distributions).
%%
%\begin{figure}[htbp]
%  \includegraphics[width=\textwidth]{figures/blue-noise.pdf}
%  \caption{\textbf{Spatial distributions.}
%    \textbf{\textsf{A.}} Uniform sampling (n=1000) corresponding to white noise.
%    \textbf{\textsf{B.}} Regular grid (n=32$\times$32) + jitter (2.5\%).
%    \textbf{\textsf{C.}} Poisson disc sampling (n=988) corresponding to blue noise.}
%  \label{fig:sampling}
%\end{figure}
%%

%Blue noise distributions have been used in the field of computer graphics for many years and there are manych different techniques for computing them: Poisson disk sampling, dart throwing, relaxation, tiling, and other applications (see \citep{Lagae:2008} for a review). One of the fastest and easiest to implement method for generating blue noise samples is the  fast Poisson disk sampling. This method, introduced by \citep{Bridson:2007}, can be used on arbitrary dimensions in linear time ($\mathcal{O}(n)$). In this work, we propose to use this method for placing neurons over a normalized  region of $[0,1]\times[0,1]$. Such Poisson disk sampling guarantees that samples are no closer to each other than a specified minimum radius. This initial placement is further refined by applying a Lloyd relaxation~\cite{Lloyd:1982} scheme for $10$ iterations to achieve a quasi centroidal Voronoi tesselation.

\subsection{Topology}
\label{sec:topo}

Considering a set of $n$ points $P = \{P_i\}_{i \in [1,n]}$ on a finite region,
we first compute the Euclidean distance matrix $E$, where $e_{ij} = \lVert P_i - P_j \rVert$
and we subsequently define a connectivity matrix $G^{p}$
%= \{G^{p}_{ij}\}_{i,j \in [1,n]}$ \gid{$G^{p} = g^{p}_{ij},\, \text{where } i,j \in [1,n]$}
such that only the $p$ closest points
are connected. More precisely, if $P_j$ is among the $p$ closest neighbours of
$P_i$ then $g^p_{ij} = 1$ else we have $g^p_{ij} = 0$.
From this connectivity
matrix representing a graph, we compute the length of the shortest path between
each pair of nodes and stored them into a distance matrix $D^p$. Note that
lengths are measured in the number of nodes between two nodes such that two
nearby points (relatively to the Euclidean distance) may have a corresponding
long graph distance as illustrated in figure \ref{fig:topology}. This matrix
distance is then normalized by dividing it by the maximum distance between two
nodes such that the maximum distance in the matrix is 1. In the singular case
when two nodes cannot be connected through the graph, we recompute a spatial
distribution until all nodes can be connected.
%%
\begin{figure}
  \includegraphics[width=\columnwidth]{figure-distances.pdf}
  \caption{\textbf{Influence of the number of neighbours on the graph
    distance.} The same initial set of 1003 neurons has been equiped with
    2-nearest neighbors, 3 nearest neighbors and 4-nearest neighbors induced
    topology (panels \textbf{A}, \textbf{B} and \textbf{C} respectively). A
    sample path from the the lower-left neuron to the upper-right neuron has
    been highlighted with a thick line (with respective lengths of 59, 50 and
    46 nodes).}
  \label{fig:topology}
\end{figure}

%Consider a set $P$ of $n$ points on a finite region of $[0, 1] \times [0, 1]$. The steps we follow to determine the topology of the SOM are: First, we compute the Euclidean distance matrix ${\bf E} \in \mathbb{R}^{n\times n}$, where $e_{ij} = \lVert p_i - p_j \rVert$ and $i, j=1, \ldots, n$. Subsequently  we define a connectivity matrix ${\bf G}_m$ with elements $g_{ij} = 1$ if $p_j$ belongs to the $m$ closest points to $p_i$ and $g_{ij} = 0$ otherwise. This definition implies that the matrix ${\bf G}_m$ carries information about connected neurons within a predetermined vicinity. Once we compute matrix ${\bf G_m}$, which essentially represents a graph, we compute the shortest path between each pair of nodes on the graph and we store them into a new matrix called ${\bf D}_m$. Note that lengths are measured in number of nodes (hops) required to reach two nodes such that the two corresponding Euclidean points (represented by the nodes) may have a graph distance as illustrated in figure \ref{fig:topology}.  \gid{This matrix distance is then normalized by dividing it by the maximum distance between two nodes. NOT VERY CLEAR}. In the degenerative case where two nodes are not connected on the graph, we resample from a spatial distribution until all nodes have degree greater than one (are connected at least with one other node \gid{IS THIS CORRECT?}).
%%
%\begin{figure}
%  \includegraphics[width=\columnwidth]{figures/distances.pdf}
%\caption{\textbf{Influence of the number of neighbours on the graph distance.} The same initial set of 1003 neurons has been equipped with 2-nearest neighbors, 3 nearest neighbors and 4-nearest neighbors induced topology (panels \textbf{A}, \textbf{B} and \textbf{C} respectively). A sample path from the the lower-left neuron to the upper-right neuron has been highlighted with a thick line (with respective lengths of 59, 50 and 46 nodes).}
%  \label{fig:topology}
%\end{figure}

\subsection{Learning}

The learning process is an iterative process between time $t=0$ and time $t=t_f \in \mathbb{N}^+$ where vectors $\mathbf{v} \in \Omega$ are sequentially presented to the map. For each presented vector $\mathbf{v}$ at time $t$, a winner $s \in \mathcal{N}$ is determined according to equation (\ref{eq:psi}). All codes $\mathbf{w}_{i}$ from the code book are shifted towards $\mathbf{v}$ according to
\begin{equation}
  \Delta\mathbf{w}_{i} = \varepsilon(t)~h_\sigma(t,i,s)~(\mathbf{v} -
  \mathbf{w}_i)
  \label{eq:som-learning}
\end{equation}
with $h_\sigma(t,i,j)$ being a neighborhood function of the form
\begin{equation}
  h_\sigma(t,i,j) = e^{- \frac{{d^p_{ij}}^2}{\sigma(t)^2}}
  \label{eq:som-neighborhood}
\end{equation}
where $\varepsilon(t) \in \mathbb{R}$ is the learning rate and $\sigma(t) \in \mathbb{R}$
is the width of the neighborhood defined as
\begin{equation}
  \sigma(t) =
  \sigma_i\left(\frac{\sigma_f}{\sigma_i}\right)^{t/t_f}, \text{ with } \varepsilon(t) =
  \varepsilon_i\left(\frac{\varepsilon_f}{\varepsilon_i}\right)^{t/t_f},
\end{equation}
while $\sigma_i$ and $\sigma_f$ are respectively the initial and final neighborhood width and $\varepsilon_i$ and $\varepsilon_f$ are respectively the initial and final learning rate. We usually have $\sigma_f \ll \sigma_i$ and $\varepsilon_f \ll \varepsilon_i$.

%The learning algorithm we propose in this work relies on the standard SOM algorithm~\cite{Kohonen:1982}. Once we have define the topology of the map following the steps we described in paragraph~\ref{sec:topo}, we can start the learning process. Learning is iterative and starts at a time $t_0=0$ and runs until some predetermined final time step, $t_f \in \mathbb{N}^+$, has been reached. At every iteration input vectors $\mathbf{v} \in \Omega$ are sequentially given to the map with respect to the probability density function $f$ \gid{Where is defined?}. For each vector $\mathbf{v}$ at time $t$, a winner neuron with index  $s \in \mathcal{N}$ is determined according to equation (\ref{eq:psi}). This means that at time $t$ neuron $s$ is closer to the input vector ${\bf v}$, in the sense of Euclidean distance, than any other neuron. Once the winner neuron has been identified all codes $\mathbf{w}_{i}$ from the current code book are shifted towards $\mathbf{v}$ according to
%\begin{align}
%\label{eq:som-learning}
%    \Delta\mathbf{w}_{i} &= \varepsilon(t)~h(t,i,s;\sigma)~(\mathbf{v} - \mathbf{w}_i),
%\end{align}
%where $s$ is the index of the winner neuron, $i$ is the index of code words in the code book and $t$ is the current time step. $h_\sigma(t,i,j;\sigma)$ is a neighborhood function of the form
%\begin{equation}
%  h(t,i,j; \sigma) = \exp\Big(-\frac{{d_{ij}}^2}{\sigma(t)^2}\Big)
%  \label{eq:som-neighborhood}
%\end{equation}
%where $\varepsilon: \mathbb{R} \rightarrow \mathbb{R}$ is the learning rate time-dependent function given by $\varepsilon(t) = \varepsilon_i\left(\frac{\varepsilon_f}{\varepsilon_i}\right)^{t/t_f}$, where $\varepsilon_i$ and $\varepsilon_f$ are the initial and final learning rates, respectively. $\sigma: \mathbb{R} \rightarrow \mathbb{R}$ is determines the width of the  neighborhood function~\eqref{eq:som-neighborhood} and it is reads $\sigma(t) = \sigma_i\left(\frac{\sigma_f}{\sigma_i}\right)^{t/t_f}$, where $\sigma_i$ and $\sigma_f$ are the initial and final neighborhood widths, respectively. We usually assume $\sigma_f \ll \sigma_i$ and  $\varepsilon_f \ll \varepsilon_i$. The entire learning procedure is summarized by Algorithm~\ref{algo:vsom}.

%% \input{algorithm}

\subsection{Analysis Tools}
In order to analyze and compare the results of RSOM and SOM, we used a spectral method and persistence diagram analysis on the respective codebooks. These analysis tools are detailed below but roughly, the spectral method allows to estimate the distributions of eigenvalues in the activity of the maps while the persistence diagram allows to check for discrepancies between the topology of the input space and the topology of the map.

% To analyze the results of both the Kohonen SOM and VSOM algorithms and to make any comparison between the two algorithms we use a spectral method and persistence diagram on codebooks. The spectral method estimates the distributions of eigenvalues of the activity of neurons. The persistence diagram is a topological-geometrical  approach, more precisely is a tool coming from the field of topological data analysis (TDA). TDA provides the tools to investigate the topology of the maps and the input space and spot differences between the topology of the input space and the neural space of the SOM algorithms (Kohonen and VSOM).

%\subsubsection{Topological Data Analysis}
\label{sec:tda}

Topological Data Analysis (TDA) \citep{Carlsson:2009} provides methods and tools to study topological structures of data sets such as point cloud and is useful when geometrical or topological information is not apparent within a data set. Furthermore, TDA tools are insensitive to dimension reduction and noise which make them well suited to analyze high-dimensional self-organized maps and their corresponding input data sets. In this work, we use the notion of persistent barcodes and diagrams \citep{Edelsbrunner:2008} to spot any differences between the topology of the input and neural spaces. Furthermore, we can apply some metrics from TDA such as the Bottleneck distance and measure how close two persistent diagrams are.

\correction { We provide, here, a simple example of how we used TDA to
  extract information relative to the underlying topology of input and
  neural spaces (a more rigorous description of the methods used in this work
  are given in section~\ref{sec:si_tda} of SI).
  Figure~\ref{fig:tda_example} illustrates a complete example of how we apply
  TDA in this work. First we need to collect the data (point cloud). In our
  example the data are either the $2$-dimensional points of the input space or
  the codebooks of the neural space (see panel A of
  Figure~\ref{fig:tda_example}). Once we have the point cloud we apply
  a filtration process, where a disc of a specific radius, $\alpha$ is
  drawn around each point. We increase the radius systematically and
  all the intersected discs are registered. In
  figure~\ref{fig:tda_example} B, radius $\alpha_1$ is too small and
  therefore there are no intersected discs. The simplicial complex
  (see section~\ref{sec:si_tda} for more details) in this case is a
  set of points (\emph{i.e.}, simplex $0$). The isolated points in the
  bottom panel of figure~\ref{fig:tda_example}B define the homology group
  $H0$. This can be seen also in the persistence barcode shown in
  figure~\ref{fig:tda_example}E, where the blue lines correspond to the
  isolated points. The beginning of the line segment indicates the
  radius at which each point is born and the end of the line shows when it
  vanished (died). A line segment on the persistent barcode
  (figure~\ref{fig:tda_example}F) or a point on the persistent diagram
  (figure~\ref{fig:tda_example}E) appears when a disc is applied on a
  data point (birth) and it is preserved until the disc intersects
  another disc (or other discs). Then the line segment or the point
  dies and a new one that represents the joint (intersected discs)
  appear in the persistent barcode or diagram.  If a point persists
  the most then that point considered significant from a topological
  point of view. }

\correction{Back to our example, the radius $\alpha$ is increased
  until some discs intersect each other ($\alpha_2$, panel C).  When
  two discs intersect, we connect their centers (dots) with a line
  segment (\emph{i.e.}, simplex $1$). In figure~\ref{fig:tda_example}C, bottom
  panel, we see that there is a closed path formed by the connected
  linear segments and there is a hole in the complex.  This hole
  corresponds to an $H1$ homology group and the isolated point (or
  points) to $H0$ homology. The persistent barcode reveals the
  formation of a hole when the radius reaches the $\alpha_2$ and the
  orange linear segment first appears in figure~\ref{fig:tda_example}E. The
  other orange line segment corresponds to some other radius that is not
  shown for illustration purposes. Increasing the radius even
  further, we get larger discs and now in some cases, more than two
  discs intersect. When three discs intersect we obtain a triangle
  (simplex $2$, pink triangles in panel D) and when four discs
  intersect we get a tetrahedron (simplex $3$, blue color in panel D), etc.
  Both the triangles and the tetrahedron are not important topological
  features and thus we ignore them. What is important here is the
  number of isolated points, holes an voids (we are not considering
  voids in this example). }

\correction{By following the procedure described in the
  aforementioned example, for any $n$-dimensional inputs, we can
  obtain the persistence barcodes and diagrams, like the ones in
  figures~\ref{fig:tda_example} \textbf{E} and \textbf{F},
  respectively. By inspecting the barcodes we can decide if there is
  any important (persistent) topological feature. Furthermore, we can
  compare quantitatively the persistence diagrams by using distance
  functions such as the Bottleneck distance~\citep{Chazal:2017}. Thus
  we can examine how close two persistence diagrams are and hence, we
  can infer how the self-organizing maps retain or degenerate the
  topology of the input space since we compare the persistence of
  input space against the codebooks of the neural space. Therefore, we
  can compare the input space against the learned codebooks of our
  algorithm (RSOM) and those learned by Kohonen's SOM. Finally, we can
  draw some conclusions on which algorithm retains the topology of
  input space the best. For the analysis in this work we used the
  Gudhi library~\citep{Maria:2014}. In section~\ref{sec:si_tda}, we
  provide a rigorous description of how we compute the persistent
  barcodes and diagrams and we give more details on the tools we
  used. }

\begin{figure}[!htpb]
    \centering
    \includegraphics[width=0.8\textwidth]{TDA.pdf}
    \caption{\textbf{Example of Topological Data Analysis.}
      \textbf{A} Point cloud (input data to TDA algorithm). In our
      case this can be either the data points of the input space or
      the codebooks of neural space. The filtration begins with discs
      of small radius $\alpha$ placed on the data points. For
      instance, in \textbf{B} we have small discs (radius is
      $\alpha_1$) and we observe that no disc intersect with
      another. Therefore the simplicial complex in this case is just a
      set of points (bottom panel of \textbf{B}). Then the radius is
      being increased to $alpha_2$ and we see in \textbf{C} that now
      many intersecting discs appear. Whenever two discs intersect we
      connect their centers with a line segment and we obtain the
      simplicial complex at the bottom panel. In this case we have a
      circle (hole marked in orange color) and a disconnected point.
      This hole is reflected in the persistent barcode (see panel E)
      as the longer orange line segment (H1 homology).  In \textbf{D}
      the radius is being further increased to $\alpha_3$ and thus
      more discs are now intersecting with each other. In this case
      there are three or four discs intersecting and thus triangles
      (simplex $3$) and tetrahedrons are formed (see the purple and
      pink colors in the bottom panel, respectively). However, the
      hole that formed when the radius was set to $\alpha_2$ is still
      present (persists) and this is reflected to the persistent
      barcode (panel E) by the longer orange line segment.  The
      persistent barcode in \textbf{E} illustrates the isolated points
      and the holes detected during the filtration process. The points
      are represented by the blue line segments and the holes by the
      orange ones. We call the former $H0$ group (homology $0$) and
      the latter $H1$ homology. A similar representation is given by
      the persistence diagram in \textbf{F}, where each dot represents
      a pair of (birth, death) of a persistent feature. For instance,
      when we apply the discs on data points for first time we mark
      the birth and once the discs intersect for first time then the
      two points that correspond to the intersected discs die and one
      new is generated (the two center of discs have been joined with
      a line segment). In the persistent diagram the blue dots
      correspond to $H0$ and orange ones to $H1$ homology.}
    \label{fig:tda_example}
\end{figure}

\subsection{Simulation Details}

Unless specified otherwise, all the models were parameterized using values given in table \ref{table:parameters}. These values were chosen to be simple and do not really impact the performance of the model. All simulations and figures were produced using the Python scientific stack, namely, SciPy \citep{Jones:2001}, Matplotlib \citep{Hunter:2007}, NumPy \citep{Walt:2011}, Scikit-Learn \citep{Pedregosa:2011}. Analysis were performed using Gudhi \citep{Maria:2014}).
Sources are available at \href{https://github.com/rougier/VSOM}{github.com/rougier/VSOM}.
%%
\begin{table}[!ht]
  \begin{center}
    \begin{tabular}{ll}
        \textbf{Parameter} & \textbf{Value} \\
        \hline
        Number of epochs      ($t_f$)           & 25000\\
        Learning rate initial ($\varepsilon_i$) & 0.50\\
        Learning rate final   ($\varepsilon_f$) & 0.01\\
        Sigma initial         ($\sigma_i$)      & 0.50\\
        Sigma final           ($\sigma_f$)      & 0.01\\
    \end{tabular}
      \caption{\textbf{Default parameters} Unless specified otherwise, these are
        the parameters used in all the simulations.}
      \label{table:parameters}
  \end{center}
\end{table}

%We conduct all the experiments using the parameters provided by Table~\ref{table:parameters}. In all the experiments the input space is the Cartesian product $[0, 1] \times [0, 1]$ and neurons positions drawn from a blue noise distribution using the fast Poisson disk sampling algorithm~\cite{Bridson:2007} (see paragraph~\ref{sec:spatial_dist} for more details).  The source code of the proposed algorithm is written in the Python programming language (SciPy~\cite{Jones:2001}, Matplotlib~\cite{Hunter:2007} and NumPy~\cite{Walt:2011}, Scikit-Learn~\cite{Pedregosa:2011}, Gudhi~\cite{Maria:2014}). Sources are available at \href{https://github.com/rougier/VSOM}{github.com/rougier/VSOM}.

%% Considering a set of $n$ points $P = \{P_i\}_{i \in [1,n]}$ on a finite domain
%% $D \in \mathbb{R}^2$, the Voronoi tesselation $V(P) = \{V_i\}_{i \in [1,n]}$ of
%% $P$ is defined as:
%% %
%% \begin{equation}
%%   \forall i \in [1,n], V_i = \{x \in D \mid
%%   \lVert x - P_i \rVert \leq \lVert x - P_j \rVert, \forall j \neq i\}
%% \end{equation}
%% %
%% Reciprocally, the (unique) Delaunay triangulation $T(P) = \{T_i\}_{i \in
%%   [1,n]}$ of $P$ is the dual graph of the Voronoi diagram and defined such that
%% no point in $P$ is inside the circumcircle of any triangles in $T(P)$. The
%% centers of the circumcircles are equivalent to the Voronoi diagram, i.e. a
%% partition of $D$ into Voronoi cells. For each of the cell $V_i$, we can compute
%% its centroid $C_i$ which is the center of mass of the cell. A Voronoi
%% tesselation is said to be centroidal when we have $\forall i \in [1,n], C_i =
%% P_i$ (see figure~\ref{fig:CVT}).\\

%% For an arbitrary set of points, there is no guarantee that the corresponding
%% Voronoi tesselation is centroidal but different methods can be used to
%% generate a centroidal tesselation from an arbitrary set of points. One of the
%% most straightforward and iterative methods is the Lloyd relaxation scheme
%% \cite{Lloyd:1982}:
%% \begin{enumerate}
%%   \item The Voronoi diagram of the $n$ points is computed
%%   \item The centroid of each of the $n$ Voronoi cell is computed.
%%   \item Each point is moved to the corresponding centroid of its Voronoi cell
%%   \item The method terminates if criterion is met (see below), else go to 1
%% \end{enumerate}
%% The algorithm finishes when the maximum distance between points and centroids
%% is less than a given threshold as illustrated in figure~\ref{fig:CVT}. It is
%% to be noted that because of numerical imprecisions, there is no guarantee that
%% an arbitrary small threshold can be reached.

%% \begin{figure}[htbp]
%%   \includegraphics[width=\textwidth]{figures/CVT.pdf}
%%   \caption{\textbf{Centroidal Voronoi Tesselation.}  \textbf{\textsf{A.}}
%%     Voronoi diagram of a uniform distribution (n=100) where red dots represent
%%     the uniform distribution and white circles represent the centroids of each
%%     Voronoi cell. \textbf{\textsf{B.}} Centroidal Voronoi diagram where the
%%     point distribution matches the centroid distribution which constitutes a
%%     blue noise distribution (i.e. {\em a distribution that is roughly uniformly
%%       random with no preferred inter-point directions or distances} according
%%     to the definition of \cite{Ebeida:2014}). This figure has been obtained
%%     from the initial distribution on the left after 50 iterations of the Lloyd
%%     relaxation algorithm. }
%%   \label{fig:CVT}
%% \end{figure}
%


\chapter{Extensions}
\section {Transversals}
{\bf Definition 1:}
$G$ is an \emph{extension} of $K$ by $Q$ if $G \triangleright K$ and $G/K \cong Q$
or equivalently $1 \rightarrow K \rightarrow G \rightarrow Q \rightarrow 1$.
\\
\\
{\bf Theorem 1:}
If $1 \rightarrow N \rightarrow_{i} G \rightarrow_{\varphi} Q \rightarrow 1$, the following
are equivalent
(1) $\exists Q^* \subseteq G: Q^* \rightarrow Q$ and
(2) $\exists s:Q \rightarrow G$ such that $\varphi \cdot s = id$.
(3) $G$ is a semi-direct product of $N$ by $Q$ written $N \ltimes Q$; in this
case, we say $G$ is a split extension of $N$ by $Q$.
\begin{quote}
\emph{Proof:}  See the chapter on constructions.
\end{quote}
{\bf Extending a group:}
Suppose $G$ is an extension of $N$ by $H$ and let $\phi: H \rightarrow G/N$.  Pick
$s:G \rightarrow H$ such that $s(1)=1$ and $\phi(h) = N s(h)$, then
$\exists f: H \times H \rightarrow N: s(h_1) s(h_2)= f(h_1, h_2) s(h_1 h_2)$
and $f(h_1, h_2) f(h_1 h_2, h_3)= f(h_2, h_3)^{s(h_1)} f(h_1 , h_2 h_3)$.  Note
that $\theta_h: n \mapsto s(h) n s(h)^{-1}$ is in $Aut(N)$ and
$\theta_{h_1}(\theta_{h_2}(n))= \theta_{h_1 h_2}(n)^{f(h_1, h_2)}$.  Note, here $a^b = b a b^{-1}$, usually,
we write $a^b = b ^ {-1} a b$, oh well.
\\
\\
{\bf Theorem:}
Given $N,H$ with $\theta_h \in Aut(N)$ and $\theta_1 = 1$ and a map
$f: H \times H \rightarrow N$ with $f(1,h)=f(h,1)=1$ and
$f(h_1, h_2) f(h_1 h_2 , h_3)= \theta_{h_1}(f(h_2, h_3)) f(h_1, h_2 h_3)$,
suppose $f$ is compatible in the sense that
$\theta_{h_1}(\theta_{h_2}(n))= \theta_{h_1h_2}(n)^{f(h_1, h_2)}$ then the
operation $(n_1, h_1) \cdot (n_2, h_2) = (n_1 \theta_{h_1}(n_2) f(h_1, h_2), h_1 h_2)$
defines a group $G$ which is an extension of $N$ by $H$.
$1 \rightarrow N \rightarrow G \rightarrow H \rightarrow 1$ holds with the obvious
embedding $n \mapsto (n,1)$ and $h \mapsto (1,h)$.
\begin{quote}
\emph{Proof:}  Put $(n,h)^{-1}= \theta^{-1}[n^{-1} f(h,h^{-1})^{-1}], h^{-1})$.
$(n,h)^{-1} \cdot (n,h)= (1,1)$.   $(n,h) \cdot (1,1)= (n,h)$.  Associativity is a long
calculation but works.
\end{quote}
{\bf Definition 2:}
A subset ${\cal T}$ consisting of a representative of each coset
in $G/K$ is called a \emph{transversal}.
\\
\\
{\bf Definition 3:}
If $\pi: G \rightarrow Q$ is a surjective homomorphism with kernel
$K$, $l: Q \rightarrow G$ is a \emph{lifting} if $\pi(l(x))=x$.
If $\pi: Q \rightarrow G$ is a surjective homomorphism with
kernel $K$ and $l:Q \rightarrow G$ is a transversal with $l(1)=0$ then
$f: Q \times Q \rightarrow K$ defined by $l(x)+l(y)= f(x,y) + l(xy)$ is
called a \emph{factor set}.  An ordered triple, $(Q, K, \theta)$ is called \emph{data}
if $K$ is an abelian group, $\theta: Q \rightarrow Aut(K)$; a group $G$ is said to
\emph{realize} the data if $G$ is and extension of $K$ by $Q$ and for every transversal,
$l: Q \rightarrow G$ satisfies $xa = \theta_x(a)
= l(x) +a-l(x)$.  Note additive notation for non-abelian operation.
\\
\\
{\bf Theorem 2:}
Let $G$ be an extension of $K$ by $Q$ and
$l: Q \rightarrow G$ a transversal.  If $K$ is abelian there is a homomorphism
$\theta: Q \rightarrow Aut(K)$ with $\theta(a)= l(x)+a-l(x), \forall a \in K$;
If $l_1: Q \rightarrow G$ is another transversal then
$ l(x)+a-l(x)= l_1(x)+a-l_1(x)$.
\begin{quote}
\emph{Proof:}
$K \lhd G$ so $\gamma_{g|K}$ is an automorphism of $K$ ($\gamma_g$ is conjugation by $g$).
$\mu: G \rightarrow Aut(K)$ given by $\mu(g)= \gamma_g$ is a homomorphism with
$K \leq ker(\mu)$.  $\mu$ induces a homomorphism $\mu_{\#}: G/K \rightarrow Aut(K)$ given by
$\mu_{\#}(Kg)= \mu(g)$.
The first isomorphism theorem gives the isomorphism $\lambda: Q \rightarrow G/K$ and if
$l:Q \rightarrow G$ is a transversal $\lambda(x)=K+l(x)$.
If $l_1: Q \rightarrow G$ is another transversal then $l(x) - l_1(x) \in K$ so
$ K+l(x)= K+l_1(x), \forall x \in Q $.  Thus $\lambda$ does not depend on the choice of transversal.
Put $\theta= \mu_{\#} \lambda$.  $\theta_x = \mu_{\#}(K+l(x))= \mu(l(x)) \in Aut(K)$ so for $a \in K:
\theta_x(a)= \mu(l(x))(a)= l(x)+a-l(x)$.
\end{quote}
{\bf Theorem 3:}
Let $\pi: G \rightarrow Q$ be a surjective homomorphism with kernel $K$ and
$l:Q \rightarrow G$ be a transversal with $l(1)=0$ and $f: Q \times Q \rightarrow K$ the corresponding
factor set.  $f(1,y)=0=f(x,1), \forall x,y \in Q$ and
the \emph{cocycle identity} $xf(y,z)-f(xy,z)+f(x,yz)-f(x,y)=0$ holds $\forall x,y,z \in Q$.
\begin{quote}
\emph{Proof:}
Definition gives $l(x)+l(y)= f(x,y)+l(xy)$.
So $l(1)+l(y)= f(1,y)+l(y)$ and since $l(1)=0$, $f(1,y)= 0$.  Similarly, $f(x,1)=0$.
$[l(x)+l(y)]+l(z)= f(x,y)+f(xy,z)+l(xyz)$ and
$l(x)+[l(y)+l(z)]= xf(y,z)+f(x,yz)+l(xyz)$.
\end{quote}
{\bf Theorem 4:}
Let $G$ realize $(Q, K, \theta )$ and $l$ and $l'$ be transversals with
$l(1)=l'(1)=0$ giving rise to factor sets $f$ and $f'$ then there is an
$h:Q \rightarrow K$ with $h(1)=0$ such that
$f'(x,y)-f(x,y)= xh(y)-h(xy)+h(x), \forall x,h \in Q$.
The \emph{cocycle identity} $xf(y,z)-f(xy,z)+f(x,yz)-f(x,y)=0$ holds $\forall x,y,z \in Q$.
\begin{quote}
\emph{Proof:}
By definition,
$l(x) + l(y)= f(x,y) + l(xy)$
and
$l(1) + l(y)= f(1,y) + l(xy)$; since $l(1)=0$, this gives $f(1,y)=0$ similarly $f(x,1)=0$.
$[l(x)+l(y)]+l(z) = f(x,y)+f(xy,z)+l(xyz)$ and
$l(x)+[l(y)+l(z)] = xf(y,z)+l(xy)+l(z)= xf(y,z)+f(xy,z)+l(xyz)$ so the result follows from associativity.
\end{quote}
{\bf Definition:}  Given data $(Q, K, \theta)$ a \emph{coboundary} is a function
$g: Q \times Q \rightarrow K$ for which $\exists h: Q \rightarrow K$ such that
$h(1)=0$ and $g(x,y)= xh(x)-h(xy)+h(x)$.
The set of all coboundaries is $B^2 (Q,K,\theta)$.
$Z^2 (Q, K, \theta)$ is the set of all \emph{ factor sets}.
$H^2 (Q, K, \theta) \cong Z^2 (Q, K, \theta) / B^2 (Q, K, \theta)$.
\\
\\
{\bf Theorem 5:}
Given data $(Q, K, \theta)$ a function $f: Q \times Q \rightarrow K$ is a factor set iff it satisfies the
cocycle identity.
\begin{quote}
\emph{Proof:}
The $\rightarrow$ direction is the previous theorem.  For $\leftarrow$, let $G$ be the set of all ordered pairs,
$(a,x) \in K \times Q$ with the operation
$(a,x)+(b,y)= (a+xb+f(x,y), xy)$.  This is a group with the cocycle identity required for associativity.
\end{quote}
{\bf Notation:} Denote the $G$ constructed in the previous proof as $G_f$ realizing
$(Q, K, \theta )$ with factor set $f$ arising from $l(x)= (0,x)$.
\\
\\
{\bf Definition:}
Two extensions $G, G'$ realizing
$(Q, K, \theta )$ with factor sets $f, f'$ are \emph{equivalent} if $f'-f \in B^2(Q, K, \theta)$.
\\
\\
{\bf Theorem 6:}
Two extensions are equivalent if the difference of
their two factor sets is in $B^2 (Q, K, \theta)$.
\begin{quote}
\emph{Proof:}
For each $x \in Q$, $l(x)$ and $l'(x)$ are representatives of the same coset
of $K$ in $G$.  Thus $\exists h(x) \in K$ with $l'(x)= h(x) + l(x)$.  Since
$l'(1)= 0 = l(1)$, $h(1) = 0$.  We have
$l'(x) + l'(y) =
(h(x) + l(x)) +
(h(y) + l(y)) =
h(x) + x h(y) + f(x, y) + l(xy) =
h(x) + x h(y) + f(x, y) - h(xy) + l'(xy)$.  Therefore
$f'(, y)= h(x) + x h(y) + f(x, y) - h(xy)$.  The conclusion follows since each term
is in an abelian group.
\end{quote}
{\bf Theorem 7:}
There is a bijection from $H^2(Q,K,\theta)$ to the set, $E$, of
all equivalence classes realizing the data
$(Q, K, \theta )$ taking the identity to the class of the semidirect product.
\begin{quote}
\emph{Proof:}
Let  the
equivalence classes of the extensions realizing the data
$(Q, K, \theta )$ be denoted by
$[G]$.  Define $\varphi: H^2(Q, K, \theta ) \rightarrow E $ by $\varphi(f+B^2(Q, K, \theta))= G_f$.
$\varphi$ is well defined since if $f,g$ are factor sets, $f-g \in
B^2(Q, K, \theta )$ and $[G_f]=[G_g]$. $\varphi$ is a surjection since if
$[G] \in E$ and $f$ is a factor set, $[G]=[G_f]$ and $[G]= \varphi(f+B^2)$.  Finally, an extension is a
semidirect product off its factor set is in $B^2(Q,K,\theta)$.
\end{quote}
{\bf Definition:}
A \emph{projective representation} of a group $Q$ is a homomorphism
$\tau: Q \rightarrow PGL_n({\mathbb C})$.
We say $U$ has the \emph{projective lifting property} if every projective representation
of $Q$ can be lifted to $U$.
If $Q$ is a group then a \emph{cover} (or \emph{representation group}) of $Q$ is a
central extension of $U$ of $K$ by $Q$ (for some abelian $K$) with the projective lifting property
and $K \le U'$.
\\
\\
{\bf Definition:}
The \emph {Schur multiplier} is
$M(Q)=H^2 (Q, {\mathbb C}^{\times})$ ($\theta$ is trivial).
Here $f(1,y)=f(x,1)=1$, $f(x,y) f(xy,z)^{-1} f(x,yz) f(x,y)^{-1}=1$,
$g: Q \times Q \rightarrow {\mathbb C}^{\times}$ is a coboundary
iff $\exists h: Q \rightarrow {\mathbb C}^{\times}$ with $h(1)=1$ such that
$g(x,y)= h(y)(h(xy))^{-1}h(x)$.
\\
\\
{\bf Schur's Theorem:} Every finite group, $Q$, has a cover $U$ which is a central extension
of $M(Q)$ by $Q$.
\begin{quote}
\emph{Proof:} See Rotman.
\end{quote}
{\bf Definition:}
$exp(G)= min \{e: x^e = 1, \forall x \in G \}$.
\\
\\
{\bf Theorem 8:} If $Q$ is finite then $M(Q)$ is a finite abelian group and
$exp(M(Q)) \mid |Q|$.
\begin{quote}
\emph{Proof:}
See Rotman, p 201-211
\end{quote}
{\bf Theorem 9:} If $Q$ is finite $p$-group then $M(Q)$ is a finite abelian $p$-group.
\begin{quote}
\emph{Proof:}
See, Rotman, p 202
\end{quote}
{\bf Theorem 10:} Let $G$ be a group with $G/{\mathbb Z}(G)$ finite, then $G^{(1)}$ is finite.
\begin{quote}
\emph{Proof:}
Let $n= |G/{\mathbb Z}(G)|$.  For $z \in {\mathbb Z}(G)$ and $g,h \in G$: $[g,hz]=[g,h]=[gz,h]$ so the
set of commutators, $\Delta$, is of order at most $n^2$.
Claim: $g \in G^{(1)}$ then $g= x_1 x_2 \ldots x_m$, $x_i \in \Delta$ and
$m \le n^3$.
\end{quote}
{\bf Observation:}
A cyclic extension $G$ of $N$ is
one where $G/N$ is cyclic.  Solvable groups are built from cyclic extensions.
\\
\\
{\bf Definition:}
$G$, an extension of $K$ by $Q$, is a \emph{central extension} if $K<{\mathbb Z}(G)$.  Functorially,
a central extension $G$ is a pair $(H, \pi)$ satisfying
$\pi: H \rightarrow G, ker(\pi) \subseteq {\mathbb Z}(H)$.
$\alpha: (H_1 , \pi_1) \rightarrow (H_2, \pi_2)$ is a morphism in this category.
The universal object in this category (if it exists) is called a
\emph{universal central extension}.
It follows that $(\tilde{G}, \tilde{\pi})$ is universal if
$\forall (H, \sigma), \exists ! \alpha : (\tilde{G}, \tilde{\pi}) \rightarrow
(H, \sigma)$.
\\
\\
{\bf Theorem 11:} Up to isomorphism, there is at most one universal central extension.
\begin{quote}
\emph{Proof:}
If $(G_1, \pi_i), i= 1, 2$ are universal central extensions of $G$,
$\exists \alpha_1:(G_i, \pi_i) \rightarrow (G_{3-i}, \pi_{3-i})$.
$\alpha \alpha_{3-i} = 1$ and by the uniqueness $\alpha_1 \alpha_2 = 1 = \alpha_2 \alpha_1$.
Thus the $\alpha_i$ is an isomorphism.
\end{quote}
{\bf Theorem 12:}   If $(\tilde{G}, \pi)$ is a universal central extension of $G$ then
both $G$ and $\tilde{G}$ are perfect.
\begin{quote}
\emph{Proof:}
Let $H = \tilde{G} \times (\tilde{G}/\tilde{G}')$ and define $\alpha: H \rightarrow G$ by
$\alpha(x,y)= \pi(x)$.   Then $(H, \alpha)$ is a central extension of $G$ and
$\alpha_i: (\tilde{G}, \pi) \rightarrow (H, \alpha)$ are morphisms
where $\alpha_1(x)= (x,1)$ and $\alpha_2(a)= (x, x \tilde{G}')$.  By uniqueness,
$\alpha_1= \alpha_2$, hence $\tilde{G} = \tilde{G}'$.  Thus $\tilde{G}$ is perfect and so
$G= \pi(\tilde{G})$.
\end{quote}
{\bf Theorem 13:}  Let $G$ be perfect and $H, \pi$ be a central extension of $G$ then
$H=ker(\pi)H'$ with $H'$ perfect.
\begin{quote}
\emph{Proof:} $\pi: H \rightarrow G$, $\pi(H')= \pi(H)'=G'=G$ and $ker(\pi) \le {\mathbb Z}(H)$.
$H/H^2 = {\mathbb Z}(H/H^2)= H'/H^2$ is abelian and $H'=H^2$ so $H'$ is perfect.
\end{quote}
{\bf Theorem 14:}
$G$ possesses a universal central extension iff $G$ is perfect.
If $(\tilde{G}, \pi)$ is a universal central extension then $ker(\pi)$ is called
the \emph{Schur multiplier}.
\begin{quote}
\emph{Proof:}  $\rightarrow$ is easy.  For the converse, suppose $G$ is perfect
$g \mapsto {\overline g}$ is a bijection, $F$ the free group on the symbols of $G$,
$\Gamma= \{ {\overline x} {\overline y} {\overline x}^{-1} {\overline y}^{-1}$.
$M= \langle \Gamma \rangle \lhd F$, $\Delta= \{ [w,z], w \in \Gamma, z \in G \}$,
$N= \langle \Delta \rangle \lhd F$.
$N=[M,F] \lhd M$, $M/N \le {\mathbb Z}(F/N)$.. $\exists \pi: F/N \rightarrow G$
$\pi({\overline x}N)= x$, $ker(\pi) \le {\mathbb Z}(F/N)$.  Now let $H, \sigma$ be any
central extension.  $w= h(x) h(y) H(xy)^{-1} \in ker(\sigma)$.  $ker(\sigma) \le C_H(h(z))$
and $[w,h(z)]=1$.  $\tilde{G} =(F/N)'$ and $F/N = ker(\pi) \tilde{G}$; further,
$\tilde{G}' = \tilde{G}$.  $(\tilde{G}, \pi)$ is a universal central extension.
\end{quote}
{\bf Note:} Quasisimple groups are exactly the central extensions of simple groups.
$H_2(G,{\mathbb Z}) = {\frac {(R \cap F')} {[F,R]}}$, further, if $Q$ is
perfect then  $F'/[F,R]$ is a cover of $Q$. $SL_k(p)$ is a central extension of
$PSL_k(p)$.
\\
\\
{\bf Theorem 15:}
Let $(H, \alpha)$ be a central extension of a group $G$ and $(K, \beta)$ is a perfect
central extension of $H$ then $(K, \alpha \beta )$ is a perfect central extension of
$G$.
\begin{quote}
\emph{Proof:}
$\alpha \beta : K \rightarrow G$ is surjective.  Let $x \in ker(\alpha \beta)$ and
$y \in K$.  $\beta(x) \in ker( \alpha ) {\mathbb Z}(H)$, so
$\beta([x,y]) = [\beta(x), \beta(y)] =1$ and $[x,y] \in ker ( \beta ) \le {\mathbb Z}(K)$.
Thus $[ker( \alpha \beta ), K, K] = 1$ so $ker( \alpha \beta ) \le  {\mathbb Z}(K)$.
\end{quote}
{\bf Theorem 16:}
Let $(H, \alpha)$ and $(K, \beta)$ be central extensions of $G$ with $K$ with
$K$ perfect and $\gamma: (H, \alpha) \rightarrow (K, \beta)$ a morphism of central
extensions, then $(H, \alpha)$ is a central extension of $K$.
central extension of $H$ then $(K, \beta \alpha)$ is a perfect central extension of
\begin{quote}
\emph{Proof:}
$\gamma: H \rightarrow K$ is a homomorphism with $\alpha = \beta \gamma$.
$ker( \gamma ) \le {\mathbb Z}(H)$ so all we have to show is that $\alpha$ is surjective.
$K= \gamma (H) ker( \beta )$.  $ker( \beta ) \le {\mathbb Z}(H)$,
$\gamma(H) \lhd K$ and $K/ {\mathbb Z}(H)$ is abelian and thus $K= \gamma(H)$ is perfect.
\end{quote}
{\bf Theorem 17:}
Let $\tilde{G}$ be the covering group of a perfect group $G$ and let $(H, \alpha)$ be
a perfect central extension of $\tilde{G}$, then $\alpha$ is an isomorphism.
\begin{quote}
\emph{Proof:}
$\pi : \tilde{G} \rightarrow G$ be the universal covering.  By previous result,
$H( \pi \alpha)$ is a perfect central extension of $G$.  By universality,
$\exists \beta: ( \tilde{G}, \pi) \rightarrow (H, \pi \alpha )$.  By uniqueness,
$\pi \alpha \beta = \pi$, $\alpha \beta = 1$ and $\beta: \tilde{G} \rightarrow H$ is
an injection.  By previous result, $\beta$ is surjective.  Thus $\beta$ is an isomorphism,
$\alpha \beta = 1$, $\alpha = \beta^{-1}$ is an isomorphism too.
\end{quote}
{\bf Theorem 18:}
Let $G$ be perfect and $(\tilde{G}, \pi)$ the universal central extension of $G$ and
$(H, \sigma)$ a perfect central extension of $G$.  Then:
(1) There exists a covering $\alpha: \tilde{G} \rightarrow H$ with $\pi = \alpha \sigma$;
(2) $(\tilde{G}, \alpha)$ is the universal central extension of $H$;
(3) The Schur multiplier of $H$ is a subgroup of the Schur multiplier of $G$;
(4) if ${\mathbb Z}(G)=1$ then ${\mathbb Z}(\tilde{G})$ is the Schur multiplier of $G$
and ${\mathbb Z}(H) \cong ker(\pi)/ker(\alpha)$ is the quotient of the Schur multiplpier of
$G$ by the Schur multiplier of $H$.
\begin{quote}
\emph{Proof:}
By the universal property, $\exists \alpha: (\tilde{G}, \pi) \rightarrow (H, \sigma)$.
$\alpha$ is a covering by previous result.  Let $(\tilde{H}, \beta )$ be the universal covering
of $H$.  By the universal property,
$\exists \gamma: (\tilde{H}, \beta ) \rightarrow (\tilde{G}, \alpha)$.  By previous result,
$\gamma$ is an isomorphism so (2) holds.  (3) and (4) are routine.
\end{quote}
{\bf Theorem 19:}
Let $G$ be a group with $G/{\mathbb Z}(G)$ finite then $G'$ is finite.
\begin{quote}
\emph{Proof:}
Let $n=|G/{\mathbb Z}(G)|$, $z \in {\mathbb Z}(G)$, $g, h \in G$.
$[g, hz]= [g,h]= [gz, h]$ so the set $\Delta$ of commutators has order $\le n^2$.
\\
\emph{Claim:} If $g \in G'$ then $g= x_1 x_2 \ldots x_m$, $x_i \in \Delta$ then $m \le n^3$.
This and the previous statement proves the theorem.
\\
\emph{Proof of Claim:} Pick expression of minimal length, $m$.  If $m > n^3$ then,
since $|\Delta| \le n^2$, $\exists d \in \Delta$ with $\Gamma= \{i: x_i=d \}$
of order $k > n$.
$x_i x_{i+1}= x_{i+1} x_i^{x_{i+1}}$
$x_i^{x_{i+1}} \in \Delta$ and $\Gamma= \{ 1 \le i \le n \}$.
Now it STS, $d^{n+1}$ is  a product of $n$ commutators which contradicts the minimality of
$m$.  Let $d= [x,y]$, $|G/{\mathbb Z}(G)|=n$, $d^n \in {\mathbb Z}(G)$ so
$d^{n+1}= (d^n)^x d= (d^{n-1})^x d^x d = (d^x)^{n-1} [x^2 , y]$ so $d$ is a product of $n$
 commutators.
\end{quote}
{\bf Theorem 20:}
Let $G$ be a perfect finite group then the universal covering group of $G$ and the Schur
multiplier are both finite.
\begin{quote}
\emph{Proof:}
Follows from previous result.
\end{quote}
{\bf Theorem 21:}
Let $(H, \sigma)$ be a perfect central extension of a finite group, $G$,
and $M$ the Schur multiplier of $G$, $p$,
a prime and $P \in S_p(H)$ then $P \cap ker(\sigma) \le \Phi(P)$.
\begin{quote}
\emph{Proof:}
By looking at $H / (\Phi(P) \cap ker( \sigma )$, we can assume $\Phi(P) ker( \sigma )=1$
and show $X= P \cap ker( \sigma ) = 1$.  ${\overline P}= P/\Phi(P)$ is elementary
abelian so $\exists {\overline Y}: {\overline Y} {\overline X}= {\overline P}$,
$P = X \times Y$ and $P$ splits by Gaschutz, $H$ splits over $X$ hence, $H$ is perfect,
$X \le {\mathbb Z}(H)$, $X=1$.
\end{quote}
{\bf Theorem 22:}
Let $(H, \sigma)$ be a perfect finite group and $M$ the Schur multiplier of $G$,
then $\pi(M) \subseteq \pi(G)$.
\begin{quote}
\emph{Proof:}
Follows from previous result.
\end{quote}
{\bf Homological version:} If $G>N$
and $H>K$ are normal subgroups isomorphic under $\phi$, the pullback
is $(g, h)$ where $gN= \phi(hK)$.
$(Q, K, \theta)$ is trivial iff every extension realizing $(Q, K, \theta)$
is a central extension.  There's a bijection between $H^2 (Q, K, \theta)$
and central extensions.
\\
\\
{\bf Theorem 23:}
Assume $G$ is perfect then a central extension
$(E, \phi)$ of $G$ is universal iff (a) $E$ is perfect and (b) all
central extensions of $E$ are trivial. In that case,
$1 \rightarrow R \rightarrow F \rightarrow G \rightarrow 1$, $F$, free and
$E= [F,F][F,R] \rightarrow [F,F]/R=G$.
\begin{quote}
\end{quote}


\documentclass{article}

\usepackage{siunitx,amsmath,amssymb}

\title{Elastic Properties of Mountains}
\author{Matthias J. Raives}

\begin{document}

  \maketitle{}

  \section{Elastic Limit of Rock}
  The simplest theory of mountains suggests that the maximum height is the height that makes the pressure at the base of the mountain equal to the elastic limit---if the mountain is taller than this, then the base will deform inelastically and the mountain will sink.  This sets a limit:
  \begin{equation}
    P =\rho g h\\
  \end{equation}
  where $P$ is the elastic limit of the rock, measured in pressure units.  Mount Everest has a height of about \SI{8}{\km}, and rock has a density of about \SI{3}{\gram\per\cm\cubed}.  Thus, the elastic limit of rock is:
  \begin{equation}
    P = \SI{2.4e8}{\Pa} = \SI{2.4e9}{dyne\per\cm\squared}
  \end{equation}
  \section{Mars' Mons}
  Applying this limit to other solar system bodies, we could write a scaling relation
  \begin{align}
    h_{\max} &= \SI{8}{\km}\;\left(\frac{g}{\SI{e3}{\cm\per\second\squared}}\right)^{-1}\\
    h_{\max} &= \SI{8}{\km}\;\left(\frac{M}{M_{\oplus}}\right)^{-1}\left(\frac{R}{R_{\oplus}}\right)^{2}
  \end{align}
  Mars has a mass $M_{\mathrm{Mars}}\sim0.1{M_{\oplus}}$ and a radius $R_{\mathrm{Mars}}\sim0.5R_{\oplus}$, thus implying:
  \begin{equation}
    h_{\max} = \SI{20}{\km}
  \end{equation}
  which is pretty close to the actual height of Olympus Mons $(\sim\SI{25}{\km})$
  \section{Spherical Bodies}
  We can consider an aspherical asteroid as a spherical one with a really large mountain, of height comparable to the asteroid's radius, on one side.  Again, scaling to mountains on Earth:
  \begin{align}
    g_{\oplus}h_{\max,\oplus} &= g(R)R\\
    \frac{GM(R_{\oplus})}{R_{\oplus}^{2}}h_{\max,\oplus} &= \frac{GM(R)}{R}\\
    \frac{4\pi\rho R_{\oplus}}{3}h_{\max,\oplus} &= \frac{4\pi}{3}\rho R^{2}\\
    R &= \sqrt{R_{\oplus}h_{\max,\oplus}}\\
    R &\sim \SI{230}{\km}
  \end{align}

\end{document}


% !TeX root = ./main.tex
% chktex-file 46
% !TeX spellcheck = en-GB
% !TeX encoding = utf8

\section{Consistency of notations}%
\label{sec:consistency}

Using the notation from the blog and the paper, including $H'\in\mathbb{R}^{N\times D}$, $A\in\mathbb{R}^{N\times N}$, $H\in\mathbb{R}^{N\times D}$, the propagation rule is:

\begin{equation}
	H' = A H
\end{equation}

is equivalent to

\begin{equation}
	\begin{split}
		H'_{v_i, m} & = \sum_l \overbrace{A_{v_i, l}}^{\in \{0, 1\}} H_{l, m} \\
		            & = \sum_{l'} H_{l',m}
	\end{split}
\end{equation}

where $l'$ takes all $A_{v_i,l}=1$, i.e.\ neighbours, into account.

Hence, I do understand that the notations are equal.

\section{Formulate normalisation}

Use from ICLR 2017 paper the normalisation $D_{ii} = \sum_j \hat{A}_{ij}$.

Use the knowledge from the blog post to write:

\begin{equation}
	\begin{split}
		\overbrace{H'}^{\in \mathbb{R}^{N\times D}} & = \overbrace{D^{-1}}^{\in\mathbb{R}^{N\times N}} \overbrace{\hat{A}}^{\in \mathbb{R}^{N\times N}} \overbrace{H}^{\in\mathbb{R}^{N\times D}} \\
		\Leftrightarrow H'_{v_i, m} & = \sum_k \overbrace{D^{-1}_{v_i,k}}^{=D_{v_i,v_i}, \delta_{v_i, k}} {(\hat{A} H)}_{km} \\
			& = D^{-1}_{v_i, v_i} {(\hat{A} H)}_{v_i, m} \\
			& = D^{-1}_{{v}_i, v_i} \sum_k \hat{A}_{v_i, k} H_{k, m} \\
			& = \sum_k \underbrace{\frac{\hat{A}_{v_i, k}}{\sum_j \hat{A}_{v_i, j}}}_{\text{normalised}} H_{k, m}.
	\end{split}
\end{equation}

The weighting by the adjacency matrix is, indeed, normalised to its column sums.

Note that this part is also normalised:

\begin{equation}
\begin{split}
	\sum_m H'_{v_i, m} & = \sum_m \sum_k \frac{\hat{A}_{v_i, k}}{\sum_j \hat{A}_{v_i, j}} H_{k, m} \\
	& = \sum_k \frac{\hat{A}_{v_i, k}}{\sum_j \hat{A}_{v_i, j}} \underbrace{\sum_m H_{k,m}}_{=1\text{, per construction}} \\
	& = 1
\end{split}
\end{equation}

\newpage
\raggedright{}
\bibliography{bibliography}


\chapter{Bag of Words}

\newthought{Every machine learning needs numbers, but all we have is text.} A simple way to convert documents into numeric vectors is to \dots well, count the words in each text.

\begin{center}
    \begin{tabular}{c|c|c|c|c|c|c}
    Document & this & is & an & example & another & apple \\
    \hline
    \emph{This is an example} & 1 & 1 & 1 & 1 & 0 & 0 \\
    \emph{Another example} & 0 & 0 & 0 & 1 & 1 & 0 \\
    \emph{This is another apple} & 1 & 1 & 0 & 0 & 1 & 1
    \end{tabular}
\end{center}

\widget{Bag of Words} creates a table with words in columns and documents in rows. Values are word frequencies in each document.

\begin{wrapfigure}{o}{0.6\textwidth}
    \includegraphics[scale=0.5]{bag-of-words.png}
    \caption{$\;$}
\end{wrapfigure}

We can simply count the words (TF or term frequency) or weigh the words according to how often they appear in the documents (IDF or inverse document frequency). Using TF-IDF, common words will have a low value as they appear across most documents, while significant words will have a high value because they appear frequently in a small number of documents.

Pass the data through a \widget{Bag of Words} widget and then again to a \widget{Data Table}. We get a new column that contains word counts for each document. Now that we have numbers, we can finally perform some magic!

\vspace{-0.2cm}
\begin{figure}[h]
  \centering
  \includegraphics[width=\linewidth]{workflow.png}%
  \caption{$\;$}
\end{figure}
\vspace{-0.3cm}

\vspace{-0.2cm}
\begin{figure}[h]
  \centering
  \includegraphics[width=1.2\linewidth]{data-table.png}%
  \caption{$\;$}
\end{figure}
\vspace{-0.3cm}