Satins, lattices, and extended Euclid's algorithm

Motivated by the design of satins with draft of period m and step a, we draw our attention to the lattices L(m,a)=⟨(1,a),(0,m)⟩\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$L(m,a)=\langle (1,a),(0,m)\rangle$$\end{document} where 1≤a<m\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1\le a<m$$\end{document} are integers with gcd(m,a)=1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\gcd (m,a)=1$$\end{document}. We show that the extended Euclid's algorithm applied to m and a produces a shortest no null vector of L(m, a) and that the algorithm can be used to find an optimal basis of L(m, a). We also analyze square and symmetric satins. For square satins, the extended Euclid's algorithm produces directly the two vectors of an optimal basis. It is known that symmetric satins have either a rectangular or a rombal basis; rectangular basis are optimal, but rombal basis are not always optimal. In both cases, we give the optimal basis directly in terms of m and a.


Introduction
A fabric consists in two sets of threads in perpendicular directions, called warp and weft (or woof). The traditional way to represent it is by the tiling of the plane by unit squares. Each vertical strip represents a thread of the warp and each horizontal strip a thread of the weft. Thus, each unit square represents the crossing of a warp-thread and a weft-thread. If the warp-thread pass over the weft thread, then the corresponding square is colored black; otherwise it is colored white. A way to design a fabric is to take a squared pattern of m × m unit squares, called the draft or the design, color each unit square black or white, and repeat it to tiling the plane. To obtain a fabric, 1 3 all the threads must hang together, so in each column and row of the draft there must be some black and some white squares.
There are a few attempts to study the mathematics of fabric designs. We can cite a six-pages paper by Shorter [13] in 1920, a series of four papers by Woods [14][15][16][17] in 1935 and 1936, the papers by Grünbaum and Shephard [6,7] in 1980 and 1986, and an article by Crowe [2] in 1986 about the work of Woods. In almost all the cases the main interest is the symmetry group of the fabric.
A satin or sateen is the following special class of fabrics. Take a draft of size m (that means a square of m × m of unit squares) and label columns and rows from 0 to m − 1 . Then take an integer a ∈ {1, … , m − 1} with gcd(m, a) = 1 , and color black the square (v, r) in column v and row r if and only if av ≡ r (mod m) . Note that, in this way, each column of the draft has exactly one black square, and the same for each row. The integer m is called the period, and the integer a the step of the satin. When the draft is extended to cover the plane, we also have that a unit square with coordinates (v, r) is black if and only if av ≡ r (mod m) . The case m = 2 and a = 1 is called plain or calico and, for m ≥ 3 , the case a = 1 is called direct twill, and the case a = m − 1 indirect twill (often plain and twills are not considered as particular cases of satins, but different from satins). Figure 1 shows the drafts of the satin of period m = 11 and step a = 4 , of the plain satin, and of the twills of period 4. The bottom rows from left to right represent the crossing of the weaf 0 with the warps 0, 1, … , m − 1 , and the first column from bottom to top the crossing of warp 0 with the weafs 0, 1, … , m − 1.
Probably the first in considering the design of satins from a mathematical point of view was Édouard Lucas [9] in 1867, motivated by two articles of the same year by the industrial Édouard Gand [4,5]. After that, Lucas insisted in the topic with an article and an appendix in an Italian specialized industrial journal [10,11]. The main interest of Lucas was to characterize periods and steps that produce satins considered of great quality: square and symmetric satins, which are those such that a 2 + 1 ≡ 0 (mod m) , and a 2 − 1 ≡ 0 (mod m) , respectively; this is to say to find periods m and steps a such that a has quadratic residue −1 or +1 modulus m.
Instead of the traditional representation by squares, we shall use coordinates; this is not usual in the context of fabrics, but an early precedent is Cerruti [1]. We identify the satin of size m and step a with the set In fact, this set is a lattice: Satins, lattices, and extended Euclid's algorithm From now on, we identify a satin of period m and step a with the lattice A satin can be defined by its draft, but considered as a lattice, can be defined by a basis. It is natural to ask for the optimal basis; that is, a basis with the vectors as short as possible. An optimal basis can be obtained by the Lagrange-Gauss lattice basis-reduction algorithm.
Our goal is to relate the study of optimal basis in satin lattices L(m, a) to the extended Euclid's algorithm applied to m and a. The paper is organized as follows.
In Sects. 2 and 3, we summarize basic properties of the extended Euclid's algorithm, and recall the Lagrange-Gauss algorithm for finding optimal basis; we apply it to obtain optimal basis of twills. In Sect. 4 we show how the extended Euclid's algorithm gives different basis of L(m, a), and it always gives the shortest vector. Moreover, if the algorithm does not gives an optimal basis directly, then in just one step the Lagrange-Gauss algorithm finds the optimal basis. For square and symmetric satins, the extended Euclid's algorithm gives some additional information. In Sect. 5, we show that the algorithm always gives an optimal basis for square satins. Finally, in Sect. 6, we apply the algorithm to symmetric satins and provide their classification into rectangular and rombal, showing how to compute an optimal basis directly from the values of the period and step. While a rectangular basis is always optimal, a rombal basis can be optimal or not. In the case of rombal satins, we give both, the optimal and the rombal basis.

