Skip to content
Snippets Groups Projects
Commit 12d67574 authored by Florian Angerer's avatar Florian Angerer
Browse files

Minor fixes and cleanup.

parent 92e4e967
No related branches found
No related tags found
No related merge requests found
......@@ -235,22 +235,22 @@ public abstract class Transpose extends RBuiltinNode.Arg1 {
});
}
@Specialization(guards = "x.isMatrix()")
@Specialization(guards = {"x.isMatrix()", "!isSquare(x)"})
protected RVector<?> transpose(RAbstractIntVector x) {
return transposeInternal(x, l -> new int[l], (a, v, i, j) -> a[i] = v.getDataAt(j), RDataFactory::createIntVector);
}
@Specialization(guards = "x.isMatrix()")
@Specialization(guards = {"x.isMatrix()", "!isSquare(x)"})
protected RVector<?> transpose(RAbstractLogicalVector x) {
return transposeInternal(x, l -> new byte[l], (a, v, i, j) -> a[i] = v.getDataAt(j), RDataFactory::createLogicalVector);
}
@Specialization(guards = "x.isMatrix()")
@Specialization(guards = {"x.isMatrix()", "!isSquare(x)"})
protected RVector<?> transpose(RAbstractDoubleVector x) {
return transposeInternal(x, l -> new double[l], (a, v, i, j) -> a[i] = v.getDataAt(j), RDataFactory::createDoubleVector);
}
@Specialization(guards = "x.isMatrix()")
@Specialization(guards = {"x.isMatrix()", "!isSquare(x)"})
protected RVector<?> transpose(RAbstractComplexVector x) {
return transposeInternal(x, l -> new double[l * 2], (a, v, i, j) -> {
RComplex d = v.getDataAt(j);
......@@ -259,17 +259,17 @@ public abstract class Transpose extends RBuiltinNode.Arg1 {
}, RDataFactory::createComplexVector);
}
@Specialization(guards = "x.isMatrix()")
@Specialization(guards = {"x.isMatrix()", "!isSquare(x)"})
protected RVector<?> transpose(RAbstractStringVector x) {
return transposeInternal(x, l -> new String[l], (a, v, i, j) -> a[i] = v.getDataAt(j), RDataFactory::createStringVector);
}
@Specialization(guards = "x.isMatrix()")
@Specialization(guards = {"x.isMatrix()", "!isSquare(x)"})
protected RVector<?> transpose(RAbstractListVector x) {
return transposeInternal(x, l -> new Object[l], (a, v, i, j) -> a[i] = v.getDataAt(j), (a, c) -> RDataFactory.createList(a));
}
@Specialization(guards = "x.isMatrix()")
@Specialization(guards = {"x.isMatrix()", "!isSquare(x)"})
protected RVector<?> transpose(RAbstractRawVector x) {
return transposeInternal(x, l -> new byte[l], (a, v, i, j) -> a[i] = v.getRawDataAt(j), (a, c) -> RDataFactory.createRawVector(a));
}
......
......@@ -177,7 +177,9 @@ public abstract class PipelineStep<T, R> {
public final boolean vectorCoercion;
/**
* Whether the cast should reuse a non-shared vector.
* Allows the cast node to create and use wrappers for non-shared vectors. Only use if you
* know the vector to be casted won't escape and preferably if the vector is just used
* read-only.
*/
public final boolean reuseNonShared;
......
......@@ -66,7 +66,7 @@ abstract class RToDoubleVectorClosure extends RToVectorClosure implements RAbstr
@Override
public final RAbstractDoubleVector copyWithNewDimensions(int[] newDimensions) {
if (!keepAttributes) {
if (keepAttributes) {
return materialize().copyWithNewDimensions(newDimensions);
}
return this;
......
......@@ -61,7 +61,7 @@ public class TestBuiltin_t extends TestBase {
}
@Test
public void testTransposeNotSquare() {
public void testTransposeNonSquare() {
// test square matrices
assertEval("{ m <- matrix(1:8, 2, 4) ; t(m) }");
assertEval("{ m <- matrix(seq(0.1,0.8,0.1), 2, 4) ; t(m) }");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment