Title: | Pseudo-Vectors Containing All Permutations, Combinations and Subsets of Objects Taken from a Vector. |
---|---|
Description: | Class definitions and constructors for pseudo-vectors containing all permutations, combinations and subsets of objects taken from a vector. Simplifies working with structures commonly encountered in combinatorics. |
Authors: | Richard Ambler |
Maintainer: | Richard Ambler <[email protected]> |
License: | GPL-3 |
Version: | 0.6 |
Built: | 2025-02-01 04:27:08 UTC |
Source: | https://github.com/cran/trotter |
Access an amalgam (permutation with replacement) stored in an APV
instance by index.
## S4 method for signature 'APV' x[i, j, drop]
## S4 method for signature 'APV' x[i, j, drop]
x |
an instance of |
i |
an index specifying the position of the sought amalgam |
j |
not used. |
drop |
not used. |
The amalgam at index i
of pseudo-vector x
is not actually
stored in memory but calculated as needed. The extract method is used solely
for interpretation.
the amalgam located at position i
in pseudo-vector x
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
Access a combination stored in a CPV
instance by index.
## S4 method for signature 'CPV' x[i, j, drop]
## S4 method for signature 'CPV' x[i, j, drop]
x |
an instance of |
i |
an index specifying the position of the sought combination. |
j |
not used. |
drop |
not used. |
The combination at index i
of pseudo-vector x
is not actually
stored in memory but calculated as needed. The extract method is used solely
for interpretation.
the combination located at position i
in pseudo-vector x
Permutations Pseudo-Vector ppv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
Access a permutation stored in a PPV
instance by index.
## S4 method for signature 'PPV' x[i, j, drop]
## S4 method for signature 'PPV' x[i, j, drop]
x |
an instance of |
i |
an index specifying the position of the sought permutation. |
j |
not used. |
drop |
not used. |
The permutation at index i
of pseudo-vector x
is not actually
stored in memory but calculated as needed. The extract method is used solely
for interpretation.
the permutation located at position i
in pseudo-vector x
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
Access a selection (combination with replacement) stored in an SPV
instance by index.
## S4 method for signature 'SPV' x[i, j, drop]
## S4 method for signature 'SPV' x[i, j, drop]
x |
an instance of |
i |
an index specifying the position of the sought selection. |
j |
not used. |
drop |
not used. |
The selection at index i
of pseudo-vector x
is not actually
stored in memory but calculated as needed. The extract method is used solely
for interpretation.
the selection located at position i
in pseudo-vector x
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Subsets Pseudo-Vector sspv
Access asubset stored in an SSPV
instance by index.
## S4 method for signature 'SSPV' x[i, j, drop]
## S4 method for signature 'SSPV' x[i, j, drop]
x |
an instance of |
i |
an index specifying the position of the sought amalgam |
j |
not used. |
drop |
not used. |
The subset at index i
of pseudo-vector x
is not actually
stored in memory but calculated as needed. The extract method is used solely
for interpretation.
the subset located at position i
in pseudo-vector x
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
The APV
class defines a pseudo-vector containing all
the arranged k
-amalgams (permutations with replacement) of the objects stored
in items
. The function apv
is a constructor for this class.
apv(k, items)
apv(k, items)
k |
the number of objects taken at a time. |
items |
a vector of objects to be amalgamated. |
The amalgams are arranged according to the order in which the objects
appear in items
. The arrangement is very similar to that used by the PPV
class
(see ppv) except that objects are replaced during permutation creation.
an instance of APV
.
Richard Ambler
Steinhaus-Johnson-Trotter algorithm. (2014, April 29). In Wikipedia, The Free Encyclopedia. Retrieved 13:24, September 5, 2014
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
# create a pseudo-vector of 10-amalgams from the first 15 letters a <- apv(10, letters[1:15]) # generate a description print(a) # compatable with length length(a) # inspect a few of the combinations "stored" in a a[1] a[1000000] a[576650390625]
# create a pseudo-vector of 10-amalgams from the first 15 letters a <- apv(10, letters[1:15]) # generate a description print(a) # compatable with length length(a) # inspect a few of the combinations "stored" in a a[1] a[1000000] a[576650390625]
The CPV
class defines a pseudo-vector containing all
the arranged k
-combinations of the objects stored
in items
. The function cpv
is a constructor for this class.
cpv(k, items)
cpv(k, items)
k |
the number of objects taken at a time. |
items |
a vector of objects to be combined. |
The combinations are arranged according to the order in which the objects
appear in items
. Combinations containing the first object in
items
are followed by combinations that contain the second object
but not the first, which are followed by combinations that contain the third
but neither the first or the second, etc.
an instance of CPV
.
Richard Ambler
Steinhaus-Johnson-Trotter algorithm. (2014, April 29). In Wikipedia, The Free Encyclopedia. Retrieved 13:24, September 5, 2014
Permutations Pseudo-Vector ppv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
# create a pseudo-vector of 10-combinations from the first 15 letters c <- cpv(10, letters[1:15]) # generate a description print(c) # compatable with length length(c) # inspect a few of the combinations "stored" in c c[1] c[1000] c[3003]
# create a pseudo-vector of 10-combinations from the first 15 letters c <- cpv(10, letters[1:15]) # generate a description print(c) # compatable with length length(c) # inspect a few of the combinations "stored" in c c[1] c[1000] c[3003]
Get the length of an APV
instance.
## S4 method for signature 'APV' length(x)
## S4 method for signature 'APV' length(x)
x |
an instance of |
Since x
contains all the k
-amalgams of objects in vector
items
, length(x)
will return length(items) ^ k)
.
the number of amalgams (permutations with replacement) in pseudo-vector x
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
Get the length of a CPV
instance.
## S4 method for signature 'CPV' length(x)
## S4 method for signature 'CPV' length(x)
x |
an instance of |
Since x
contains all the k
-combinations of objects in vector
items
, length(x)
will return choose(length(items), k)
.
the number of combinations in pseudo-vector x
Permutations Pseudo-Vector ppv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
Get the length of a PPV
instance.
## S4 method for signature 'PPV' length(x)
## S4 method for signature 'PPV' length(x)
x |
an instance of |
Since x
contains all the k
-permutations of objects in vector
items
, length(x)
will return
choose(length(items), k) * factorial(k)
.
the number of permutations in pseudo-vector x
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
Get the length of an SPV
instance.
## S4 method for signature 'SPV' length(x)
## S4 method for signature 'SPV' length(x)
x |
an instance of |
Since x
contains all the k
-selections of objects in vector
items
, length(x)
will return choose(length(items) + k - 1, k)
.
the number of selections (combinations with replacement) in pseudo-vector x
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Subsets Pseudo-Vector sspv
Get the length of an SSPV
instance.
## S4 method for signature 'SSPV' length(x)
## S4 method for signature 'SSPV' length(x)
x |
an instance of |
Since x
contains all the subsets of objects in vector
items
, length(x)
will return 2 ^ length(items)
.
the number of subsets in pseudo-vector x
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
The PPV
class defines a pseudo-vector containing all
the k
-permutations of the objects stored
in items
. The function ppv
is a constructor for this class.
ppv(k, items)
ppv(k, items)
k |
the number of objects taken at a time. |
items |
a vector of objects to be permuted. |
The arrangement of permutations is similar, but in many cases not identical, to that obtained from the Steinhaus-Johnson-Trotter algorithm (see references).
an instance of PPV
.
Richard Ambler
Steinhaus-Johnson-Trotter algorithm. (2014, April 29). In Wikipedia, The Free Encyclopedia. Retrieved 13:24, September 5, 2014
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
Subsets Pseudo-Vector sspv
# create a pseudo-vector of 5-permutations from the first 10 letters p <- ppv(5, letters[1:10]) # generate a description print(p) # compatable with length length(p) # inspect a few of the permutations "stored" in p p[1] p[1000] p[30240]
# create a pseudo-vector of 5-permutations from the first 10 letters p <- ppv(5, letters[1:10]) # generate a description print(p) # compatable with length length(p) # inspect a few of the permutations "stored" in p p[1] p[1000] p[30240]
The SPV
class defines a pseudo-vector containing all
the arranged k
-selections (combinations with replacement) of the objects stored
in items
. The function spv
is a constructor for this class.
spv(k, items)
spv(k, items)
k |
the number of objects taken at a time. |
items |
a vector of objects to be selected. |
The selections are arranged according to the order in which the objects
appear in items
. The arrangement is very similar to the arrangement
of combinations (see cpv) except that objects may be repeatedly selected.
an instance of SPV
.
Richard Ambler
Steinhaus-Johnson-Trotter algorithm. (2014, April 29). In Wikipedia, The Free Encyclopedia. Retrieved 13:24, September 5, 2014
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Subsets Pseudo-Vector sspv
# create a pseudo-vector of 10-selections from the first 15 letters s <- spv(10, letters[1:15]) # generate a description print(s) # compatable with length length(s) # inspect a few of the combinations "stored" in s s[1] s[1000] s[1961256]
# create a pseudo-vector of 10-selections from the first 15 letters s <- spv(10, letters[1:15]) # generate a description print(s) # compatable with length length(s) # inspect a few of the combinations "stored" in s s[1] s[1000] s[1961256]
The SSPV
class defines a pseudo-vector containing all
the arranged subsets of the objects stored
in items
. The function sspv
is a constructor for this class.
sspv(items)
sspv(items)
items |
a vector of objects to be subsetted. |
The subsets are arranged according to the order in which the objects
appear in items
. The first subset, containing none of the objects,
is NULL
.
an instance of SSPV
.
Richard Ambler
Permutations Pseudo-Vector ppv
Combinations Pseudo-Vector cpv
Amalgams Pseudo-Vector apv
Selections Pseudo-Vector spv
# create a pseudo-vector of subsets from the first 15 letters ss <- sspv(letters[1:15]) # generate a description print(ss) # compatable with length length(ss) # inspect a few of the combinations "stored" in ss ss[1] ss[1000] ss[32768]
# create a pseudo-vector of subsets from the first 15 letters ss <- sspv(letters[1:15]) # generate a description print(ss) # compatable with length length(ss) # inspect a few of the combinations "stored" in ss ss[1] ss[1000] ss[32768]