Skip to content

Commit 1c00560

Browse files
committed
moved from std::vector to std::array for cases where array size is static
1 parent 26bcf6a commit 1c00560

File tree

5 files changed

+98
-103
lines changed

5 files changed

+98
-103
lines changed

.github/workflows/rhub.yaml

+2-6
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,9 @@ jobs:
8484
echo "BUILD_ARGS=--no-build-vignettes" >> $GITHUB_ENV
8585
- name: Bad CXXFLAGS for atlas
8686
if: matrix.config.label == 'atlas'
87+
# throws a warning on non-portable compilation flags
8788
run: |
88-
echo "CXXFLAGS=-g -O2 -Wall -pedantic -mtune=native -fexceptions -fstack-protector-strong -fstack-clash-protection -fcf-protection" >> $GITHUB_ENV
89-
echo "CXX11FLAGS=-g -O2 -Wall -pedantic -mtune=native -fexceptions -fstack-protector-strong -fstack-clash-protection -fcf-protection" >> $GITHUB_ENV
90-
echo "CXX14FLAGS=-g -O2 -Wall -pedantic -mtune=native -fexceptions -fstack-protector-strong -fstack-clash-protection -fcf-protection" >> $GITHUB_ENV
91-
echo "CXX17FLAGS=-g -O2 -Wall -pedantic -mtune=native -fexceptions -fstack-protector-strong -fstack-clash-protection -fcf-protection" >> $GITHUB_ENV
92-
echo "CXX20FLAGS=-g -O2 -Wall -pedantic -mtune=native -fexceptions -fstack-protector-strong -fstack-clash-protection -fcf-protection" >> $GITHUB_ENV
93-
echo "CXX23FLAGS=-g -O2 -Wall -pedantic -mtune=native -fexceptions -fstack-protector-strong -fstack-clash-protection -fcf-protection" >> $GITHUB_ENV
89+
echo "_R_CHECK_COMPILATION_FLAGS_=false" >> $GITHUB_ENV
9490
- uses: r-hub/actions/run-check@v1
9591
with:
9692
token: ${{ secrets.RHUB_TOKEN }}

src/OACommonDefines.h

+56-55
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
* it under the terms of the GNU Lesser General Public License as published by
99
* the Free Software Foundation, either version 3 of the License, or
1010
* (at your option) any later version.
11-
*
11+
*
1212
* This program is distributed in the hope that it will be useful,
1313
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
* GNU Lesser General Public License for more details.
16-
*
16+
*
1717
* You should have received a copy of the GNU Lesser General Public License
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19-
*
19+
*
2020
* Reference:
2121
* <ul><li><a href="http://lib.stat.cmu.edu/designs/">Statlib Designs</a></li>
2222
* <li><a href="http://lib.stat.cmu.edu/designs/oa.c">Owen's Orthogonal Array Algorithms</a></li></ul>
@@ -36,6 +36,7 @@
3636
#include <sstream>
3737
#include <iostream>
3838
#include <numeric>
39+
#include <array>
3940