Extended Euclid's algorithm
Let us recall some of the basic properties of the extended Euclid's algorithm.
Let 1 ≤ a < m be integers. Define by recursion the sequence r 0 = m , r 1 = a and, for i ≥ 1 and while r i ≠ 0 , let q i and r i+1 the quotient and the remainder of dividing r i−1 by r i . If r n+1 = 0 , we have and r n = gcd(m, a) . We also define, for i ∈ {1, … , n}, We shall denote the data of the extended Euclid's algorithm by The following properties are easily proved (most of them by induction) and almost all can be found in Shoup [12,Theorem 4.3].  The following property shall be useful to deal with square and symmetric satins. Proposition 2.1 Keep the above notations and assume that 1 ≤ a < m∕2 . For i ∈ {1, … , n} , the integers |v i−1 | and q i are the remainder and the quotient, respectively, of the division of |v i+1 | by |v i |.

Lagrange-Gauss algorithm
Let ∈ ℝ 2 and denote ⟨ ⟩ = { ∶ ∈ ℤ} . If and are two independent vectors of ℝ 2 , the lattice generated by and is the additive subgroup of ℝ 2 An optimal basis of a lattice L is a basis ( 1 , 2 ) such that for all ∈ L ⧵ { } one has: The vector 1 of an optimal basis ( 1 , 2 ) is called a shortest vector of L, and 2 a second shortest vector. Note that if 1 is a shortest vector, − 1 is a shortest vector too. Hence, we can always take a shortest vector with a no negative second coordinate.
An optimal basis of a lattice L = ⟨ , ⟩ can be found by using the Lagrange-Gauss algorithm. We refer, for instance, to Hoffstein and Pipper [8] or Galbraith [3] for more details. We denote ⌊ ⌉ = ⌊ + 1∕2⌋ the closest integer to the real number ; note that in case that z is an integer and = z + 1∕2 , then ⌊ ⌉ = z.

