Skip to content

Commit

Permalink
Fixed front and back methods. Was not setting the index vector. Also …
Browse files Browse the repository at this point in the history
…cleaned up summary.
  • Loading branch information
jwood000 committed Sep 18, 2023
1 parent 0ca780c commit 254d88f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion man/comboGroupsIterator.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ a = comboGroupsIter(12, 3)
a@nextIter()
a@nextNIter(3)
a@front()
a@nextRemaining()
all_remaining = a@nextRemaining()
dim(all_remaining)
a@summary()
a@back()
a[[5]]
Expand Down
13 changes: 7 additions & 6 deletions src/ComboGroupsClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ SEXP ComboGroupsClass::front() {
if (IsGmp) {
mpzIndex = 1;
mpzTemp = 0;
nthCmbGrpGmp(mpzTemp);
z = nthCmbGrpGmp(mpzTemp);
} else {
dblIndex = 1;
dblTemp = 0;
nthCmbGrp(dblTemp);
z = nthCmbGrp(dblTemp);
}

return SingleReturn();
Expand All @@ -308,11 +308,11 @@ SEXP ComboGroupsClass::back() {
if (IsGmp) {
mpzIndex = computedRowsMpz;
mpzTemp = computedRowsMpz - 1;
nthCmbGrpGmp(mpzTemp);
z = nthCmbGrpGmp(mpzTemp);
} else {
dblIndex = computedRows;
dblTemp = computedRows - 1;
nthCmbGrp(dblTemp);
z = nthCmbGrp(dblTemp);
}

return SingleReturn();
Expand All @@ -331,8 +331,9 @@ SEXP ComboGroupsClass::summary() {
grpSizeDesc.pop_back();

const std::string gtype = CmbGrp->GetType();
std::string prefix = "Partition of v into " + std::to_string(r);
std::string suffix = (gtype == "Uniform") ? " uniform groups" :
const std::string prefix = "Partition of v of length " +
std::to_string(n) + " into " + std::to_string(r);
const std::string suffix = (gtype == "Uniform") ? " uniform groups" :
" groups of sizes: " + grpSizeDesc;

const std::string strDesc = prefix + suffix;
Expand Down

0 comments on commit 254d88f

Please sign in to comment.