forked from johannesgerer/jburkardt-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatin_cover.html
282 lines (240 loc) · 7.11 KB
/
latin_cover.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<html>
<head>
<title>
LATIN_COVER - N Latin Squares which cover an NxN square.
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
LATIN_COVER <br> N Latin Squares which cover an NxN square.
</h1>
<hr>
<p>
<b>LATIN_COVER</b>
is a C++ library which
produces a set of N Latin Squares which cover an NxN square.
</p>
<p>
Given an NxN grid, a Latin Square is a selection of N pairs of indices
(I,J) such that every possible value of I and J occurs exactly once.
A picture for the case N = 5 may suggest what is going on:
<pre>
- - - 1 -
- 1 - - -
I 1 - - - -
- - - - 1
- - 1 - -
J
</pre>
The above Latin Square can also be described by the index pairs (1,4),
(2,2), (3,1), (4,5), (5,3).
</p>
<p>
A Latin square will always contain N index pairs. Since the original
square contains NxN index pairs, it is interesting to speculate whether
it would be possible to find N Latin squares with the property that
every possible index pair (I,J) in the NxN square occurs in exactly one
of the Latin Squares. In that case, we would say that the Latin Squares
"cover" or decompose the square.
</p>
<p>
Here is an example which starts with the Latin square pictured above,
and generates 4 more Latin squares to cover the 5x5 square.
<pre>
3 2 5 1 4
2 1 4 5 3
I 1 5 3 4 2
5 4 2 3 1
4 3 1 2 5
J
</pre>
</p>
<p>
Given a value N, this program produces a Latin cover for an NxN square.
</p>
<p>
Given a description of a Latin square of order N, this program produces
N-1 more Latin squares, so that together with the input Latin square,
a Latin cover is produced.
</p>
<p>
It is also possible to generate a 3D Latin covering. Here, a single
Latin cube contains only N subcubes, so we require NxN such cubes if
we have a hope of covering all the subcubes. The routine LATIN_COVER_3D
will compute such a covering.
</p>
<p>
A small example of a 3D a Latin Cover:
<pre>
K = 1
J: 1 2 3
I:
1: 4 1 7
2: 6 3 9
3: 5 2 8
K = 2
J: 1 2 3
I:
1: 3 9 6
2: 2 8 5
3: 1 7 4
K = 3
J: 1 2 3
I:
1: 8 5 2
2: 7 4 1
3: 9 6 3
</pre>
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this
web page are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>LATIN_COVER</b> is available in
<a href = "../../c_src/latin_cover/latin_cover.html">a C version</a> and
<a href = "../../cpp_src/latin_cover/latin_cover.html">a C++ version</a> and
<a href = "../../f77_src/latin_cover/latin_cover.html">a FORTRAN77 version</a> and
<a href = "../../f_src/latin_cover/latin_cover.html">a FORTRAN90 version</a> and
<a href = "../../m_src/latin_cover/latin_cover.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../cpp_src/latin_center/latin_center.html">
LATIN_CENTER</a>,
a C++ library which
computes elements of a Latin Hypercube dataset, choosing center points.
</p>
<p>
<a href = "../../cpp_src/latin_edge/latin_edge.html">
LATIN_EDGE</a>,
a C++ library which
computes elements of a Latin Hypercube dataset, choosing edge points.
</p>
<p>
<a href = "../../cpp_src/latin_random/latin_random.html">
LATIN_RANDOM</a>,
a C++ library which
computes elements of a Latin Hypercube dataset, choosing points at random.
</p>
<p>
<a href = "../../c_src/latinize/latinize.html">
LATINIZE</a>,
a C library which
adjusts N points in M dimensions to form a Latin hypercube.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ol>
<li>
Herbert Ryser,<br>
Combinatorial Mathematics,<br>
Mathematical Association of America, 1963.
</li>
</ol>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "latin_cover.c">latin_cover.c</a>, the source code.
</li>
<li>
<a href = "latin_cover.h">latin_cover.h</a>, the include file.
</li>
<li>
<a href = "latin_cover.sh">latin_cover.sh</a>,
BASH commands to compile the source code.
</li>
</ul>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<ul>
<li>
<a href = "latin_cover_prb.c">latin_cover_prb.c</a>
a sample calling program.
</li>
<li>
<a href = "latin_cover_prb.sh">latin_cover_prb.sh</a>,
BASH commands to compile and run the sample program.
</li>
<li>
<a href = "latin_cover_prb_output.txt">latin_cover_prb_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>I4_MAX</b> returns the maximum of two I4's.
</li>
<li>
<b>I4_MIN</b> returns the smaller of two I4's.
</li>
<li>
<b>I4_MODP</b> returns the nonnegative remainder of I4 division.
</li>
<li>
<b>I4_UNIFORM</b> returns a scaled pseudorandom I4.
</li>
<li>
<b>I4_WRAP</b> forces an I4 to lie between given limits by wrapping.
</li>
<li>
<b>I4BLOCK_PRINT</b> prints an I4BLOCK.
</li>
<li>
<b>I4MAT_PRINT</b> prints an I4MAT.
</li>
<li>
<b>I4MAT_PRINT_SOME</b> prints some of an I4MAT.
</li>
<li>
<b>LATIN_COVER</b> returns a 2D Latin Square Covering.
</li>
<li>
<b>PERM_CHECK</b> checks that a vector represents a permutation.
</li>
<li>
<b>PERM_PRINT</b> prints a permutation.
</li>
<li>
<b>PERM_UNIFORM</b> selects a random permutation of N objects.
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../c_src.html">
the C source codes</a>.
</p>
<hr>
<i>
Last revised on 05 August 2012.
</i>
<!-- John Burkardt -->
</body>
<!-- Initial HTML skeleton created by HTMLINDEX. -->
</html>