Remark 3.2
Suppose that ( , ) is a basis of a lattice L and that is a shortest vector of L. Then, the Lagrange-Gauss algorithm takes at most one step to find an optimal basis. Indeed, we calculate = ( ⋅ )∕‖ is an optimal basis of L.
As an immediate application of the algorithm, we consider the case of direct twills; that is, the satin lattices L(m, 1) with period m ≥ 3 and step a = 1 . (Observe that the plain satin L(2, 1) has optimal basis ((1, 1), (−1, 1)).
is an optimal basis of L(m, m − a) . In particular, as a consequence of Proposition 3.1, we have Satins, lattices, and extended Euclid's algorithm Proposition 3.2 An optimal basis of the indirect twill L(m, m − 1) of period m is given by:

Euclid's algorithm and the shortest vector
If 0 = |v| , then = (0, r) = x(0, m) + y(1, a) = (y, xm + ya) for some intergers x and y, which implies y = 0 and m > r = xm ≥ m , a contradiction. Hence, |v| > 0. If Next proposition is the adaptation to our context of the first part of the "Reconstruction Theorem" of Shoup [12,Theorem 4.9]. For the sake of completeness we include the proof, which is (almost) the same.

Proposition 4.2 Let L(m, a) be a satin, and let
The sequence r 0 = m, … , r n+1 = 0 is strictly decreasing. Hence j is a well defined integer and j ≥ 1.
The condition (v, r) ∈ L(m, a) means that um + av = r for some u ∈ ℤ . By Theo- Then, the numbers are integers. We have and, analogously, one has v j + v j−1 = v.
We have three possible cases. We shall see that in the first two we have |v| ≥ |v j | as required, and that the last one implies a contradiction.
◻ As a consequence, we have the following theorem.

Theorem 4.1 Let L(m, a) be a satin. Then, one of the vectors of E(m, a) is a shortest vector in L(m, a).
Proof Let = (v, r) be a shortest vector of L(m, a) with r ≥ 0 , and let 0 , … , n+1 be the vectors of E(m, a). From Lemma 4.1 we have r > 0 . By applying Proposition 4.2 to the vector = (v, r) , we have ‖ ‖ ≥ ‖ j ‖ for some j ∈ {0, … , n + 1} . As is a shortest vector, ‖ j ‖ ≥ ‖ ‖ . Thus, ‖ j ‖ = ‖ ‖ and j is a shortest vector. ◻ Theorem 4.1 does not explain when, in the execution of Euclid's algorithm, the shortest vector has been reached. The remainder of this section is devoted to precise which of the vectors of E(m, a) is the shortest.
Next proposition shows some useful properties of the vectors of E(m, a). a). Then, it holds:

Proposition 4.3 Let L(m, a) with m > 2 be a satin and let
Proof (i) By definition of i , one has (ii) By (i), the sequence of scalar products i−1 ⋅ i is strictly decreasing. Now, (iii) We have |v 0 | = 0 < m = r 0 and |v n+1 | = m > 0 = r n+1 . Moreover, the sequence (r i ) is strictly decreasing and the sequence (|v i |) is increasing. Hence, k = min{i ∶ |v i | > r i } is well defined and k ≥ 1.
By definition of k, we have |v k | > r k and |v k+1 | > r k+1 . Taking in account that v k v k+1 < 0 , it follows This implies − 1 ≤ k.
If < k , we have Then, it follows a contradiction. Therefore, k ≤ . So, we have , the scalar product i ⋅ i+1 is not negative and from the equality i−1 = q i i + i+1 it follows (v) and (vi) Suppose i ≥ . Since the scalar product i−1 ⋅ i is negative, from In the case (v) we have i ≥ k = , and in the case (vi) we have i ≥ k + 1 = . In both cases, the statement follows.
Satins, lattices, and extended Euclid's algorithm Then, 0 ≤ ≤ 1 and h ∈ {0, 1} . If h = 0 , then ( k−2 , k−1 ) is an optimal basis. Consider the case h = 1 . Then, We can distinguish four cases j = k − 1 , j = k , j = k + 1 and j > k + 1 . In the cases j = k and j = k + 1 we shall proof that ( k−2 , k ) is an optimal basis, and that the other two cases are not possible. If Since v k v k+1 < 0 and k ⋅ k+1 < 0 , it follows Consider now the case h = −1 . If = (v, r) = k + k+1 , then ( k+1 , ) is an optimal basis and ‖ k ‖ > ‖ ‖. As before, let j = min{i ∶ r ≥ r i } . We have ‖ ‖ ≥ ‖ j ‖ . Since r = r k + r k+1 > r k , we have j ≤ k . We can distinguish the four cases j < k − 2 , j = k − 2 , j = k − 1 and j = k . We shall see that only j = k − 1 is possible and, in this case ( k+1 , k−1 ) is an optimal basis.
vertex lower and further on the right than the preceding one. The norm of i is the distance from ̃ i to the origin. The first point after the polygonal crosses the bisector of the axes corresponds to the index k. The point closest to the origin is one of the four closest points to the bisector. By Theorem 4.2, a shortest vector of L(m, a) can be found by calculating the vectors i = (v i , r i ) of E(m, a) till we reach an index k + 1 such that |v k | > r k , and select from the four vectors k−2 , k−1 , k and k+1 the one with smaller norm, say s . This is a shortest vector of L(m, a). If s = k − 2 , a second shortest vector of L(m, a) is the shortest among the two vectors k−1 and k . Analogously, if s = k + 1 , a second shortest vector of L(m, a) is the shortest among the two vectors k−1 and k . If either s = k − 1 or s = k , we can apply just one step the Lagrange-Gauss algorithm either to the basis ( k−1 , k ) if s = k − 1 or ( k , k−1 ) if s = k to obtain an optimal basis.   vector of E(m, a), it is denoted by without subindex.

