Skip to content
Snippets Groups Projects
Commit e35b1c03 authored by Adam Welc's avatar Adam Welc
Browse files

Added addtional specializations for "match" function.

parent 770aa21b
Branches
No related tags found
No related merge requests found
......@@ -100,6 +100,18 @@ public abstract class Match extends RBuiltinNode {
return matchRecursive(frame, RClosures.createFactorToVector(x, true, attrProfiles), RClosures.createFactorToVector(table, true, attrProfiles), nomatchObj, incomparables);
}
@Specialization
protected RIntVector match(VirtualFrame frame, RFactor x, RAbstractVector table, Object nomatchObj, Object incomparables) {
naCheck.enable(x.getVector());
return matchRecursive(frame, RClosures.createFactorToVector(x, true, attrProfiles), table, nomatchObj, incomparables);
}
@Specialization
protected RIntVector match(VirtualFrame frame, RAbstractVector x, RFactor table, Object nomatchObj, Object incomparables) {
naCheck.enable(table.getVector());
return matchRecursive(frame, x, RClosures.createFactorToVector(table, true, attrProfiles), nomatchObj, incomparables);
}
@Specialization
@SuppressWarnings("unused")
protected RIntVector match(RAbstractIntVector x, RAbstractIntVector table, Object nomatchObj, Object incomparables) {
......
......@@ -3176,6 +3176,9 @@ public class TestSimpleBuiltins extends TestBase {
assertEval("{ match(c(0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,NaN,NA,1), c(1,NA,NaN,1,2,3,4,5,6,7,8,9,10,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9)) }");
assertEval("{ match(factor(c(\"a\", \"b\")), factor(c(\"c\", \"b\", \"a\", \"b\", \"c\", \"a\"))) }");
assertEval("{ match(\"a\", factor(c(\"a\", \"b\", \"a\"))) }");
assertEval("{ match(factor(c(\"a\", \"b\", \"a\")), \"a\") }");
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment