pCart {kStatistics} | R Documentation |
Cartesian product
Description
The function returns the cartesian product between vectors.
Usage
pCart( L )
Arguments
L |
vectors in a list |
Details
The pCart
function pairs any element of the first vector with any element of
the second vector, iteratively, if there are more than two vectors in input. Repetitions are allowed.
See examples.
Value
list |
the list with the cartesian product |
Note
Called by the nPS
function in the kStatistics
package.
Author(s)
Elvira Di Nardo elvira.dinardo@unito.it,
Giuseppe Guarino giuseppe.guarino@rete.basilicata.it
References
D. E. Knuth (1998) The Art of Computer Programming. (3rd ed.) Addison Wesley.
See Also
Examples
A <- c(1,2)
B <- c(3,4,5)
# Return the cartesian product [[1,3],[1,4],[1,5],[2,3],[2,4],[2,5]]
pCart( list( A, B) )
L1<-list( c(1,1), c(2))
L2<-list( c(5,5), c(7) )
# Return the cartesian product [[1,1],[5,5]], [[1,1],[7]], [[2],[5,5]], [[2],[7]]
# and assign the result to L3
L3<-pCart ( list(L1, L2) )
# Return the cartesian product between L3 and [7].
# The result is [[1,1],[5,5],[7]], [[1,1],[7],[7]], [[2],[5,5],[7]], [[2],[7],[7]]
pCart ( list(L3, c(7)) )
[Package kStatistics version 2.1.1 Index]