Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up
When trying to replicate the results of this question: Remove repeating numbers from for loop, I found an issue with how version
2.3.5handles multisets and their respective frequencies when the vector passed isn't sorted. Observe:Clearly, something is not right. We obtained
2135solutions with brute force and6561with the constraint algorithm. Let's have a look at the actual results.We can see that the brute force solution correctly repeats zero multiple times whereas the constraint algo repeats
11multiple times. This sorting is taken care of inGetPartitionCase:RcppAlgos/src/ConstraintsUtils.cpp
Lines 397 to 408 in 8364c46
And we see that it is a templated function that can accept vectors of different types:
RcppAlgos/src/ConstraintsUtils.cpp
Lines 377 to 382 in 8364c46
Now,
ConstraintsMaster.cppcallsGetPartitionCasehere:RcppAlgos/src/ConstraintsMaster.cpp
Lines 150 to 156 in 8364c46
And here is the problem. We are only taking care of numeric vectors (
vNumandtargetValsare vectors of typedouble). We can verify this by simply wrappingvalsabove withas.numeric:We simply need to ensure we handle the integer case appropriately.