Nothing
context("testing partitionGeneral GMP")
test_that("partitions/compostionsGeneral Distinct Parallel Lower GMP", {
#######################################################################
########********************** Lower Only *******************##########
## partitionsDesign(0:600, freqs = c(600, rep(1, 600)))[
## c("num_partitions", "partition_type")
## ]
## $num_partitions
## Big Integer ('bigz') :
## [1] 30703043607660730
##
## $partition_type
## [1] "DstctStdAll"
bench <- partitionsGeneral(0:600, freqs = c(600, rep(1, 600)),
lower = "30703043607560730")
expect_identical(partitionsGeneral(0:600, freqs = c(600, rep(1, 600)),
lower = "30703043607560730",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 0:600,
freqs = c(600, rep(1, 600))),
gmp::as.bigz("30703043607560730"))
expect_equal(gmp::sub.bigz("30703043607660730",
"30703043607560730") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 600))
## partitionsDesign(1000, 15)[c("num_partitions", "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 3649675516801903698
##
## $partition_type
## [1] "DstctNoZero"
bench <- partitionsGeneral(1000, 15, lower = "3649675516801803698")
expect_identical(partitionsGeneral(1000, 15, lower = "3649675516801803698",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 1000),
gmp::as.bigz("3649675516801803698"))
expect_equal(gmp::sub.bigz("3649675516801903698",
"3649675516801803698") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000))
## partitionsDesign((1:1000) * 2e9, 15)[c("num_partitions",
## "partition_type",
## "mapped_target")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 3649675516801903698
##
## $partition_type
## [1] "DstctNoZero"
##
## $mapped_target
## [1] 1000
bench <- partitionsGeneral((1:1000) * 2e9, 15,
lower = "3649675516801803698")
expect_identical(partitionsGeneral((1:1000) * 2e9, 15,
lower = "3649675516801803698",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = (1:1000) * 2e9),
gmp::as.bigz("3649675516801803698"))
expect_equal(gmp::sub.bigz("3649675516801903698",
"3649675516801803698") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000 * 2e9))
## partitionsDesign(0:1000, 15)[c("num_partitions",
## "partition_type",
## "mapped_target")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 4556757507869210155
##
## $partition_type
## [1] "DstctOneZero"
##
## $mapped_target
## [1] 1015
bench <- partitionsGeneral(0:1000, 15,
lower = "4556757507869110155")
expect_identical(partitionsGeneral(0:1000, 15,
lower = "4556757507869110155",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 0:1000),
gmp::as.bigz("4556757507869110155"))
expect_equal(gmp::sub.bigz("4556757507869210155",
"4556757507869110155") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000))
## partitionsDesign(0:1000 * 2e9, 15)[c("num_partitions",
## "partition_type",
## "mapped_target")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 4556757507869210155
##
## $partition_type
## [1] "DstctOneZero"
##
## $mapped_target
## [1] 1015
bench <- partitionsGeneral(0:1000 * 2e9, 15,
lower = "4556757507869110155")
expect_identical(partitionsGeneral(0:1000 * 2e9, 15,
lower = "4556757507869110155",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = (0:1000) * 2e9),
gmp::as.bigz("4556757507869110155"))
expect_equal(gmp::sub.bigz("4556757507869210155",
"4556757507869110155") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000 * 2e9))
## partitionsDesign(0:1000, 12,
## freqs = c(3, rep(1, 1000)))[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 39228755152043560
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "DstctMultiZero"
bench <- partitionsGeneral(0:1000, 12,
lower = "39228755151943560",
freqs = c(3, rep(1, 1000)))
expect_identical(partitionsGeneral(0:1000, 12,
lower = "39228755151943560",
freqs = c(3, rep(1, 1000)),
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 0:1000,
freqs = c(3, rep(1, 1000))),
gmp::as.bigz("39228755151943560"))
expect_equal(gmp::sub.bigz("39228755152043560",
"39228755151943560") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000))
#### Mapped version
##
## 15 * 12 + 1000 * 3 = 3180
##
## partitionsDesign(15 + 0:1000 * 3, 12,
## freqs = c(3, rep(1, 1000)),
## target = 3180)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 39228755152043560
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "DstctMultiZero"
bench <- partitionsGeneral(15 + 0:1000 * 3, 12,
lower = "39228755151943560",
freqs = c(3, rep(1, 1000)),
target = 3180)
expect_identical(partitionsGeneral(15 + 0:1000 * 3, 12,
lower = "39228755151943560",
freqs = c(3, rep(1, 1000)),
target = 3180, nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 15 + 0:1000 * 3,
freqs = c(3, rep(1, 1000)),
target = 3180),
gmp::as.bigz("39228755151943560"))
expect_equal(gmp::sub.bigz("39228755152043560",
"39228755151943560") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 3180))
## partitionsDesign(0:1000, 12,
## freqs = c(13, rep(1, 1000)))[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 39233351450439724
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "DstctMultiZero"
bench <- partitionsGeneral(0:1000, 12,
lower = "39233351450339724",
freqs = c(13, rep(1, 1000)))
expect_identical(partitionsGeneral(0:1000, 12,
freqs = c(13, rep(1, 1000)),
lower = "39233351450339724",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 0:1000,
freqs = c(13, rep(1, 1000))),
gmp::as.bigz("39233351450339724"))
expect_equal(gmp::sub.bigz("39233351450439724",
"39233351450339724") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000))
#### Mapped version
##
## 19 * 12 + 1000 * 2 = 2228
##
## partitionsDesign(19 + 0:1000 * 2, 12, target = 2228,
## freqs = c(13, rep(1, 1000)))[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 39233351450439724
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "DstctMultiZero"
bench <- partitionsGeneral(19 + 0:1000 * 2, 12, target = 2228,
lower = "39233351450339724",
freqs = c(13, rep(1, 1000)))
expect_identical(partitionsGeneral(19 + 0:1000 * 2, 12, target = 2228,
freqs = c(13, rep(1, 1000)),
lower = "39233351450339724",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 19 + 0:1000 * 2,
target = 2228,
freqs = c(13, rep(1, 1000))),
gmp::as.bigz("39233351450339724"))
expect_equal(gmp::sub.bigz("39233351450439724",
"39233351450339724") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 2228))
########************* These take a few seconds ***************#######
## partitionsDesign(500, 10, target = 1380)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 9605186196368891
##
## $mapped_target
## [1] 1380
##
## $partition_type
## [1] "DistCapped"
bench <- partitionsGeneral(500, 10, lower = "9605186196168891",
target = 1380)
expect_identical(partitionsGeneral(500, 10, lower = "9605186196168891",
target = 1380, nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 500, target = 1380),
gmp::as.bigz("9605186196168891"))
expect_equal(gmp::sub.bigz("9605186196368891",
"9605186196168891") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1380))
## partitionsDesign(0:500, 10, target = 1380,
## freqs = c(3, rep(1, 500)))[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 10236925075643716
##
## $mapped_target
## [1] 1380
##
## $partition_type
## [1] "DstctCappedMZ"
bench <- partitionsGeneral(0:500, 10, freqs = c(3, rep(1, 500)),
lower = "10236925075443716", target = 1380)
expect_identical(partitionsGeneral(0:500, 10, freqs = c(3, rep(1, 500)),
lower = "10236925075443716", target = 1380,
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 0:500,
freqs = c(3, rep(1, 500)),
target = 1380),
gmp::as.bigz("10236925075443716"))
expect_equal(gmp::sub.bigz("10236925075643716",
"10236925075443716") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1380))
######************************* Compositions *************************#####
## compositionsDesign(300, 10)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 22478140825862400
##
## $mapped_target
## [1] 300
##
## $partition_type
## [1] "CmpDstctNoZero"
bench <- compositionsGeneral(300, 10, lower = "22478140825762400")
expect_identical(compositionsGeneral(300, 10, nThreads = 2,
lower = "22478140825762400"),
bench)
expect_identical(compositionsRank(bench[1, ], v = 300),
gmp::as.bigz("22478140825762400"))
expect_equal(gmp::sub.bigz("22478140825862400",
"22478140825762400") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 300))
## compositionsDesign(200, 10, target = 300)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 22475881190246400
##
## $mapped_target
## [1] 300
##
## $partition_type
## [1] "CmpDstctCapped"
bench <- compositionsGeneral(200, 10, target = 300,
lower = "22475881190046400")
expect_identical(compositionsGeneral(200, 10, target = 300, nThreads = 2,
lower = "22475881190046400"),
bench)
expect_identical(compositionsRank(bench[1, ], v = 200, target = 300),
gmp::as.bigz("22475881190046400"))
expect_equal(gmp::sub.bigz("22475881190246400",
"22475881190046400") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 300))
## compositionsDesign(0:200, 12, weak = TRUE)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 94068392477875200
##
## $mapped_target
## [1] 212
##
## $partition_type
## [1] "CmpDstctWeak"
bench <- compositionsGeneral(0:200, 12, weak = TRUE,
lower = "94068392477775200")
expect_identical(compositionsGeneral(0:200, 12, weak = TRUE, nThreads = 2,
lower = "94068392477775200"),
bench)
expect_identical(compositionsRank(bench[1, ], v = 0:200, weak = TRUE),
gmp::as.bigz("94068392477775200"))
expect_equal(gmp::sub.bigz("94068392477875200",
"94068392477775200") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200))
## compositionsDesign(0:100, 12, weak = TRUE, target = 200)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 93947774605977600
##
## $mapped_target
## [1] 212
##
## $partition_type
## [1] "CmpDstCapWeak"
bench <- compositionsGeneral(0:100, 12, weak = TRUE, target = 200,
lower = "93947774605777600")
expect_identical(compositionsGeneral(0:100, 12, weak = TRUE, target = 200, nThreads = 2,
lower = "93947774605777600"),
bench)
expect_identical(compositionsRank(bench[1, ], v = 0:100,
weak = TRUE, target = 200),
gmp::as.bigz("93947774605777600"))
expect_equal(gmp::sub.bigz("93947774605977600",
"93947774605777600") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200))
## compositionsDesign(0:200, 15, freqs = c(4, rep(1, 200)))[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 9847835447429548800
##
## $mapped_target
## [1] 200
##
## $partition_type
## [1] "CmpDstctZNotWk"
bench <- compositionsGeneral(0:200, 15, freqs = c(4, rep(1, 200)),
lower = "9847835447429448800")
expect_identical(compositionsGeneral(0:200, 15, freqs = c(4, rep(1, 200)),
nThreads = 2,
lower = "9847835447429448800"),
bench)
expect_identical(compositionsRank(bench[1, ], v = 0:200,
freqs = c(4, rep(1, 200))),
gmp::as.bigz("9847835447429448800"))
expect_equal(gmp::sub.bigz("9847835447429548800",
"9847835447429448800") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200))
## Testing the above as it moves from compositions of width 12 to 13.
mid_point <- sum(
do.call(
c,
lapply(
11:13, \(x) gmp::as.bigz(compositionsCount(200, m = x))
)
)
)
myLower <- gmp::sub.bigz(mid_point, 40000)
myUpper <- gmp::add.bigz(mid_point, 60000)
bench <- compositionsGeneral(0:200, 15, freqs = c(4, rep(1, 200)),
lower = myLower, upper = myUpper)
expect_identical(compositionsGeneral(0:200, 15, freqs = c(4, rep(1, 200)),
nThreads = 2,
lower = myLower, upper = myUpper),
bench)
expect_identical(compositionsRank(bench[1, ], v = 0:200,
freqs = c(4, rep(1, 200))), myLower)
expect_equal(100001, nrow(bench))
expect_true(all(rowSums(bench) == 200))
## compositionsDesign(0:100, 12, target = 200)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 46298981912198400
##
## $mapped_target
## [1] 200
##
## $partition_type
## [1] "CmpDstCapMZNotWk"
bench <- compositionsGeneral(0:100, 12, target = 200,
lower = "46298981912000000")
expect_identical(compositionsGeneral(0:100, 12, target = 200, nThreads = 2,
lower = "46298981912000000"),
bench)
expect_identical(compositionsRank(bench[1, ], v = 0:100, target = 200),
gmp::as.bigz("46298981912000000"))
expect_equal(gmp::sub.bigz("46298981912198400",
"46298981912000000") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200))
## Testing the above as it moves from compositions of width 11 to 12.
mid_point <- gmp::as.bigz(compositionsCount(100, 11, target = 200))
myLower <- gmp::sub.bigz(mid_point, 90000)
myUpper <- gmp::add.bigz(mid_point, 110000)
bench <- compositionsGeneral(0:100, 12, target = 200,
lower = myLower, upper = myUpper)
expect_identical(compositionsGeneral(0:100, 12, target = 200,
nThreads = 2,
lower = myLower, upper = myUpper),
bench)
expect_identical(compositionsRank(bench[1, ], v = 0:100, target = 200),
myLower)
expect_equal(200001, nrow(bench))
expect_true(all(rowSums(bench) == 200))
## compositionsDesign(0:200, 12, freqs = c(8, rep(1, 200)), weak = TRUE)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 123675593191381440
##
## $mapped_target
## [1] 200
##
## $partition_type
## [1] "CmpDstctMZWeak"
bench <- compositionsGeneral(0:200, 12, freqs = c(8, rep(1, 200)),
weak = TRUE, lower = "123675593191181440")
expect_identical(compositionsGeneral(0:200, 12, freqs = c(8, rep(1, 200)),
weak = TRUE, nThreads = 2,
lower = "123675593191181440"), bench)
expect_identical(compositionsRank(bench[1, ], v = 0:200, weak = TRUE,
freqs = c(8, rep(1, 200))),
gmp::as.bigz("123675593191181440"))
expect_equal(gmp::sub.bigz("123675593191381440",
"123675593191181440") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200))
## compositionsDesign(0:150, 12, freqs = c(8, rep(1, 150)),
## weak = TRUE, target = 250)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 1878764044241252520
##
## $mapped_target
## [1] 250
##
## $partition_type
## [1] "CmpDstCapMZWeak"
bench <- compositionsGeneral(0:150, 12, freqs = c(8, rep(1, 150)),
weak = TRUE, target = 250,
lower = "1878764044241052520")
expect_identical(compositionsGeneral(0:150, 12, freqs = c(8, rep(1, 150)),
weak = TRUE, target = 250, nThreads = 2,
lower = "1878764044241052520"), bench)
expect_identical(compositionsRank(bench[1, ], v =0:150,
freqs = c(8, rep(1, 150)),
weak = TRUE, target = 250),
gmp::as.bigz("1878764044241052520"))
expect_equal(gmp::sub.bigz("1878764044241252520",
"1878764044241052520") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 250))
######********************* Compositions Mapped **********************#####
## compositionsDesign((1:300) * 7, 10)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 22478140825862400
##
## $mapped_target
## [1] 300
##
## $partition_type
## [1] "CmpDstctNoZero"
bench <- compositionsGeneral((1:300) * 7, 10, lower = "22478140825762400")
expect_identical(compositionsGeneral((1:300) * 7, 10, nThreads = 2,
lower = "22478140825762400"),
bench)
expect_identical(compositionsRank(bench[1, ], v = (1:300) * 7),
gmp::as.bigz("22478140825762400"))
expect_equal(gmp::sub.bigz("22478140825862400",
"22478140825762400") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 300 * 7))
## 300 * 7 + 3 * 10 = 2310
##
## compositionsDesign(3L + (1:200) * 7, 10, target = 2130L)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 22475881190246400
##
## $mapped_target
## [1] 300
##
## $partition_type
## [1] "CmpDstctCapped"
bench <- compositionsGeneral(3L + (1:200) * 7, 10, target = 2130L,
lower = "22475881190046400")
expect_identical(compositionsGeneral(3L + (1:200) * 7, 10, target = 2130L,
nThreads = 2,
lower = "22475881190046400"),
bench)
expect_identical(compositionsRank(bench[1, ], v = 3L + (1:200) * 7,
target = 2130L),
gmp::as.bigz("22475881190046400"))
expect_equal(gmp::sub.bigz("22475881190246400",
"22475881190046400") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 2130L))
## compositionsDesign((0:200) * 3e9, 12, weak = TRUE)[c("num_partitions",
## "mapped_target",
##. "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 94068392477875200
##
## $mapped_target
## [1] 212
##
## $partition_type
## [1] "CmpDstctWeak"
bench <- compositionsGeneral((0:200) * 3e9, 12, weak = TRUE,
lower = "94068392477775200")
expect_identical(compositionsGeneral((0:200) * 3e9, 12, weak = TRUE,
nThreads = 2,
lower = "94068392477775200"),
bench)
expect_identical(compositionsRank(bench[1, ],
v = (0:200) * 3e9, weak = TRUE),
gmp::as.bigz("94068392477775200"))
expect_equal(gmp::sub.bigz("94068392477875200",
"94068392477775200") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200 * 3e9))
## compositionsDesign((0:100) * 47, 12, weak = TRUE, target = 200 * 47)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 93947774605977600
##
## $mapped_target
## [1] 212
##
## $partition_type
## [1] "CmpDstCapWeak"
bench <- compositionsGeneral((0:100) * 47, 12,
weak = TRUE, target = 200 * 47,
lower = "93947774605777600")
expect_identical(compositionsGeneral((0:100) * 47, 12, weak = TRUE,
target = 200 * 47, nThreads = 2,
lower = "93947774605777600"),
bench)
expect_identical(compositionsRank(bench[1, ], v = (0:100) * 47,
weak = TRUE, target = 200 * 47),
gmp::as.bigz("93947774605777600"))
expect_equal(gmp::sub.bigz("93947774605977600",
"93947774605777600") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200 * 47))
## compositionsDesign((0:200) * 97, 15, freqs = c(4, rep(1, 200)))[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 9847835447429548800
##
## $mapped_target
## [1] 200
##
## $partition_type
## [1] "CmpDstctZNotWk"
bench <- compositionsGeneral((0:200) * 97, 15, freqs = c(4, rep(1, 200)),
lower = "9847835447429448800")
expect_identical(compositionsGeneral((0:200) * 97, 15, freqs = c(4, rep(1, 200)),
nThreads = 2,
lower = "9847835447429448800"),
bench)
expect_identical(compositionsRank(bench[1, ], v = (0:200) * 97,
freqs = c(4, rep(1, 200))),
gmp::as.bigz("9847835447429448800"))
expect_equal(gmp::sub.bigz("9847835447429548800",
"9847835447429448800") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200 * 97))
## Testing the above as it moves from compositions of width 12 to 13.
mid_point <- sum(
do.call(
c,
lapply(
11:13, \(x) gmp::as.bigz(
compositionsCount((1:200) * 97, m = x)
)
)
)
)
myLower <- gmp::sub.bigz(mid_point, 40000)
myUpper <- gmp::add.bigz(mid_point, 60000)
bench <- compositionsGeneral((0:200) * 97, 15, freqs = c(4, rep(1, 200)),
lower = myLower, upper = myUpper)
expect_identical(compositionsGeneral((0:200) * 97, 15, freqs = c(4, rep(1, 200)),
nThreads = 2,
lower = myLower, upper = myUpper),
bench)
expect_identical(compositionsRank(bench[1, ], v = (0:200) * 97,
freqs = c(4, rep(1, 200))), myLower)
expect_equal(100001, nrow(bench))
expect_true(all(rowSums(bench) == 200 * 97))
## compositionsDesign((0:100) * 3000000019, 12, target = 200 * 3000000019)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 46298981912198400
##
## $mapped_target
## [1] 200
##
## $partition_type
## [1] "CmpDstCapMZNotWk"
bench <- compositionsGeneral((0:100) * 3000000019, 12,
target = 200 * 3000000019,
lower = "46298981912000000")
expect_identical(compositionsGeneral((0:100) * 3000000019, 12,
target = 200 * 3000000019,
nThreads = 2,
lower = "46298981912000000"),
bench)
expect_identical(compositionsRank(bench[1, ], v = (0:100) * 3000000019,
target = 200 * 3000000019),
gmp::as.bigz("46298981912000000"))
expect_equal(gmp::sub.bigz("46298981912198400",
"46298981912000000") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200 * 3000000019))
## compositionsDesign((0:200) * 97, 12, freqs = c(8, rep(1, 200)),
## weak = TRUE)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 123675593191381440
##
## $mapped_target
## [1] 200
##
## $partition_type
## [1] "CmpDstctMZWeak"
bench <- compositionsGeneral((0:200) * 97, 12, freqs = c(8, rep(1, 200)),
weak = TRUE, lower = "123675593191181440")
expect_identical(compositionsGeneral((0:200) * 97, 12, freqs = c(8, rep(1, 200)),
weak = TRUE, nThreads = 2,
lower = "123675593191181440"), bench)
expect_identical(compositionsRank(bench[1, ], v = (0:200) * 97, weak = TRUE,
freqs = c(8, rep(1, 200))),
gmp::as.bigz("123675593191181440"))
expect_equal(gmp::sub.bigz("123675593191381440",
"123675593191181440") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 200 * 97))
## compositionsDesign((0:150) * 907041845093, 12,
## freqs = c(8, rep(1, 150)),
## weak = TRUE, target = 250 * 907041845093)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
##
## $num_partitions
## Big Integer ('bigz') :
## [1] 1878764044241252520
##
## $mapped_target
## [1] 250
##
## $partition_type
## [1] "CmpDstCapMZWeak"
bench <- compositionsGeneral((0:150) * 907041845093, 12,
freqs = c(8, rep(1, 150)),
weak = TRUE, target = 250 * 907041845093,
lower = "1878764044241052520")
expect_identical(compositionsGeneral((0:150) * 907041845093, 12,
freqs = c(8, rep(1, 150)),
weak = TRUE, nThreads = 2,
target = 250 * 907041845093,
lower = "1878764044241052520"), bench)
expect_identical(compositionsRank(bench[1, ], v = (0:150) * 907041845093,
freqs = c(8, rep(1, 150)),
weak = TRUE, target = 250 * 907041845093),
gmp::as.bigz("1878764044241052520"))
expect_equal(gmp::sub.bigz("1878764044241252520",
"1878764044241052520") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 250 * 907041845093))
})
test_that("partition/compositionsGeneral and Repetition Parallel Lower GMP", {
#######################################################################
## See commentary above
########********************** Lower Only *******************##########
## partitionsDesign(0:300, repetition = T)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 9253082936723602
##
## $mapped_target
## [1] 300
##
## $partition_type
## [1] "RepStdAll"
bench <- partitionsGeneral(0:300, repetition = TRUE,
lower = "9253082936523602")
expect_identical(partitionsGeneral(0:300, repetition = TRUE,
lower = "9253082936523602",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 0:300,
repetition = TRUE),
gmp::as.bigz("9253082936523602"))
expect_equal(gmp::sub.bigz("9253082936723602",
"9253082936523602") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 300))
#### Mapped version
##
## 3 * 300 + 17 * 300 = 6000
##
## partitionsDesign(3L + (0:300) * 17L, 300, repetition = TRUE,
## target = 6000L)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 9253082936723602
##
## $mapped_target
## [1] 600
##
## $partition_type
## [1] "RepNoZero"
bench <- partitionsGeneral(3L + (0:300) * 17L, 300, repetition = TRUE,
lower = "9253082936523602", target = 6000L)
expect_identical(partitionsGeneral(3L + (0:300) * 17L, 300, repetition = TRUE,
lower = "9253082936523602", target = 6000L,
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 3L + (0:300) * 17L,
target = 6000L, repetition = TRUE),
gmp::as.bigz("9253082936523602"))
expect_equal(gmp::sub.bigz("9253082936723602",
"9253082936523602") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 6000L))
########********************** Lower Only *******************##########
## compositionsDesign(0:60, repetition = T)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 576460752303423488
##
## $mapped_target
## [1] 60
##
## $partition_type
## [1] "CmpRpZroNotWk"
bench <- compositionsGeneral(0:60, repetition = TRUE,
lower = "576460752303223488")
expect_identical(compositionsGeneral(0:60, repetition = TRUE,
lower = "576460752303223488",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:5, ], v = 0:60,
repetition = TRUE),
gmp::as.bigz("576460752303223488") + 0:4)
expect_equal(gmp::sub.bigz("576460752303423488",
"576460752303223488") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 60))
#### Mapped version
##
## compositionsDesign((0:60) * 19, repetition = T)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 576460752303423488
##
## $mapped_target
## [1] 60
##
## $partition_type
## [1] "CmpRpZroNotWk"
bench <- compositionsGeneral((0:60) * 19, repetition = TRUE,
lower = "576460752303223488")
expect_identical(compositionsGeneral((0:60) * 19, repetition = TRUE,
lower = "576460752303223488",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:5, ], v = (0:60) * 19,
repetition = TRUE),
gmp::as.bigz("576460752303223488") + 0:4)
expect_equal(gmp::sub.bigz("576460752303423488",
"576460752303223488") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 60 * 19))
## Weak = TRUE
##
## compositionsDesign(0:60, repetition = T, weak = T)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 48307454420181661301946569760686328
##
## $mapped_target
## [1] 120
##
## $partition_type
## [1] "CompRepWeak"
bench <- compositionsGeneral(0:60, repetition = TRUE, weak = TRUE,
lower = "48307454420181661301946569760486328")
expect_identical(compositionsGeneral(0:60, repetition = TRUE, weak = TRUE,
lower = "48307454420181661301946569760486328",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:5, ], v = 0:60,
repetition = TRUE, weak = TRUE),
gmp::as.bigz("48307454420181661301946569760486328") + 0:4)
expect_equal(gmp::sub.bigz("48307454420181661301946569760686328",
"48307454420181661301946569760486328") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 60))
## Mapped Version; Weak = TRUE
##
## compositionsDesign((0:60) * 19, 60, repetition = T,
## weak = T)[c("num_partitions", "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 48307454420181661301946569760686328
##
## $mapped_target
## [1] 120
##
## $partition_type
## [1] "CompRepNoZero"
bench <- compositionsGeneral((0:60) * 19, 60, repetition = TRUE, weak = TRUE,
lower = "48307454420181661301946569760486328")
expect_identical(compositionsGeneral((0:60) * 19, 60, repetition = TRUE, weak = TRUE,
lower = "48307454420181661301946569760486328",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:5, ], v = (0:60) * 19,
repetition = TRUE, weak = TRUE),
gmp::as.bigz("48307454420181661301946569760486328") + 0:4)
expect_equal(gmp::sub.bigz("48307454420181661301946569760686328",
"48307454420181661301946569760486328") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 60 * 19))
## partitionsDesign(6000, 10, TRUE)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 7856063261819197461639
##
## $mapped_target
## [1] 6000
##
## $partition_type
## [1] "RepNoZero"
bench <- partitionsGeneral(6000, 10, TRUE, lower = "7856063261819197261639")
expect_identical(partitionsGeneral(6000, 10, TRUE,
lower = "7856063261819197261639",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 6000,
repetition = TRUE),
gmp::as.bigz("7856063261819197261639"))
expect_equal(gmp::sub.bigz("7856063261819197461639",
"7856063261819197261639") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 6000L))
#### Mapped version
##
## partitionsDesign(2e9 * 1:6000, 10, TRUE)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 7856063261819197461639
##
## $mapped_target
## [1] 6000
##
## $partition_type
## [1] "RepNoZero"
bench <- partitionsGeneral(2e9 * 1:6000, 10, TRUE,
lower = "7856063261819197261639")
expect_identical(partitionsGeneral(2e9 * 1:6000, 10, TRUE,
lower = "7856063261819197261639",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 2e9 * 1:6000,
repetition = TRUE),
gmp::as.bigz("7856063261819197261639"))
expect_equal(gmp::sub.bigz("7856063261819197461639",
"7856063261819197261639") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1.2e+13))
## compositionsDesign(1000, 10, TRUE)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 2634095604619702128324
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "CompRepNoZero"
bench <- compositionsGeneral(1000, 10, TRUE, lower = "2634095604619701928324")
expect_identical(compositionsGeneral(1000, 10, TRUE,
lower = "2634095604619701928324",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:11, ], v = 1000,
repetition = TRUE),
gmp::as.bigz("2634095604619701928324") + 0:10)
expect_equal(gmp::sub.bigz("2634095604619702128324",
"2634095604619701928324") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000L))
#### Mapped version
##
## compositionsDesign(23 + (1:1000) * 123e8, 10, TRUE,
## target = 12300000000230)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 2634095604619702128324
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "CompRepNoZero"
bench <- compositionsGeneral(23 + (1:1000) * 123e8, 10, TRUE,
lower = "2634095604619701928324",
target = 12300000000230)
expect_identical(compositionsGeneral(23 + (1:1000) * 123e8, 10, TRUE,
lower = "2634095604619701928324",
target = 12300000000230,
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:11, ], v = 23 + (1:1000) * 123e8,
target = 12300000000230,
repetition = TRUE),
gmp::as.bigz("2634095604619701928324") + 0:10)
expect_equal(gmp::sub.bigz("2634095604619702128324",
"2634095604619701928324") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 12300000000230))
## compositionsDesign(300, 10, TRUE, target = 1000)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
## $num_partitions
## Big Integer ('bigz') :
## [1] 1620625022683448734459
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "CompRepCapped"
bench <- compositionsGeneral(300, 10, TRUE, target = 1000,
lower = "1620625022683448534459")
expect_identical(compositionsGeneral(300, 10, TRUE, target = 1000,
lower = "1620625022683448534459",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:11, ], v = 300, target = 1000,
repetition = TRUE),
gmp::as.bigz("1620625022683448534459") + 0:10)
expect_equal(gmp::sub.bigz("1620625022683448734459",
"1620625022683448534459") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000L))
#### Mapped version
##
## compositionsDesign(23 + (1:300) * 123e8, 10, TRUE,
## target = 12300000000230)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 1620625022683448734459
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "CompRepCapped"
bench <- compositionsGeneral(23 + (1:300) * 123e8, 10, TRUE,
target = 12300000000230,
lower = "1620625022683448534459")
expect_identical(compositionsGeneral(23 + (1:300) * 123e8, 10,
TRUE, target = 12300000000230,
lower = "1620625022683448534459",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:11, ], v = 23 + (1:300) * 123e8,
target = 12300000000230,
repetition = TRUE),
gmp::as.bigz("1620625022683448534459") + 0:10)
expect_equal(gmp::sub.bigz("1620625022683448734459",
"1620625022683448534459") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 12300000000230))
## compositionsDesign(15, 40, TRUE, target = 70)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
## $num_partitions
## Big Integer ('bigz') :
## [1] 31626933860118657196
##
## $mapped_target
## [1] 70
##
## $partition_type
## [1] "CompRepCapped"
bench <- compositionsGeneral(15, 40, TRUE, target = 70,
lower = "31626933860118457196")
expect_identical(compositionsGeneral(15, 40, TRUE, target = 70,
lower = "31626933860118457196",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:11, ], v = 15, target = 70,
repetition = TRUE),
gmp::as.bigz("31626933860118457196") + 0:10)
expect_equal(gmp::sub.bigz("31626933860118657196",
"31626933860118457196") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 70L))
## compositionsDesign(0:300, 10, TRUE, target = 1000)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
## $num_partitions
## Big Integer ('bigz') :
## [1] 1632937540829860491445
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "CmpRpCapZNotWk"
bench <- compositionsGeneral(0:300, 10, TRUE, target = 1000,
lower = "1632937540829860291445")
expect_identical(compositionsGeneral(0:300, 10, TRUE, target = 1000,
lower = "1632937540829860291445",
nThreads = 2), bench)
expect_identical(compositionsRank(bench[1:11, ], v = 0:300, target = 1000,
repetition = TRUE),
gmp::as.bigz("1632937540829860291445") + 0:10)
expect_equal(gmp::sub.bigz("1632937540829860491445",
"1632937540829860291445") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000L))
## compositionsDesign(0:300, 10, TRUE, target = 1000, weak = TRUE)[
## c("num_partitions",
## "mapped_target",
## "partition_type")
## ]
## $num_partitions
## Big Integer ('bigz') :
## [1] 1746444308278095001576
##
## $mapped_target
## [1] 1010
##
## $partition_type
## [1] "CompRepWeakCap"
bench <- compositionsGeneral(0:300, 10, TRUE, target = 1000, weak = TRUE,
lower = "1746444308278094801576")
expect_identical(compositionsGeneral(0:300, 10, TRUE, target = 1000,
lower = "1746444308278094801576",
nThreads = 2, weak = TRUE), bench)
expect_identical(compositionsRank(bench[1:11, ], v = 0:300, target = 1000,
repetition = TRUE, weak = TRUE),
gmp::as.bigz("1746444308278094801576") + 0:10)
expect_equal(gmp::sub.bigz("1746444308278095001576",
"1746444308278094801576") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000L))
## partitionsDesign(0:6000, 10, TRUE)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 7974346430545135003177
##
## $mapped_target
## [1] 6010
##
## $partition_type
## [1] "RepShort"
bench <- partitionsGeneral(0:6000, 10, TRUE, lower = "7974346430545134803177")
expect_identical(partitionsGeneral(0:6000, 10, TRUE,
lower = "7974346430545134803177",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 0:6000,
repetition = TRUE),
gmp::as.bigz("7974346430545134803177"))
expect_equal(gmp::sub.bigz("7974346430545135003177",
"7974346430545134803177") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 6000L))
#### Mapped version
##
## partitionsDesign(2e9 * 0:6000, 10, TRUE)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 7974346430545135003177
##
## $mapped_target
## [1] 6010
##
## $partition_type
## [1] "RepNoZero"
bench <- partitionsGeneral(2e9 * 0:6000, 10, TRUE,
lower = "7974346430545134803177")
expect_identical(partitionsGeneral(2e9 * 0:6000, 10, TRUE,
lower = "7974346430545134803177",
nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 2e9 * 0:6000,
repetition = TRUE),
gmp::as.bigz("7974346430545134803177"))
expect_equal(gmp::sub.bigz("7974346430545135003177",
"7974346430545134803177") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1.2e+13))
## partitionsDesign(200, 12, TRUE,
## target = 1000)[c("num_partitions",
## "mapped_target",
## "partition_type")]
## $num_partitions
## Big Integer ('bigz') :
## [1] 14001484381527012
##
## $mapped_target
## [1] 1000
##
## $partition_type
## [1] "RepCapped"
bench <- partitionsGeneral(200, 12, TRUE, target = 1000,
lower = "14001484381327012")
expect_identical(partitionsGeneral(200, 12, TRUE, lower = "14001484381327012",
target = 1000, nThreads = 2), bench)
expect_identical(partitionsRank(bench[1, ], v = 200,
target = 1000,
repetition = TRUE),
gmp::as.bigz("14001484381327012"))
expect_equal(gmp::sub.bigz("14001484381527012",
"14001484381327012") + 1, nrow(bench))
expect_true(all(rowSums(bench) == 1000))
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.