4041
#ifdef RCOMPILE
4142
#include <Rcpp.h>
@@ -99,153 +100,153 @@ namespace oacpp {
99100

100101
/**
101102
* @page oa_main_page Orthogonal Array Library
102-
*
103+
*
103104
* From the original documentation by Owen:
104-
*
105+
*
105106
*<blockquote>
106107
* From: owen@stat.stanford.edu
107-
*
108-
* These programs construct and manipulate orthogonal
108+
*
109+
* These programs construct and manipulate orthogonal
109110
* arrays. They were prepared by
110111
* - Art Owen
111112
* - Department of Statistics
112113
* - Sequoia Hall
113114
* - Stanford CA 94305
114-
*
115+
*
115116
* They may be freely used and shared. This code comes
116117
* with no warranty of any kind. Use it at your own
117118
* risk.
118-
*
119+
*
119120
* I thank the Semiconductor Research Corporation and
120121
* the National Science Foundation for supporting this
121122
* work.
122-
*
123+
*
123124
* I thank Randall Tobias of SAS Inc. for many helpful
124125
* electronic discussions that lead to improvements in
125126
* these programs.
126127
* </blockquote>
127-
*
128+
*
128129
* @tableofcontents
129-
*
130+
*
130131
* @section orthogonal_arrays_sec Orthogonal Arrays
131132
* <blockquote>
132-
* An orthogonal array <code>A</code> is a matrix of <code>n</code> rows, <code>k</code>
133+
* An orthogonal array <code>A</code> is a matrix of <code>n</code> rows, <code>k</code>
133134
* columns with every element being one of <code>q</code> symbols
134135
* <code>0,...,q-1</code>. The array has strength <code>t</code> if, in every <code>n</code> by <code>t</code>
135136
* submatrix, the <code>q^t</code> possible distinct rows, all appear
136137
* the same number of times. This number is the index
137-
* of the array, commonly denoted <code>lambda</code>. Clearly,
138-
* <code>lambda*q^t = n</code>. Geometrically, if one were to "plot" the
138+
* of the array, commonly denoted <code>lambda</code>. Clearly,
139+
* <code>lambda*q^t = n</code>. Geometrically, if one were to "plot" the
139140
* submatrix with one plotting axis for each of the <code>t</code> columns
140141
* and one point in <code>t</code> dimensional space for each row, the
141142
* result would be a grid of <code>q^t</code> distinct points. There would
142143
* be <code>lambda</code> "overstrikes" at each point of the grid.
143-
*
144+
*
144145
* The notation for such an array is <code>OA( n, k, q, t )</code>.
145-
*
146+
*
146147
* If <code>n <= q^(t+1)</code>, then the <code>n</code> rows "should" plot as
147148
* <code>n</code> distinct points in every <code>n</code> by <code>t+1</code> dimensional subarray.
148149
* When this fails to hold, the array has the "coincidence
149150
* defect".
150-
*
151+
*
151152
* Owen (1992,199?) describes some uses for randomized
152153
* orthogonal arrays, in numerical integration, computer
153154
* experiments and visualization of functions. Those
154155
* references contain further references to the literature,
155-
* that provide further explanations. A strength 1 randomized
156+
* that provide further explanations. A strength 1 randomized
156157
* orthogonal array is a Latin hypercube
157158
* sample, essentially so or exactly so, depending on
158159
* the definition used for Latin hypercube sampling.
159160
* The arrays constructed here have strength 2 or more, it
160161
* being much easier to construct arrays of strength 1.
161-
*
162+
*
162163
* The randomization is achieved by independent
163164
* uniform permutation of the symbols in each column.
164-
*
165+
*
165166
* To investigate a function <code>f</code> of <code>d</code> variables, one
166167
* has to have an array with <code>k >= d</code>. One may also
167168
* have a maximum value of <code>n</code> in mind and a minimum value
168169
* for the number <code>q</code> of distinct levels to investigate.
169-
*
170+
*
170171
* It is entirely possible that no array of strength <code>t > 1</code>
171172
* is compatible with these conditions. The programs
172173
* below provide some choices to pick from, hopefully
173174
* without too much of a compromise.
174-
*
175+
*
175176
* The constructions used are based on published
176177
* algorithms that exploit properties of Galois fields.
177178
* Because of this the number of levels <code>q</code> must be
178179
* a prime power. That is <code>q = p^r</code> where <code>p</code> is prime
179180
* and <code>r >= 1</code> is an integer.
180-
*
181+
*
181182
* The Galois field arithmetic for the prime powers is
182183
* based on tables published by Knuth and Alanen (1964)
183184
* below. The resulting fields have been tested by the
184185
* methods described in Appendix 2 of that paper and
185186
* they passed. This is more a test of the accuracy of
186187
* my transcription than of the original tables.
187188
* </blockquote>
188-
*
189+
*
189190
* @section avail_prime_sec Available Prime Powers
190-
*
191+
*
191192
* <blockquote>
192193
* The designs given here require a prime power for
193-
* the number of levels. They presently work for the
194+
* the number of levels. They presently work for the
194195
* following prime powers:
195-
*
196+
*
196197
* All Primes
197198
* All prime powers <code>q = p^r</code> where <code>p < 50</code> and <code>q < 10^9</code>
198-
*
199+
*
199200
* Here are some of the smaller prime powers:
200-
*
201+
*
201202
* - Powers of 2: 4 8 16 32 64 128 256 512
202203
* - Powers of 3: 9 27 81 243 729
203204
* - Powers of 5: 25 125 625
204-
* - Powers of 7: 49 343
205+
* - Powers of 7: 49 343
205206
* - Square of 11: 121
206207
* - Square of 13: 169
207-
*
208+
*
208209
* Here are some useful primes:
209-
*
210+
*
210211
* - 2,3,5,7,11,13,17,19,23,29,31,37,101,251,401
211-
*
212+
*
212213
* The first row are small primes, the second row are
213214
* primes that are 1 more than a "round number". The small
214215
* primes lead to small arrays. An array with 101 levels
215216
* is useful for exploring a function at levels 0.00 0.01
216217
* through 1.00. Keep in mind that a strength 2 array on
217218
* 101 levels requires <code>101^2 = 10201</code> experimental runs,
218219
* so it is only useful where large experiments are possible.
219-
*
220+
*
220221
* Note that some of these will require more
221222
* memory than your computer has. For example,
222223
* with a large prime like 10663, the program knows
223224
* the Galois field, but can't allocate enough
224225
* memory:
225-
*
226+
*
226227
* <code>bose 10663</code>
227228
* - Unable to allocate 1927'th row in an integer matrix.
228229
* - Unable to allocate space for Galois field on 10663 elements.
229230
* - Construction failed for <code>GF(10663)</code>.
230231
* - Could not construct Galois field needed for Bose design.
231-
*
232+
*
232233
* The smallest prime power not covered is <code>53^2 = 2809</code>.
233234
* The smallest strength 2 array with 2809 symbols has
234235
* <code>2809^2 = 7890481</code> rows. Therefore the missing prime powers
235236
* are only needed in certain enormous arrays, not in the
236237
* small ones of most practical use. In any event there
237238
* are some large primes and prime powers in the program
238239
* if an enormous array is needed.
239-
*
240+
*
240241
* To add <code>GF(p^r)</code> for some new prime power p^r,
241242
* consult Alanen and Knuth for instructions on how
242243
* to search for an appropriate indexing polynomial,
243244
* and for how to translate that polynomial into a
244-
* replacement rule for <code>x^r</code>.
245+
* replacement rule for <code>x^r</code>.
245246
* </blockquote>
246-
*
247+
*
247248
* @section methods Methods
248-
*
249+
*
249250
* <ul>
250251
* <li>@ref oacpp::COrthogonalArray::bose</li>
251252
* <li>@ref oacpp::COrthogonalArray::bush</li>
@@ -264,9 +265,9 @@ namespace oacpp {
264265
* <li>@ref oacpp::COrthogonalArray::oaagree</li>
265266
* <li>@ref oacpp::COrthogonalArray::oadimen</li>
266267
* </ul>
267-
*
268+
*
268269
* @section tips Tips On Use
269-
*
270+
*
270271
* <blockquote>
271272
* It is faster to generate only the columns you need.
272273
* For example
@@ -275,11 +276,11 @@ namespace oacpp {
275276
* <code>bose 101</code>
276277
* generates 102 columns. If you only want 4 columns the
277278
* former saves a lot of time.
278-
*
279+
*
279280
* Passing the <code>q n k</code> on the command line is more difficult
280281
* than letting the computer figure them out, but it
281282
* allows more error checking.
282-
*
283+
*
283284
* In practical use, I would try first to use a Bose
284285
* design. Then I would consider either an Addelman-
285286
* Kempthorne or Bose-Bush design to see whether it
@@ -289,9 +290,9 @@ namespace oacpp {
289290
* large number of runs is possible a Bush design may
290291
* work well, since it can have high strength.
291292
* </blockquote>
292-
*
293+
*
293294
* @section references References
294-
*
295+
*
295296
* <blockquote>
296297
* Here are the references for the constructions used:
297298
* <ul>
@@ -303,7 +304,7 @@ namespace oacpp {
303304
* </ul>
304305
* This book provides a large list of orthogonal array constructions:
305306
* <ul><li>Aloke Dey (1985) "Orthogonal Fractional Factorial Designs" Halstead Press</li></ul>
306-
*
307+
*
307308
* These papers discuss randomized orthogonal arrays, the second
308309
* is being revised in parallel with development of the software
309310
* described here:
@@ -320,9 +321,9 @@ namespace oacpp {
320321
* <li>M. Stein (1987) Technometrics 29, 143-151</li>
321322
* </ul>
322323
* </blockquote>
323-
*
324+
*
324325
* @section implement Implementation Details
325-
*
326+
*
326327
* <blockquote>
327328
* Galois fields are implemented through arrays that
328329
* store their addition and multiplication tables. Some
@@ -333,15 +334,15 @@ namespace oacpp {
333334
* was not considered to be a burden. Subtraction and
334335
* division are implemented through vectors of additive
335336
* and multiplicative inverses, derived from the tables.
336-
* The tables for <code>GF(p^r)</code> are constructed using a
337+
* The tables for <code>GF(p^r)</code> are constructed using a
337338
* representation of the field elements as polynomials in <code>x</code>
338339
* with coefficients as integers modulo <code>p</code> and a special
339340
* rule (derived from minimal polynomials) for handling
340341
* products involving <code>x^r</code>. These rules are taken from
341342
* published references. The rules have not all
342-
* been checked for accuracy, because some of the fields are
343+
* been checked for accuracy, because some of the fields are
343344
* very large (e.g. 16807 elements).
344-
*
345+
*
345346
* The functions that manipulate orthogonal arrays
346347
* keep the arrays in integer matrices. This might be
347348
* a problem for applications that require enormous
@@ -355,11 +356,11 @@ namespace oacpp {
355356
* row by row, so it is not too hard to change the program
356357
* to place the elements on an output stream as they
357358
* are computed and do away with the storage.
358-
*
359+
*
359360
* The functions that test the strength of the
360361
* arrays may be very far from optimally fast.
361362
* </blockquote>
362-
*
363+
*
363364
* @section compile_oa Compiling oalib
364365
* When compiling <code>oalib</code> these preprocessor directives are used:
365366
* - NDEBUG defined for a release build

0 commit comments

Comments
 (0)