# Module GBF

`module GBF: `sig  end``
The Group Based Field collection

` 'smith : `gbf -> seq``
Returns the sequence of integer coefficients of the smith normal form of the GBF type of the argument. An `undef` value is returned if the argument is not a `GBF`.

This sequence describes the canonical isomorphic Z-module used to represent the elements of the group `G3`. A coefficient `1` means that the corresponding generator is free (i.e. the corresponding subgroup is isomorphic to Z). A coffecient n means that the corresponding generator is cyclic (i.e. the corresponding subgroup is isomorphic to Z/nZ).

For example, given the GBF declaration

`` gbf G3 = < a, b, c; 10 b, 33 c > ``
the expression `smith(G3:())` returns the sequence
``(1, 330):'seq``
which means that the group structure of `G3` is isomorphic to Z`x`Z/330Z. The interpretation is the following: generator `a` is mapped to Z and the subgroup spanned by `b` and `c` is mapped to Z/330Z (note that `330 = 10 * 33`).
` 'smith_backpos : `posgbf -> seq``
Inverse of the `'smith` function.

!!! Not yet correctly implemented !!!
See : smith

` 'following : `seq -> posgbf -> gbf``
`seq -> seq -> gbf `

Build a GBF from a sequence of values and a sequence of directions.

`l following d` is the infix form of `'following(l, d)` (note that the unquoted name is a keyword and cannot be used as an identifier). This expression builds a GBF by enumeration: the values are given in the nested sequence `l` and the direction of the enumeration are given in the sequence of direction `d`.

Suppose that there are two directions `d1` and `d2` in the directions list: `D == d1, d2`. Then, the sequence of values must be a sequence of sequences of elements ```l == ((L00, L01, L02)::(L10, L11, L12, L13)::(L20, L21)::seq:())```. Then, the expression `l following d` builds a GBF `g` that is build in the following manner: the value `Lij` becomes the value of position `i*D1 + j*D2`. And more generally, `Lij...k` becomes the value of position `i*D1 + j*D2 + ... + k*Dn`.

Perhaps a better explanation is given considering a path: the directions list specifies a path starting from the position `0` and the values in the first argument of the following becomes the values of the positions crossed along this path. The direction `Di` are followed for each element in the list or each time we go from a sublist to another sublist. For our example,

• we start from the position `0` (called the initial starting point) and we give the value `L00` to this position,
• we move towards the direction `d1` and give to the current position the value `L01`,
• we continue this way, until we reach the end of the sublist.
• Then, jump to our initial position `0` and we move following `d2`. This point becomes the new starting point.
• We repeat the previous procedure again, that is, the current position takes the value `L10`, we move following `d1`, the current position takes the value `L11`, etc.
• At the end of the current sublist, we move to our current starting point and we move again following `d2` to obtain our new starting point. And we proceed to affect the values of sublist `l2x`.
• And so on, until the exhaustion of the sequences of values.
More formally,
Example :Suppose we have defined a GBF `gbf GG = <X, Y>`, then
``(a, a, a) :: (b, b) :: (c, c, c, c) :: seq:() following  |X>, |Y>``
returns the GBF
``a, a, a``
``b, b``
``c, c, c, c``
(we assume that the `|X>` dimension is mapped horizontally and `|Y>` is mapped vertically).