Square lattices
Probably square and symmetric satins are the most relevant classes of satins, and they have deserved special attention. For instance, they are the unique classes of the so-called isonemal satins (see Grünbaum and Shephard [6]), and the cited articles by Lucas study square and symmetric satins. We devote this section to square satins and the next one to symmetric satins.
A lattice L is called a square lattice if it satisfies one of the following three equivalent conditions: Thus, if a 2 + 1 ≡ 0 (mod m) , then L(m, a) is a square lattice. Therefore, a square satin is a satin L(m, a) such that a 2 + 1 ≡ 0 (mod m) . See the example in Fig. 3.
Historically, the main interest was to find m such that there exist steps a giving squared satins. In arithmetic terms, the problem is to find m such that −1 is a quadratic residue modulus m. It is well known that such m are those with a factorization in product of primes of the form m = 2 0 p 1 1 … p k k with 0 ∈ {0, 1} and  L(m, a) is a square lattice, then the extended Euclid's algorithm gives an optimal basis. We have the following characterization of square lattices in terms of the penultimate vector of the Euclid's algorithm. vectors of E(m, a). Assume that a < m∕2 . Then the lattice L(m, a) is a square lattice if and only if v n = −a . In this case, n is even.
Proof Assume that L(m, a) is a square lattice. From the Bézout identity u n m + v n a = 1 and a 2 + 1 = xm for some integer x, we obtain u n m + v n a = 1 = xm − a 2 and (u n − x)m = −a(a + v n ) . Since gcd(m, a) = 1 , it follows that m divides |a + v n | , that is, |a + v n | = mq for some integer q. By Theorem 2.1 (xii), we have |v n | ≤ m∕2 . Then, Therefore, q = 0 and v n = −a < 0.
Reciprocally, if v n = −a , from u n m + v n a = r n = 1 , we get −a 2 ≡ 1 (mod m) , that is L(m, a) is a square lattice.
By Theorem 2.1 (vi), v n = −a < 0 implies n even. ◻ If a = 1 , the lattice L(m, a) is a square lattice only if m = 2 (the plain satin) and, in this case, ((1, 1), (−1, 1)) is an optimal basis. We left apart this case. It is immediate that for m = 3 and m = 4 there are not square satins. Moreover, as said before, it is not restrictive to assume a < m∕2 . If m ≥ 5 , for the direct twill a = 1 we have a 2 + 1 ≡ 2 (mod m) , so it is not a square lattice. Then, we can also assume 1 < a.
(ii) By (i), we have r n+1−i = |v i | and |v n+1−i | = r i . It follows Satins, lattices, and extended Euclid's algorithm Proof The number j = n∕2 is integer since n is even. The equality |v n+1−i | = r i for i = j and i = j + 1 gives |v j+1 | = r j > r j+1 = |v j | . Thus, k = j + 1 = (n + 2)∕2 . We is an optimal basis. ◻ L(65, 18). We calculate the vectors i = (v i , r i ) till |v i | > r i or, equivalently, till we obtain a pair of consecutive orthogonal vectors.

