{'fraction_non_alphanumeric': 0.029727176751680837, 'fraction_numerical': 0.010890704006223259, 'mean_word_length': 4.610349127182045, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
The Geometry of Niggli Reduction II: BGAOL -- Embedding Niggli Reduction

Niggli reduction can be viewed as a series of operations in a six-dimensional space derived from the metric tensor. An implicit embedding of the space of Niggli-reduced cells in a higher dimensional space to facilitate calculation of distances between cells is described. This distance metric is used to create a program, BGAOL, for Bravais lattice determination. Results from BGAOL are compared to the results from other metric-based Bravais lattice determination algorithms.


Introduction
BGAOL (Bravais General Analysis of Lattices) is a Bravais lattice identification program based on the G 6 analysis of Niggli reduction described in the first paper of this series [2]. Niggli reduction defines a complex space that has not previously been fully analyzed. Several authors have published interesting commentaries on the properties [10] [18] [7]. These studies use the space G 6 [4], or a similar metric-tensor-based space, or a projection of G 6 to a space of lower dimensionality, respectively. Two principal uses of Niggli reduction are the determination of Bravais lattice type and the construction of databases using a representation of the unit cell for the key [3] [22] [6].
Both uses can be viewed as distance determinations in G 6 . In the former case the distances to the Bravais lattice subspaces are used, and in the latter case the distances between pairs of unit cells are used. However, the complexity of the space has consequences in some regions; it is not adequate to consider only one representation of a unit cell in G 6 . A standard mathematical solution is to create an "embedding" [16] of the space with an appropriate associated metric. In such an embedding, separate regions of the space under consideration are sewn together into a single fundamental region preserving distances from the original piecewise presentation.
In the case being considered the regions contain sets of cells that appear to be far apart originally but which can be seen to represent similar lattices as the regions are sewn together and sets of cells that remain far apart after the sewing can be seen not to represent similar lattices. In concept, this is similar to what we do in folding of atomic coordinates into the asymmetric unit of a crystal. This is an example of a simple embedding, allowing us to see which atoms interact. This is the approach followed in BGAOL.
In order to define an embedding, the operations defining the fundamental region must be specified. In the case of Niggli reduction, the complete space is G 6 , and the fundamental region is the fraction of the space containing only Niggli-reduced cells. Proper unit cells in any other region of G 6 can be transformed into the fundamental region by the rules of Niggli reduction. The transformations at the boundaries must be enumerated and their combinations analyzed [2]. See Table 1.
Given the complete set of conditions that define all boundaries of the fundamental unit and their relationships to adjacent units, the transformations of coordinates on crossing the boundaries are enumerated. [18] has enumerated transformations in a related space.

Background
Crystallography began with the study of crystal morphology and the classification of substances by the shapes of their crystals, a database concept before the creation of databases. Von Laue [23] provided an accessible description. In the present context, two themes have developed: Bravais lattice assignment and database searches to identify substances by their unit cell parameters.

Bravais Lattice Assignment
Modern work on Bravais lattice assignment has taken two directions: qualitative absolute assignment of lattice type versus quantitative assignment using a metric to measure the distance from the 14 Bravais lattice types. This is a fuzzy distinction because all methods are fundamentally quantitative, being rooted in numeric cell parameters. The advantage of the methods based on, and making full use of, a metric is that they perform well in the presence of experimental error. The more fine-grained the metric used, the more easily and efficiently can the alternatives be ranked. Gruber's work [7] is the latest in qualitative assignment of lattice types. DELOS [25] is a popular example of a rather coarse-grained metric. Kabsch has incorporated a fine-grained metric in XDS [11] [12] based on the sum of the magnitudes of deviations from the various Niggli reduction conditions. See [14] for a reasonably complete review of the relevant literature.
The use of a fine-grained metric under which it is meaningful to ask precisely how far a probe cell is from a given lattice and to compare that distance to the experimental error began with [4], in which the space G 6 , consisting of vectors (a modified metric tensor), was introduced. The concept is simple, but the implementation is complex because a very large number of iterations may be necessary to apply the boundary transformations of the Niggli cone. BLAF [14] and OT-BLD [18] cut off the iterations, creating the possibility of missed symmetries. The implementation of [4], ITERATE, continues without a cutoff until no new candidates are found, to avoid missed symmetries but at the expense of additional execution time. BGAOL resolves this conflict by specifically using the 15 5-D boundaries cited in [2] labelled 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, from which the many remaining internal boundaries of the Niggli cone may be derived as intersections, and by using an isometric embedding that sharply limits the boundary transforms to be applied to the ones directly involved with those 15 5-D boundaries, plus three of the 4-D boundaries (8F, BF and EF) in the negative portion of the Niggli cone and two boundaries (69 and 6C) in the positive portion of the Niggli cone that contains the images of 8F, BF and EF under their boundary transforms.

Database Searches
For Niggli reduced cells, the last three elements of the G 6 vector are highly unstable under small perturbations of the cell parameters [3]. That is why many iterations have been needed in robust lattice identification. The highly iterative nature of prior uses of the G 6 metric along with a lack of clearly defined stopping criteria creates a significant burden for application to cell databases. One feasible approach with an easier-to-compute metric has been to use perturbationstable subsets of the cell parameters, such as the edge lengths and the volume, as in the JCDPS database originally distributed on cards in the 1930s [24]. This approach proved insufficiently selective as the number of solved structures grew. [3] added the reduced reciprocal cell edge lengths to the search key, and that approach was also successfully implemented by [5] [17] [20] [6] [22]. This metric, however, is very non-linear in comparison to the G 6 metric. A database search based on the combinatorial approach in [4] is used in WebCSD [21]. A "Nearest Cell" search based on 3-D unit cell vectors can be found in [19]. The G 6 embedding can have a significant impact on such searches. In addition, it is helpful in the context of databases to linearize and scale theÅngstroms squared distance of G 6 to linearÅngstroms. This will be discussed in a subsequent paper in this series [15].

Embeddings
The problem of finding how far cells in the Niggli cone are from other cells in the Niggli cone is similar to the problem of finding the distance between atoms in a crystal, where the shortest distance may not be the distance within the asymmetric unit of the chosen cell. For example in Fig. ??, two atoms, A and B, are shown in the asymmetric unit of a cell chosen from a two-dimensional lattice, with symmetry-related copies of those atoms in neighboring cells. In this case, a symmetry-related copy of B is closer to A (shown with a solid black line) than is the original B in the same asymmetric unit. An alternative to searching through neighboring cells in two dimensions would be to pick up the matching left and right edges of the cell and glue them together to form a tube, and then bend the tube to glue the remaining edges together to form a torus. Then we can navigate between points on the surface of the torus looking for the shortest distance. In that representation of this cell, the shortest path from A to B is the three pieces shown in Fig. ?? as the bold black segments 1, 2 and 3. Even though they appear to be disjoint in the two-dimensional representation, they are contiguous in the embedding. This process of picking up a lower-dimensional manifold in which we know the geometry in Euclidean patches and gluing the edges of the patches together to form a closed surface in a higher-dimensional space but with the same distances between points is called an isometric embedding. "All" we need to know is the distance function on that embedded surface.
Embedding the Niggli cone in G 6 into a higher-dimensional space is, as one might expect, more complicated than embedding a three-dimensional lattice as a torus-like object into a six-dimensional space. In addition to having more dimensions, the symmetry operations generated by the boundary transformations in Table 1 are not, in general, isometric. The face-diagonal and body-diagonal boundary transformations significantly compress space in some directions and expand it in others. In measuring the distance between cells in the Niggli cone, we always have to measure distances between representatives of cells within the Niggli cone and not even between a representative in the cone and one outside. We can, however, safely "unroll" the cone into multiple images using the equal-cell-edge and ninety-degree boundary transforms and then measure distances among those cell representatives because the associated transforms for those boundaries are isometric. The non-isometric boundary transforms have anisotropic expansions and contractions, ranging from an expansion by a factor of nearly 3.6 in one direction and a contraction by a factor of less than 0.28 in another direction for the G 6 vectors (corresponding to an expansion factor of nearly 1.9 and a contraction factor of less than 0.53 for the R 3 cells) for the body-diagonal boundary transform. For the face-diagonal boundaries the corresponding expansions and contractions are 2.8 and .36 for the G 6 vectors (corresponding to expansions and contractions of nearly 1.7 and less than 0.6 for the R 3 cells). The face-diagonal and body-diagonal boundary transforms act like folds around special position subspaces of the boundary manifolds, forming cones rather than tori in an embedding, with no impact from the metric distortions on the boundary manifolds themselves. However, if we step past those boundaries into the surrounding G 6 environment, the effect of those metric distortions is very much like looking through glass of a high anisotropic refractive index thereby potentially creating a very large number of distorted images of the distances within the Niggli cone. Using the embedding and confining distance measurements to those entirely within the cone greatly reduces this computationally expensive effect and the need for inappropriately early terminations of iterations.

The BGAOL Embedding Distance
There are two ways in which to compute an embedded distance. In the first way, one maps the lower-dimensional space into a higher-dimensional space and computes distances along the resulting curved surface using the coordinate system of the higher-dimensional space, much as one computes spherical distances on the surface of the earth to determine the distance between cities [1]. In the second way, one uses the coordinate system of the lower-dimensional space and computes distances in those terms, using the rules of the embedding to join patches together [8]. Both approaches can involve comparisons among multiple alternate distances, just as one might have to compare going east versus going west in deciding on the shortest distance between New York, USA and Sydney, Australia. In BGAOL, we chose to work with the coordinate system in G 6 rather than with curvilinear coordinates in a higher-dimensional space.
The program BGAOL computes the embedded distance between G 6 vectors v 1 and v 2 , which must both be within the Niggli cone. This restriction is important because the boundary transformations are not isometric and have significant anisotropies, causing the regions outside the Niggli cone to be viewed as if through glass of anisoropic refractive index. The distances are computed from the G 6 coordinates as follows.
• 2. For each of the 48 resulting cells from step 1, compute the distances to and projections onto to each of the 15 5-D Niggli cone boundaries. • 7. For each member of each set of permutations, compute the distance from each permutation to each of the face-diagonal and body-diagonal boundary manifolds. The face-diagonal boundaries are grouped together as three cases (6-7-8, 9-A-B, C-D-E), with two subcases each. In the first three cases these are the full five-dimensional boundaries, and in the subcases these are the four-dimensional boundaries produced by the intersections with the body-diagonal boundary manifold (8F, BF, EF).
• 8. For each face-diagonal or body-diagonal boundary manifold, Γ , consider a member w 1 from the first set of permutations and w 2 from the second set of permutations. Let h 1 be the distance from w 1 to Γ and h 2 be the distance from w 2 to Γ .
• 9. If h 1 + h 2 is less than the minimum distance already found, let P Γ w 1 be the projection of w 1 onto Γ and M Γ P Γ w 1 be the image of that projection under the boundary transformation and let P Γ w 2 be the projection of w 2 onto Γ and M Γ P Γ w 2 be the image of that projection under the boundary transformation. For the 8F, BF and EF four-dimensional boundaries, use the transformations for the corresponding face-diagonal boundaries (M 8 , M F , M E ). Compare the minimum distance thus far to and keep the smaller value.
The raw distance in G 6 is not sufficient for comparison of lattices of different symmetries and does not consider distances in relationship to the size of experimental errors. The anorthic lattices have the full six degrees of freedom of the space, monoclinic have four, orthorhombic have three, hexagonal and tetragonal have two and cubic have one. Multiplying the reported G 6 distances by the square root of the number of degrees of freedom provides a better comparision among possible lattices. If we then divide by the G 6 experimental error estimate, we get a dimensionless "Z-score".
Computationally, the multiplicities of the combinations used is lower than one might expect because of constant pruning by comparing the distance computed at each stage to the distance to the boundary under consideration. If the boundary distance, which was precomputed in step 2 or 3 is larger than the previously computed minimum distance between cells, there is no need to compute path lengths that include that boundary distance.

Implementation of the embedding
BGAOL is a modification of our earlier, iteration-based program ITERATE [4] using embeddingbased distances to search for likely Bravais lattice matches. The only other lattice matching programs that we know of that use a metric are BLAF [14], DELOS [25], XDS [12] and OT-BLD, the lattice matching part of CONOGRAPH [18]. BLAF uses an L 1 measure on the metric tensor, while ITERATE and BGAOL use an L 2 measure. DELOS uses a coarse measure based on "cycles". OT-BLD reports matches using a fractional measure, also based on the metric tensor. XDS uses a "quality index" based on the sum of the extents to which the inequalities of Niggli reduction are not satisfied for components of the metric tensor, essentially an L 1 measure of the distance from each Niggli-cone boundary polytope. Table 2 shows a comparison of BGAOL results to other programs, except XDS. Table 2 shows a comparison of the BGAOL Z-score to the XDS quality indicator.

Distance calculation
BGAOL distances are calculated using the function NCDIST, which computes the distance between pairs of reduced cells. Bravais lattice determination for a given probe cell consists of finding which boundary polytopes of the Niggli cone are closest to the probe. Constructing and using a cell database requires computing the distance between cells as points in G 6 that are arbitrarily far apart. Figure 2 illustrates the use of NCDIST to compute distances between well-separated points.

Availability and Test Results
A BGAOL-based lattice identification web server is available at http://www.bernstein-plus-sons/software/BGAOL/ A source kit may also be downloaded from a link on that page.
The prior ITERATE-based lattice identification web server is available at http://www.bernstein-plus-sons.com/software/ITERATE/ The latest version of the source code of BGAOL is maintained on SourceForge for svn access at svn checkout svn://svn.code.sf.net/p/iterate/code/trunk/bgaol bgaol-code.

IMPLEMENTATION OF THE EMBEDDING
The source kit contains the test program, Follower.for, that computes the distance for database work as shown in Fig. 2. The database code that will be discussed in a subsequent paper is available from the "sauc" module in the same repository. Table 1: Fifteen 5-D boundary polytopes of Niggli-reduced cells in G 6 . For a given boundary polytope Γ , the column "Condition" gives the G 6 constraints (prior to closure) of the boundary polytope. Boundary polytopes 1 and 2 apply in both the all acute (+ + +) and all obtuse (− − −) branches of the Niggli-reduced cone. Boundary polytopes 8, B, E and F are restricted to the all obtuse (− − −) branch of the Niggli-reduced cone, N . Boundary polytopes 6, 7, 9, A, C and D are restricted to the all acute (+ + +) branch of N . Boundary polytopes 3, 4 and 5 are boundaries of both the all acute (+ + +) and all obtuse (− − −) branches.