productCA: Direct product and generalized direct product for two CAs

View source: R/productCA.R

dpCAR Documentation

Direct product and generalized direct product for two CAs

Description

Functions to construct a CA from a (generalized) direct product of two ingoing CAs

Usage

dpCA(k, v, ...)

productCA(D1, D2, c1=NA, c2=NA, check=FALSE, dupremove=TRUE, generalized=TRUE, ...)

productCA_raw(D1, D2)

Arguments

k

number of columns

v

number of levels

...

further arguments to function maxconstant, e.g., one_is_enough=TRUE in case of large D1 and D2.

D1

an N x k CA of strength 2 with v levels

D2

an M x l CA of strength 2 with v levels

c1

for generalized=TRUE, number of constant rows at the top of D1; specifying this (correctly) substantially speeds up the function for large D1

c2

for generalized=TRUE, number of constant rows at the top of D2; specifying this substantially speeds up the function for large D2, if D1 has fewer than v constant rows (ignored otherwise)

check

logical; if TRUE, checks required strength of ingoing CAs (may substantially increase run time for large CAs)

dupremove

logical; if TRUE, removes duplicated rows of the result (if any)

generalized

logical; if TRUE, exploits constant rows.
TRUE is the recommended choice, as it reduces the number of runs from N+M to a run size between N+M-v and N+M-2, depending on the number of constant rows.

Value

Function productCA returns a CA(N + M - min(v, s+r), 2, kl, v) (matrix of class ca).
Function productCA_raw returns the simple (N + M) x (k*l) direct product of its two arguments.

Details

Function dpCA yields a uniform strength 2 CA with k columns in v levels, based on the pre-inspected combination of ingredient CAs contained in the data frame DPcat; the calculations invoked use the function productCA that implements (a simple form of) the generalized direct product construction presented in Colbourn and Torres-Jimenez (2013).

Function productCA yields a CA(N + M - min(v, s+r), 2, kl, v) from a product construction,
for which D1 can be rearranged to have s constant rows
and D2 can be rearranged to have r constant rows
as proposed in Corollary 4.3 of Colbourn and Torres-Jimènez (2013)
(removal of duplicates may reduce run size further, for very poor ingoing arrays).
For large and efficient ingoing arrays, it may be wise to specify one_is_enough=TRUE (as part of ...); in that case, the search for the maximum number of constant rows is skipped, and the resulting run size is N + M - 2.

Function productCA also serves as work horse function for combining two CAs in some instances of the CAEX construction.

Function productCA_raw is mainly meant for calculation of interim results in other functions, e.g., productPCA. It works on any pair of numeric matrices that do not need to be integer-valued or CAs (see Examples Section).

References

Colbourn and Torres-Jimenez (2013)

Examples

############################
#### dpCA ##################
############################
Ns(2, 25, 6)
D <- dpCA(25, 5)
coverage(D, 2)

#########################################
## productCA
#########################################
###  (N+M-2 x k*l matrix)
A <- cyc(19,2)
B <- KSK(k=12)
dim(A); dim(B)
E <- productCA(A, B)
dim(E)
## check coverage with the fast function
caverify::ca_verify(E, 2)
## 19 + 7 - 2 runs, twice as large as the optimal 12
eCAN(2,228,2)

A <- lhs::createBose(4, 5, bRandom=FALSE)
dim(A)
E <- productCA(A, A)
## check coverage with the fast function
caverify::ca_verify(E, 2)
dim(E)  ## 30 runs with 25 columns, close to optimal
eCAN(2, 25, 4) ## 29 runs
eCAK(2, 30, 4) ## 30 columns

## from two CAs with many constant rows
## (not useful for this particular A, for demo purposes only)
A <- lhs::createBush(4, 5, bRandom=FALSE)
dim(productCA(A,A)) ## using default behavior
                     ## that exploits maximum constant rows
                     ## reduces N+M by up to v runs
dim(productCA(A,A, one_is_enough=TRUE))
                     ## preventing function maxconstant from conducting a
                     ## clique search, reduces N+M by 2 runs

## the function also works for designs with flexible values (which are denoted by NA)
## productCA
D <- productCA(CAEX(N=16), CAEX(N=16))
dim(D)
eCAN(2,441,3) ## slightly worse than the best CA, which is obtained as CAEX(N=28)
eCAK(2,30,3) ## a lot more columns are possible in 30 runs

### productCA_raw works on arbitrary numeric matrices
### and applies the simple direct product
A <- matrix(1:12, nrow=4)
B <- matrix(10*(1:6), nrow=3)
productCA_raw(A, B)


CAs documentation built on Nov. 29, 2026, 1:06 a.m.