Symmetric satins
A symmetric lattice is a lattice L such that for all (x, y) ∈ ℤ 2 , if (x, y) ∈ L , then (y, x) ∈ L . Geometrically, it is a lattice symmetric with respect to the line of equation y = x . If a satin L(m, a) is a symmetric lattice, then (1, a) ∈ L(m, a) implies (a, 1) ∈ L(m, a) and, then, a 2 ≡ 1 (mod m) ; reciprocally, if a 2 ≡ 1 (mod m) then gcd(m, a) = 1 and if (v, r) ∈ L(m, a) , we have av ≡ r (mod m) and v = a 2 v = ar (mod m) , so (r, v) ∈ L(m, a) and it follows that L(m, a) is a symmetric lattice. Thus, a symmetric satin is a satin L(m, a) such that a 2 − 1 ≡ 0 (mod m) . See the example in Fig. 4. Twills, for example, are symmetric satins. A basis ( , ) of a satin is rectangular if ⋅ = 0 . Obviously, a rectangular basis is an optimal one. A satin is rectangular if it has a rectangular basis. For instance, twills with even period m are rectangular.
A basis ( , ) of a satin is rombal if ‖ ‖ = ‖ ‖ , that is, if the parallelogram of sides and is a rhombus. A satin is rombal if it has rombal basis. A satin is rombal optimal if it has a rombal optimal basis. Twills with odd period m have optimal basis which are neither rectangular nor rombal (see Propositions 3.1 and 3.  )) is not optimal (the optimal one is ((−2, 2), (1, 3)) ). Thus, the bound 4 ≤ a in the Proposition 6.1 is sharp.
It is known that every symmetric satin is rectangular or rombal. Grünbaum and Shepard give a sketch of the proof in [6]. Next, we provide a detailed proof with the goal to obtain, not only the classification, but also an optimal basis, and discriminate when a rombal basis is optimal or not. At the end of the section, we relate these results with the Euclid's algorithm.
The plain L(2, 1) has optimal basis ((1, 1), (−1, 1)) , that is rectangular and rombal, so we exclude this case of the discussion. (iii) We shall see that x 1 = (d + m 1 )∕2 is an integer and also that Consider first the case when m is even and a 2 − 1 ≢ 0 (mod 2m) ; that is, m is even and a 2 − 1 = qm with q an odd integer. We claim that m 1 is even. Indeed, implies qm 1 = (a − 1)a 1 . Since a − 1 is even, we have that qm 1 = (a − 1)a 1 is even, but q is odd. Hence, m 1 is even.
Because d and m 1 are even, the number x 1 = (d + m 1 )∕2 is an integer. We shall see that ax 1 ≡ d − x 1 (mod m) . From ad ≡ d (mod m) , it follows (a − 1)d = m for some integer . Multiplying by a + 1 , we get (a 2 − 1)d = (a + 1)m . Then, qmd = a 1 dm , and q = a 1 . As q is odd, is odd too. Analogously, from am 1 ≡ −m 1 (mod m) we get (a + 1)m 1 = m for some integer . Dividing by m 1 , we obtain a + 1 = d and = (a + 1)∕d = a 1 , which is odd. Now, and are odd, so + is even, say + = 2 . Then adding, ad = d + m and am 1 = −m 1 + m we obtain a(d + m 1 ) = d − m 1 + ( + )m = d − m 1 + 2 m and dividing by 2, Consider now the case when m is odd. Then, d and m 1 are odd and d + m 1 is even, so x 1 = (d + m 1 )∕2 is an integer. The congruences ad ≡ d (mod m) and Plane and twill satins have been considered above. Next theorem considers symmetric satins other than plain and twills, so m ≥ 5 and 1 < a < m − 1. L(m, a) be a symmetric satin with m ≥ 5 and m − 1 > a > 1 . d).
Next, we turn to the Euclid's algorithm again. Next Lemma and Proposition show certain properties of the vectors of E(m, a) for a symmetric satin. We skip the proofs because they are very similar to those of Lemma 5.1 and Proposition 5.1, respectively. (6.2) (d 2 + m 2 1 )∕2 = ‖ ‖ 2 < ‖ ‖ 2 ≤ 2d 2 ⇔ m 2 1 < 3d 2 .